Skip to content

Commit

Permalink
radio buttons were not updating correctly, avoided errors by changing…
Browse files Browse the repository at this point in the history
… test statements, but it's still strange that the updateradiobutton doesn't update the options and selected expression name and tests before going into "server-datafilter-update-expr"...
  • Loading branch information
jminnier committed Oct 21, 2018
1 parent 5a86e50 commit 89d50ea
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 30 deletions.
94 changes: 64 additions & 30 deletions server-filterdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,41 +39,20 @@ observe({
updateSelectizeInput(session,"datafilter_gene_select",
choices=data_analyzedgenes,server=TRUE)

updateSelectizeInput(session,"datafilter_selecttest",choices=tmptests)
updateSelectizeInput(session,"datafilter_selecttest",
choices=tmptests,
selected = tmptests[1]
)

updateRadioButtons(session,'datafilter_selectexpr',
choices=sort(tmpynames,decreasing = TRUE))
choices=sort(tmpynames,decreasing = TRUE),
selected= sort(tmpynames,decreasing = TRUE)[1])

})

# after selecting test

observe({
print("server-datafilter-update-tests")
data_analyzed = analyzeDataReactive()
if(!(input$datafilter_selecttest=="")) {
tmptest = input$datafilter_selecttest
# get max abs fold change for this test
tmpdat = data_analyzed$results
tmpdat = tmpdat%>%filter(test==tmptest)
tmpfc = abs(tmpdat$logFC)
tmpfc = tmpfc[tmpfc<Inf]
tmpmax = max(tmpfc,na.rm=T)
if(tmpmax==Inf)

updateNumericInput(session,"datafilter_fccut",
min=0,max= ceiling(tmpmax),value=0)
}
})

# after selecting expression value
observe({
tmpdat = data_analyzed$data_long # add filter by group and sample id
exprname = input$datafilter_selectexpr
print("server-datafilter-update-expr")
data_analyzed = analyzeDataReactive()
if(!(input$datafilter_selectexpr=="")) {
exprname = input$datafilter_selectexpr
if(exprname%in%colnames(tmpdat)) {
#calculate miin and max
tmpdat = data_analyzed$data_long # add filter by group and sample id
tmpmin = min(tmpdat[,colnames(tmpdat)==exprname],na.rm=T)
tmpmax = max(tmpdat[,colnames(tmpdat)==exprname],na.rm=T)

Expand All @@ -82,8 +61,63 @@ observe({
updateNumericInput(session,"datafilter_exprmax",
min=floor(tmpmin),max= ceiling(tmpmax),value=ceiling(tmpmax))
}

tmpdat = data_analyzed$results
tmptest = input$datafilter_selecttest
print("server-datafilter-update-tests")
if(!(tmptest=="")) {
# get max abs fold change for this test
tmpdat = tmpdat%>%filter(test==tmptest)
tmpfc = abs(tmpdat$logFC)
tmpfc = tmpfc[tmpfc<Inf]
tmpmax = max(tmpfc,na.rm=T)
if(tmpmax==Inf) {tmpmax = max(tmpfc[tmpfc<Inf],na.rm=T)}

updateNumericInput(session,"datafilter_fccut",
min=0,max= ceiling(tmpmax),value=0)
}


})

# after selecting test

# observe({
# print("server-datafilter-update-tests")
# data_analyzed = analyzeDataReactive()
# if(!(input$datafilter_selecttest=="")) {
# tmptest = input$datafilter_selecttest
# # get max abs fold change for this test
# tmpdat = data_analyzed$results
# tmpdat = tmpdat%>%filter(test==tmptest)
# tmpfc = abs(tmpdat$logFC)
# tmpfc = tmpfc[tmpfc<Inf]
# tmpmax = max(tmpfc,na.rm=T)
# if(tmpmax==Inf)
#
# updateNumericInput(session,"datafilter_fccut",
# min=0,max= ceiling(tmpmax),value=0)
# }
# })

# after selecting expression value
# observe({
# print("server-datafilter-update-expr")
# data_analyzed = analyzeDataReactive()
# if(!(input$datafilter_selectexpr=="")) {
# exprname = input$datafilter_selectexpr
# #calculate miin and max
# tmpdat = data_analyzed$data_long # add filter by group and sample id
# tmpmin = min(tmpdat[,colnames(tmpdat)==exprname],na.rm=T)
# tmpmax = max(tmpdat[,colnames(tmpdat)==exprname],na.rm=T)
#
# updateNumericInput(session,"datafilter_exprmin",
# min=floor(tmpmin),max= ceiling(tmpmax),value=floor(tmpmin))
# updateNumericInput(session,"datafilter_exprmax",
# min=floor(tmpmin),max= ceiling(tmpmax),value=ceiling(tmpmax))
# }
# })



filterDataReactive <- reactive({
Expand Down
1 change: 1 addition & 0 deletions server-inputdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ analyzeDataReactive <-
## ==================================================================================== ##
## Count/expression data
## ==================================================================================== ##

if(input$inputdat_type=="expression_only") {
numgeneids <- 0

Expand Down

0 comments on commit 89d50ea

Please sign in to comment.