Commit 5a2e859f authored by dmattek's avatar dmattek
Browse files

Added: scatter plot based on 2 time-points with surrounding points

parent 03947223
...@@ -25,12 +25,15 @@ tabScatterPlotUI <- function(id, label = "Comparing t-points") { ...@@ -25,12 +25,15 @@ tabScatterPlotUI <- function(id, label = "Comparing t-points") {
fluidRow( fluidRow(
column( column(
6, 4,
uiOutput(ns('varSelTptX')), uiOutput(ns('uiSelTptX')),
uiOutput(ns('varSelTptY')) uiOutput(ns('uiSelTptY')),
checkboxInput(ns('chBfoldChange'), 'Y-axis displays fold change between the two t-points'),
numericInput(ns('inNeighTpts'), '#t-pts left & right', value = 0, step = 1, min = 0),
radioButtons(ns('rBstats'), 'Operation:', list('Mean' = 1, 'Min' = 2, 'Max' = 3))
), ),
column( column(
6, 4,
numericInput( numericInput(
ns('inPlotHeight'), ns('inPlotHeight'),
'Display plot height', 'Display plot height',
...@@ -74,8 +77,8 @@ getDataTpts <- reactive({ ...@@ -74,8 +77,8 @@ getDataTpts <- reactive({
return(unique(loc.dt$realtime)) return(unique(loc.dt$realtime))
}) })
output$varSelTptX = renderUI({ output$uiSelTptX = renderUI({
cat(file = stderr(), 'UI varSelTptX\n') cat(file = stderr(), 'UI uiSelTptX\n')
ns <- session$ns ns <- session$ns
...@@ -92,8 +95,8 @@ output$varSelTptX = renderUI({ ...@@ -92,8 +95,8 @@ output$varSelTptX = renderUI({
} }
}) })
output$varSelTptY = renderUI({ output$uiSelTptY = renderUI({
cat(file = stderr(), 'UI varSelTptY\n') cat(file = stderr(), 'UI uiSelTptY\n')
ns <- session$ns ns <- session$ns
...@@ -117,17 +120,49 @@ data4scatterPlot <- reactive({ ...@@ -117,17 +120,49 @@ data4scatterPlot <- reactive({
if(is.null(loc.dt.in)) if(is.null(loc.dt.in))
return(NULL) return(NULL)
loc.dt = data.table(x = loc.dt.in[realtime == input$inSelTptX, y], loc.tpts.x = input$inSelTptX
y = loc.dt.in[realtime == input$inSelTptY, y], loc.tpts.y = input$inSelTptY
group = loc.dt.in[realtime == input$inSelTptX, group])
# if neigbbouring points selected
if (input$inNeighTpts > 0) {
loc.dt.in.tpts = unique(loc.dt.in$realtime)
loc.tpts.x.id = seq(which(loc.dt.in.tpts == loc.tpts.x) - input$inNeighTpts, which(loc.dt.in.tpts == loc.tpts.x) + input$inNeighTpts, 1)
loc.tpts.y.id = seq(which(loc.dt.in.tpts == loc.tpts.y) - input$inNeighTpts, which(loc.dt.in.tpts == loc.tpts.y) + input$inNeighTpts, 1)
loc.tpts.x.id = loc.tpts.x.id[loc.tpts.x.id > 0]
loc.tpts.y.id = loc.tpts.y.id[loc.tpts.y.id > 0]
loc.tpts.x = loc.dt.in.tpts[loc.tpts.x.id]
loc.tpts.y = loc.dt.in.tpts[loc.tpts.y.id]
#cat(loc.tpts.x.id, '\n')
#cat(loc.tpts.y.id, '\n')
}
#cat(loc.tpts.x, '\n')
#cat(loc.tpts.y, '\n')
loc.dt.x = loc.dt.in[realtime == input$inSelTptX] if (input$rBstats == 1) {
loc.dt.y = loc.dt.in[realtime == input$inSelTptY] loc.dt.x = loc.dt.in[realtime %in% loc.tpts.x, .(y.aggr = mean(y)), by = .(group, id)]
loc.dt.y = loc.dt.in[realtime %in% loc.tpts.y, .(y.aggr = mean(y)), by = .(group, id)]
} else if (input$rBstats == 2) {
loc.dt.x = loc.dt.in[realtime %in% loc.tpts.x, .(y.aggr = min(y)), by = .(group, id)]
loc.dt.y = loc.dt.in[realtime %in% loc.tpts.y, .(y.aggr = min(y)), by = .(group, id)]
} else {
loc.dt.x = loc.dt.in[realtime %in% loc.tpts.x, .(y.aggr = max(y)), by = .(group, id)]
loc.dt.y = loc.dt.in[realtime %in% loc.tpts.y, .(y.aggr = max(y)), by = .(group, id)]
}
loc.dt = merge(loc.dt.x, loc.dt.y, by = 'id') loc.dt = merge(loc.dt.x, loc.dt.y, by = 'id')
setnames(loc.dt, c('group.x', 'y.x', 'y.y'), c('group', 'x', 'y')) loc.dt[, group.y := NULL]
setnames(loc.dt, c('group.x', 'y.aggr.x', 'y.aggr.y'), c('group', 'x', 'y'))
if (input$chBfoldChange) {
loc.dt[ , y := y / x]
}
return(loc.dt) return(loc.dt)
}) })
...@@ -197,6 +232,12 @@ output$outPlotScatterInt <- renderPlotly({ ...@@ -197,6 +232,12 @@ output$outPlotScatterInt <- renderPlotly({
# "Warning: Error in <Anonymous>: cannot open file 'Rplots.pdf'" # "Warning: Error in <Anonymous>: cannot open file 'Rplots.pdf'"
# When running on a server. Based on: # When running on a server. Based on:
# https://github.com/ropensci/plotly/issues/494 # https://github.com/ropensci/plotly/issues/494
if (locBut == 0) {
cat(file=stderr(), 'plotScatterInt Go button not pressed\n')
return(NULL)
}
if (names(dev.cur()) != "null device") dev.off() if (names(dev.cur()) != "null device") dev.off()
pdf(NULL) pdf(NULL)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment