Skip to content

Commit 5660c45

Browse files
committed
Upload cancer types
1 parent e0281d1 commit 5660c45

File tree

7 files changed

+77
-17
lines changed

7 files changed

+77
-17
lines changed

CPP/modals.R

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ formatBSModal<-function (id, title, trigger, applyID, ..., size, applyText = "Up
4343

4444
welcomeModal <- bsModal("welcomeModal",HTML("<i>Cancer Publication Portal</i>"), trigger = "btnNewSearch", size = "large",
4545
p(strong("Instructions:"), "Welcome to the Cancer Publication Portal for summarizing and searching cancer-related literature.",
46-
"To start, select a gene and click the 'Summarize cancer types' button to select the cancer types you are interested in.
46+
"To start, select a gene or genes and click the 'Summarize cancer types' button to select the cancer types you are interested in.
4747
After selecting the cancer types of interest, articles will be summarized based on drugs, cancer terms, mutations, and additional genes
4848
mentioned in article titles and abstracts. Additional filters can be applied by clicking on any of the tables."),
4949

@@ -265,7 +265,8 @@ cancerTypeSetupModal <- formatBSModal("cancerTypeSetupModal", "Select cancer typ
265265
fluidRow(column(12,
266266
uiOutput('cancerTypeSummaryHeader'),
267267
progressDiv('cancerTypeProgress', 'cancerSelection-bar-text'),
268-
HTML("<p>Select your desired cancer types by clicking on the table or by using the drop down below.
268+
HTML("<p>Select your desired cancer types by clicking on the table or by using the drop down below. You may also
269+
upload your cancer types from a file, and Download your selected cancer types for future use.
269270
When you are finished, click the 'Retrieve' button to retrieve summaries of your results. </br></br>\
270271
</p>")
271272
)),
@@ -278,16 +279,25 @@ cancerTypeSetupModal <- formatBSModal("cancerTypeSetupModal", "Select cancer typ
278279
column(1),
279280

280281
column(5,
281-
282282
fluidRow(
283283
conditionalPanel(condition="!$('html').hasClass('shiny-busy')",
284284
style="padding-right:0px",
285285
div(id = "cancerTypeDiv",
286-
selectizeInput("cancerType", "Selected cancer types: ", choices = NULL, multiple = TRUE,
287-
options = list(placeholder = "(leave blank to search all articles)") ),
286+
selectizeInput("cancerType", "Selected cancer types:", choices = NULL, multiple = TRUE,
287+
options = list(placeholder = "(leave blank to search all articles)")),
288+
downloadLink('saveCancerTypes', 'Save selected cancer types to file'),
288289
htmlOutput("cancerSelectionMsg")
289290
)
290-
))
291+
),
292+
fluidRow(
293+
fileInput("cancerTypeFile", "Upload cancer types (must include MeshIDs in first column)",
294+
accept = c(
295+
"text/csv",
296+
"text/comma-separated-values,text/plain",
297+
".csv")
298+
)
299+
)
300+
)
291301
)
292302
),
293303

@@ -296,6 +306,11 @@ cancerTypeSetupModal <- formatBSModal("cancerTypeSetupModal", "Select cancer typ
296306
)
297307

298308

309+
##########################################################################
310+
# Add download button to footer
311+
312+
##########################################################################
313+
299314
showProgress <- function(msg = NULL) {
300315
if (!is.null(msg)) {
301316
shinyjs::html("cancerSelection-bar-text", msg)

CPP/server-cancerTypeSetup.R

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,22 @@ observeEvent(input$btnSelectCancerType, {
5555
hideProgress()
5656
enableTableClicks()
5757

58+
reset('cancerTypeFile')
59+
5860
})
5961

6062
# ## update btnSelectCancerType based on current selection
6163
observe({
6264
label <- "Retrieve summaries for selected cancer types"
6365
if (is.null(input$cancerType)) {
6466
label <- "Retrieve summaries for all cancer types"
67+
catn('hide')
68+
shinyjs::hide('saveCancerTypes')
69+
} else {
70+
shinyjs::show('saveCancerTypes')
6571
}
6672
updateActionButton(session, "btnSelectCancerType", label)
67-
73+
6874
if (is.null(diseaseSummary$dat)) {
6975
return()
7076
}
@@ -79,5 +85,30 @@ observe({
7985

8086

8187

88+
observeEvent(input$cancerTypeFile, {
89+
cat("look at file")
90+
if (is.null(input$cancerTypeFile)) {
91+
return()
92+
}
93+
types <- read.csv(input$cancerTypeFile$datapath, nrows = 1000, header = FALSE, as.is = 1)
94+
if (ncol(types) > 2) {
95+
shinyjs::alert('Invalid format: gene file should have Mesh IDs in first column')
96+
return()
97+
}
98+
99+
choices <- cancerSelectionChoices()
100+
101+
if (!any(types$V1 %in% choices)) {
102+
shinyjs::alert('File does not contain any cancer types for current selection')
103+
}
104+
105+
updateSelectInput(session, "cancerType", choices = choices,
106+
selected = types$V1)
107+
108+
#updateTextAreaInput(session, 'multiGeneInput', value = paste0(genes$V1, collapse = "\n"))
109+
110+
})
111+
112+
82113

83114

CPP/server-download.R

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,23 @@ writeDownloadHeader <- function(header, file) {
3838
}
3939

4040

41+
output$saveCancerTypes <- downloadHandler(
42+
"selectedCancerTypes.csv",
43+
content = function(file) {
44+
choices <- cancerSelectionChoices()
45+
46+
m <- match(input$cancerType, choices)
47+
choices <- choices[m]
48+
write.table(data.frame(unlist(choices), names(choices), row.names = NULL), file, sep = ",", row.names = FALSE, col.names = FALSE)
49+
50+
msg <- paste0("Cancer types saved to your download directory")
51+
showNotification(msg, duration = 4, closeButton = TRUE,
52+
id = "fileSaveNotification", type = "message")
53+
54+
},
55+
contentType = "text/csv"
56+
)
57+
4158
output$downloadPMIDs <- downloadHandler(
4259
"pmids.csv",
4360
content = function(file) {

CPP/server-geneSearch.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ cancerSummaryByGenes <- function(geneID) {
121121
shinyjs::removeClass('welcomeModalProgress', 'hide')
122122
validSearch <- getCancerTypes()
123123

124-
if (!validSearch) {
124+
if (is.null(validSearch)) {
125125
shinyjs::addClass('welcomeModalProgress', 'hide')
126126
resetReactiveValues()
127127
shinyjs::addClass(id = "btnWelcomeCancel", class = "cancel")

CPP/server.R

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -392,14 +392,9 @@ shinyServer(function(input, output, session) {
392392
cat("NO RESULTS -- SHOULD BE CHECKED!")
393393
# don't stop here because this is now possible
394394
# if user updates cancer types but keeps filters
395-
pmids <- "NULL"
396395
return()
397396
}
398397

399-
#update PMIDs
400-
if (pmids == 'NULL') {
401-
pmids <- NULL
402-
}
403398
pmidList$pmids <- data.frame(PMID = pmids)
404399

405400
getSummaries("Cancer Types", con, getMeshSummaryByPMIDs, pmids, session, diseaseSummary, "filterDisease")
@@ -444,13 +439,13 @@ shinyServer(function(input, output, session) {
444439
if (n == 0) {
445440
dbDisconnect(con)
446441
cat("NO RESULTS -- SHOULD BE CHECKED!")
447-
return(FALSE)
442+
return(NULL)
448443
} else if (n > limit) {
449444
dbDisconnect(con)
450445
msg <- paste0('Limit exceeded: your gene list has >200,000 results.\n\n',
451446
'Reduce the number of genes in your list and search again.')
452447
shinyjs::alert(msg)
453-
return(FALSE)
448+
return(NULL)
454449
}
455450

456451
# get Mesh IDs

CPP/stackedBarGraphs.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ getStackedResults2 <- function(sql_function, group, group.filters) {
9191
res2[[group]] <- factor(res2[[group]], levels = n)
9292

9393
if (!is.null(msg)) {
94-
showNotification(msg, duration = 6, closeButton = TRUE,
94+
showNotification(msg, duration = 4, closeButton = TRUE,
9595
id = "graphNotification")
9696
}
9797

CPP/ui-about.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ tabAbout = tabPanel("About",
5959
HTML("</li>"),
6060

6161
HTML("</ul>")
62+
), div(
63+
HTML("</br></br></br><b> Last updated: 10/24/2019</b>")
64+
)
6265
)
63-
)
6466
)
6567

0 commit comments

Comments
 (0)