[go: nahoru, domu]

Skip to content
This repository has been archived by the owner on Jun 23, 2020. It is now read-only.

Commit

Permalink
Add fixed expression range support to 3D model coloring
Browse files Browse the repository at this point in the history
  • Loading branch information
mschilli87 committed May 17, 2018
1 parent 9b4b505 commit b268c9b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 17 deletions.
31 changes: 18 additions & 13 deletions functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# file: functions.R
# author(s): Marcel Schilling <marcel.schilling@mdc-berlin.de>
# created: 2017-02-23
# last update: 2018-04-16
# last update: 2018-04-23
# license: GNU Affero General Public License Version 3 (GNU AGPL v3)
# purpose: define functions for tomo-seq shiny app

Expand All @@ -30,6 +30,7 @@
# change log (reverse chronological) #
######################################

# 2018-04-23: added fixed expression range support to 3D model coloring
# 2018-04-16: renamed y-axis limits inputs to expression range inputs
# 2018-04-13: added sample shifts & stretches to 3D model coloring
# removed left-over code from user specified sample shift/strech support
Expand Down Expand Up @@ -2206,24 +2207,28 @@ generate.heatmap<-
# end heatmap generation function definition
}

plot.model3d <- function(outline, cpm.fit = NULL){
plot.model3d <- function(outline, cpm.fit = NULL, plot.options = character(0),
manual.exprlim = NULL){

if(is.null(cpm.fit)) outline %<>% mutate(cpm = NA)
else
outline %<>%
left_join(distinct(., dp) %>%
mutate(cpm = predict(cpm.fit, dp)))
if(!("set.exprlim" %in% plot.options)) manual.exprlim <- NULL

outline %>%
plot_ly(x = ~dp, y = ~lr, z = ~dv) %>%
add_lines(color = ~cpm, colors = params$colorscale.model3d) %>%
colorbar(title = params$colorlab.model3d) %>%
layout(title = params$plot.title.model3d,
scene = list(xaxis = list(title = params$dplab.model3d),
yaxis = list(title = params$lrlab.model3d),
zaxis = list(title = params$dvlab.model3d),
aspectmode = "data",
camera = list(eye = list(x = params$eye.model3d.dp,
y = params$eye.model3d.lr,
z = params$eye.model3d.dv))))}
plot_ly(x = ~dp, y = ~lr, z = ~dv) %>%
add_lines(color = ~cpm, colors = params$colorscale.model3d) %>%
colorbar(title = params$colorlab.model3d, limits = manual.exprlim) %>%
layout(title = params$plot.title.model3d,
scene = list(xaxis = list(title = params$dplab.model3d),
yaxis = list(title = params$lrlab.model3d),
zaxis = list(title = params$dvlab.model3d),
aspectmode = "data",
camera = list(eye = list(x = params$eye.model3d.dp,
y = params$eye.model3d.lr,
z = params$eye.model3d.dv))))}


##########################
Expand Down
6 changes: 5 additions & 1 deletion params.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# file: params.R
# author(s): Marcel Schilling <marcel.schilling@mdc-berlin.de>
# created: 2017-02-21
# last update: 2018-04-16
# last update: 2018-04-23
# license: GNU Affero General Public License Version 3 (GNU AGPL v3)
# purpose: define parameters for tomo-seq shiny app

Expand All @@ -30,6 +30,7 @@
# change log (reverse chronological) #
######################################

# 2018-04-23: added 3D model fixed expression range plot option
# 2018-04-16: renamed y-axis limits inputs to expression range inputs
# 2018-04-13: added 3D model gene name input default parameter
# added 3D model gene name input panel label parameter
Expand Down Expand Up @@ -487,6 +488,9 @@ if(!exists("params"))
model3d.tab.title = "3D model",
gene3d.input.label = "Gene/miRNA name",
gene3d.input.default = "rpl-17",
plot.options3d =
c(`manually set expression range limis` = "set.exprlim"),
plot.options3d.input.default = c(),


##############
Expand Down
14 changes: 12 additions & 2 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# file: server.R
# author(s): Marcel Schilling <marcel.schilling@mdc-berlin.de>
# created: 2017-02-21
# last update: 2018-04-16
# last update: 2018-04-23
# license: GNU Affero General Public License Version 3 (GNU AGPL v3)
# purpose: define back end for tomo-seq shiny app

Expand All @@ -30,6 +30,7 @@
# change log (reverse chronological) #
######################################

# 2018-04-23: added 3D expression range inputs
# 2018-04-16: renamed y-axis limits inputs to expression range inputs
# 2018-04-13: added 3D model gene name default
# replaced user specified sample shifts by defaults
Expand Down Expand Up @@ -155,6 +156,13 @@ function(input, output, session){
renderUI(
generate.gene.type.input(params$sample.description.input.default,
input$genotype))
output$manual.exprmin3d.input <-
renderUI(generate.manual.exprmin.input(input$plot.options3d,
id = "manual.exprmin3d"))
output$manual.exprmax3d.input <-
renderUI(generate.manual.exprmax.input(input$plot.options3d,
exprmin = input$manual.exprmin3d,
id = "manual.exprmax3d"))

# assign gene list filtered gene profiles
gene.profiles.filtered.gene.list<-
Expand Down Expand Up @@ -293,7 +301,9 @@ function(input, output, session){
filter(gene.name == input$gene3d,
genotype == input$genotype3d) %>%
fit.cpm(model.length = max(input.data$gonad.model$outline$dp),
smoothing.span = input$span3d)))
smoothing.span = input$span3d),
plot.options = input$plot.options3d,
manual.exprlim = c(input$manual.exprmin3d, input$manual.exprmax3d)))

# assign gene annotation
gene.annotation<-
Expand Down
9 changes: 8 additions & 1 deletion ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# file: ui.R
# author(s): Marcel Schilling <marcel.schilling@mdc-berlin.de>
# created: 2017-02-21
# last update: 2018-04-16
# last update: 2018-04-23
# license: GNU Affero General Public License Version 3 (GNU AGPL v3)
# purpose: define front end for tomo-seq shiny app

Expand All @@ -30,6 +30,7 @@
# change log (reverse chronological) #
######################################

# 2018-04-23: added 3D model plot options input panel & expression range inputs
# 2018-04-16: renamed y-axis limits inputs to expression range inputs
# 2018-04-13: relabeled 3D model gene input panel
# removed sample shift input panel
Expand Down Expand Up @@ -483,6 +484,12 @@ fluidPage(
selectizeInput(inputId = "gene3d",
label = h3(params$gene3d.input.label),
choices = NULL),
checkboxGroupInput(inputId = "plot.options3d",
label = h3(params$plot.options.input.label),
choices = params$plot.options3d,
selected = params$plot.options3d.input.default),
uiOutput(outputId = "manual.exprmin3d.input"),
uiOutput(outputId = "manual.exprmax3d.input"),
numericInput(inputId = "span3d",
label = h3(params$smoothing.span.input.label),
min = params$smoothing.span.input.min,
Expand Down

0 comments on commit b268c9b

Please sign in to comment.