Skip to content

Commit f4915d5

Browse files
authored
Merge pull request #78 from gdancik/master
merge with current shinyGEO version
2 parents ad62d58 + 50ada19 commit f4915d5

File tree

7 files changed

+56
-38
lines changed

7 files changed

+56
-38
lines changed

RData/getTestData.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Download testdata using first platform for given GSE
44
#####################################################################
55

6-
GSE = "GSE13507"
6+
GSE = "GSE33331"
77
SAVE.FILE = paste0(GSE, ".RData")
88

99

misc/bsModal.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ shiny::tags$div(class = "modal-body",
9090
fluidRow(
9191
column(7,
9292
tags$h4(class="col-time-head","Time Column Selection"),
93-
selectizeInput('autoColumn.time','Time Column',choices=NULL),
93+
selectizeInput('autoColumnTime','Time Column',choices=NULL),
9494
tags$br(),
9595
DT::dataTableOutput("timetable")
9696
),
9797
column(1,""),
9898
column(3,
9999
tags$h4(class="col-time-head","Outcome Column Selection"),
100-
selectizeInput('autoColumn.outcome','Outcome Column',choices=NULL),
100+
selectizeInput('autoColumnOutcome','Outcome Column',choices=NULL),
101101
tags$br(),
102102
tags$div(class="columnSelect",
103103
selectizeInput('columnEvent1',label ="Event: Yes",choices = NULL,multiple = TRUE)

server.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
TRACE = FALSE
1+
TRACE = TRUE
22
shinycat <<-function(...) {
33
if (TRACE) cat(...)
44
}

server/server-report.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ add.probe = paste0("probe = \"", input$selectGenes, "\"")
214214
kmplot <-paste0("probe = \"", input$selectGenes, "\"
215215
x = data.expr[probe,]
216216
217-
outcome.column = \"", input$autoColumn.outcome, "\"
217+
outcome.column = \"", input$autoColumnOutcome, "\"
218218
outcome.orig = data.p[[outcome.column]]
219219
outcome = rep(NA, length(outcome.orig))
220220

server/server-survival.R

Lines changed: 49 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ library(stringr)
55
##
66
calc.columns <- function(this){
77
# First need to grep the first row of the data, then lapply a function that will return true for
8-
time.pattern = c("distant-relapse free survival","time","survival \\(mo\\)", "survival month")
8+
time.pattern = c("distant-relapse free survival","time","survival \\(mo\\)", "survival month", "survival \\(months\\)","survival months")
99
outcome.pattern = c("distant-relapse event","outcome","dead of disease","dss censor","os censor","overall survival", "cancer specific survival", "survival")
1010

1111
is.time.column <- function(x){
@@ -17,6 +17,9 @@ calc.columns <- function(this){
1717
}
1818
is.outcome.column <- function(x){
1919
ans = grepl(paste(outcome.pattern,collapse="|"),x)
20+
# not an outcome if contains 'month'
21+
ans2 = grepl("month",x)
22+
ans = ans & !ans2
2023
if(any(ans)){
2124
return(TRUE)
2225
}
@@ -32,6 +35,7 @@ calc.columns <- function(this){
3235
else if(length(x.time) == 0){
3336
x.time = NA
3437

38+
3539
}
3640
if(length(y.outcome) > 1)
3741
{
@@ -42,15 +46,19 @@ calc.columns <- function(this){
4246
else if(length(y.outcome) == 0){
4347
y.outcome = NA
4448
}
49+
50+
if(is.na(x.time) & !is.na(y.outcome)){
51+
createAlert(session,"warningAlert",alertId = "warn1",title = "Warning: No survival time columns were found!", content = "<p>If you believe this is incorrect, you can review the clinical data and select the appropriate column. </p>",style= 'danger', dismiss = TRUE, append = TRUE)
52+
}
53+
else if(is.na(y.outcome) & !is.na(x.time)){
54+
createAlert(session,"warningAlert",alertId = "warn1",title = "Warning: No survival outcome columns were found!", content = "<p>If you believe this is incorrect, you can review the clinical data and select the appropriate column. </p>",style= 'danger', dismiss = TRUE, append = TRUE)
55+
}
4556

46-
if(is.na(y.outcome) & !is.na(x.time)){
57+
if(y.outcome == x.time & !is.na(y.outcome) & !is.na(x.time)){
58+
y.outcome = NA
4759
createAlert(session,"warningAlert",alertId = "warn1",title = "Warning: No survival outcome columns were found!", content = "<p>If you believe this is incorrect, you can review the clinical data and select the appropriate columns. </p>",style= 'danger', dismiss = TRUE, append = TRUE)
4860

4961
}
50-
else if(is.na(x.time) & !is.na(y.outcome)){
51-
createAlert(session,"warningAlert",alertId = "warn1",title = "Warning: No survival time columns were found!", content = "<p>If you believe this is incorrect, you can review the clinical data and select the appropriate columns. </p>",style= 'danger', dismiss = TRUE, append = TRUE)
52-
}
53-
5462
ans = c(x.time,y.outcome)
5563
return (ans)
5664
}
@@ -63,11 +71,11 @@ time.analysis <-reactive({
6371
this = values.edit$table
6472
if(is.null(this)) return(NULL)
6573

66-
code1 = paste0("time.column = \"", input$autoColumn.time, "\"")
74+
code1 = paste0("time.column = \"", input$autoColumnTime, "\"")
6775
code2 = paste0("time = as.double(gsub(\".*: \",\"\",data.p[[time.column]]))")
6876

6977
code = paste(code1, code2, sep = "\n")
70-
time = as.double(reduce(this[[input$autoColumn.time]]))
78+
time = as.double(reduce(this[[input$autoColumnTime]]))
7179

7280
list(code = code, time = time)
7381

@@ -102,24 +110,23 @@ reduce <- function(column){
102110
# because time and outcome may be autodetected
103111
# (i.e., not selected in drop down)
104112
reduce.columns <- function(time,outcome,this){
105-
106113
if(is.na(time) && is.na(outcome)){
107114
createAlert(session, "warningAlert", alertId = "warn3", title = "Warning: No Columns were found",
108-
content = c("<p>Oops! shinyGEO could not find columns for survival analysis in your data. Please try the following: <ol><li>View the table and select the columns relevant to time and outcome or..</li><li>Use manual selection and format your data accordingly.</li></ol></p>"), style= 'danger', dismiss = TRUE, append = TRUE)
115+
content = c("<p>Oops! shinyGEO could not find columns for survival analysis in your data. Please try the following: <ol><li>View the table and select the columns relevant to time and outcome </li><li>If necessary, manually format the data by exporting the data, reformatting, and uploading your data back into <i>shinyGEO</i>.</li></ol></p>"), style= 'danger', dismiss = TRUE, append = TRUE)
109116
ans = list(time = NA, outcome = NA)
110117
return(ans)
111118
}
112119

113120
if(is.na(outcome)){
114121
reduced.time = reduce(this[[time]])
115-
ans = list(time = reduced.time)
122+
ans = list(time = reduced.time, outcome = NA)
116123
return(ans)
117124
}
118125
else if(is.na(time)){
119126
reduced.outcome = reduce(this[[outcome]])
120127
reduced.outcome = replace(reduced.outcome,(reduced.outcome == "NO" | reduced.outcome == "censored" | reduced.outcome == "survival"),0)
121128
reduced.outcome = replace(reduced.outcome,(reduced.outcome == "YES" | reduced.outcome == "uncensored" | reduced.outcome == "death"),1)
122-
ans = list(outcome = reduced.outcome)
129+
ans = list(time = NA,outcome = reduced.outcome)
123130
return (ans)
124131

125132
} else{
@@ -137,11 +144,10 @@ reduce.columns <- function(time,outcome,this){
137144
main.gen <- function(this,columns.data){
138145
#Reduce and analyze
139146
# update inputs for time and outcome columns
140-
updateSelectizeInput(session,"autoColumn.time",choices=colnames(this),
147+
updateSelectizeInput(session,"autoColumnTime",choices=colnames(this),
141148
selected=columns.data[1])
142-
updateSelectizeInput(session,"autoColumn.outcome",choices=colnames(this),
149+
updateSelectizeInput(session,"autoColumnOutcome",choices=colnames(this),
143150
selected=columns.data[2])
144-
145151
new = reduce.columns(columns.data[1],columns.data[2],this)
146152
if (!is.na(new$outcome)) {
147153
outcome.orig = as.character(this[[columns.data[2]]])
@@ -176,9 +182,9 @@ main.gen <- function(this,columns.data){
176182

177183
if (!values.edit$autogen) {
178184
# use last saved values
179-
updateSelectizeInput(session,"autoColumn.time",choices=colnames(this),
185+
updateSelectizeInput(session,"autoColumnTime",choices=colnames(this),
180186
selected=KM$time.col)
181-
updateSelectizeInput(session,"autoColumn.outcome",choices=colnames(this),
187+
updateSelectizeInput(session,"autoColumnOutcome",choices=colnames(this),
182188
selected=KM$outcome.col)
183189

184190
events = as.character(unique(this[[KM$outcome.col]]))
@@ -199,17 +205,23 @@ main.gen <- function(this,columns.data){
199205

200206

201207
# display time table when time column is updated
202-
observeEvent(input$autoColumn.time,({
203-
shinycat("observe autoColumn.time...\n")
208+
observeEvent(input$autoColumnTime,({
209+
shinycat("observe autoColumnTime...\n")
204210
this = values.edit$table
205211
if (is.null(this)) return(NULL)
206-
if (input$autoColumn.time == "") return(NULL)
207-
208-
#new = reduce.columns(input$autoColumn.time,NA,this)
212+
if (input$autoColumnTime == "") return(NULL)
213+
if (input$autoColumnOutcome == ""){
214+
shinyjs::disable("genBtn")
215+
}
216+
else{
217+
shinyjs::enable("genBtn")
218+
}
219+
220+
#new = reduce.columns(input$autoColumnTime,NA,this)
209221
#if (length(new$time) == 0) return(NULL)
210222

211223

212-
time_both <- data.frame("TimeColumnOriginal" = this[[input$autoColumn.time]],"TimeColumnFormatted" = time.analysis()$time)
224+
time_both <- data.frame("TimeColumnOriginal" = this[[input$autoColumnTime]],"TimeColumnFormatted" = time.analysis()$time)
213225

214226
rownames(time_both) <- rownames(this)
215227

@@ -220,15 +232,21 @@ main.gen <- function(this,columns.data){
220232
}))
221233

222234

223-
observeEvent(input$autoColumn.outcome,({
224-
shinycat("observe autoColumn.outcome...\n")
235+
observeEvent(input$autoColumnOutcome,({
236+
shinycat("observe autoColumnOutcome...\n")
225237
if (is.null(values.edit$table)) return(NULL)
226238
this = values.edit$table
227-
selected = input$autoColumn.outcome
239+
selected = input$autoColumnOutcome
228240
if (selected == "") return(NULL)
241+
if (input$autoColumnTime == ""){
242+
shinyjs::disable("genBtn")
243+
} else{
244+
shinyjs::enable("genBtn")
245+
}
246+
229247
selected = setdiff(selected, c("", " "))
230-
outcome.orig = as.character(this[[input$autoColumn.outcome]])
231-
outcome.new = outcome.01(input$autoColumn.outcome, this)
248+
outcome.orig = as.character(this[[input$autoColumnOutcome]])
249+
outcome.new = outcome.01(input$autoColumnOutcome, this)
232250
outcome.no = unique(outcome.orig[outcome.new == 0])
233251
outcome.yes = unique(outcome.orig[outcome.new == 1])
234252
columnItems = as.character(unique(this[[selected]]))
@@ -245,16 +263,16 @@ main.gen <- function(this,columns.data){
245263
KM$generated <- TRUE
246264
closeAlert(session, alertId = "SelectKM")
247265
values.edit$autogen <- FALSE
248-
KM$time.col = isolate(input$autoColumn.time)
249-
KM$outcome.col = isolate(input$autoColumn.outcome)
266+
KM$time.col = isolate(input$autoColumnTime)
267+
KM$outcome.col = isolate(input$autoColumnOutcome)
250268
KM$eventNo = isolate(input$columnEvent0)
251269
KM$eventYes = isolate(input$columnEvent1)
252270

253271
if (is.null(values.edit$table)) return(NULL)
254272
output$kmSurvival <- renderPlot({
255273
main = paste(input$GSE, geneLabel() , sep = ": ")
256274

257-
if (input$autoColumn.outcome == "") return(NULL)
275+
if (input$autoColumnOutcome == "") return(NULL)
258276

259277
outcome.orig = values.edit$table[[KM$outcome.col]]
260278
outcome.analysis = rep(NA, length(outcome.orig))

server/settings.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ if (TEST.DATA) {
99
#load("RData/GSE19915.RData")
1010
#load("RData/GSE13.RData")
1111
load("RData/GSE13507.RData")
12+
#load("RData/GSE33331.RData")
1213
}
1314

ui/ui.tab.about.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ tab.about = tabItem("About",
1717
<a href ='http://bioinformatics.easternct.edu/'>Bioinformatics Laboratory Page</a> <span class= \'label label-primary\'>Package Maintainer</span></p>
1818
1919
<p><span style = \'font-weight: bold\'> Michael Gargano </span>
20-
is currently a Computer Science major at Eastern Connecticut State University graduating in May of 2016. His interests include web application development, text mining, and bioinformatics.
21-
He currently works as a web application developer intern for Cigna. </p>
20+
has a BS degree in Computer Science from Eastern Connecticut State University. He is pursuing a Masters in Bioinformatics at Northeastern University.</p>
2221
</div>
2322
2423
<div class='panel-heading'>

0 commit comments

Comments
 (0)