Commit 1a623b17 authored by Holger Brandl's avatar Holger Brandl

added url parameters for gene_id and gene_name

parent 9e535dfc
......@@ -4,6 +4,8 @@
# https://shiny.rstudio.com/reference/shiny/1.0.5/
# http://rstudio.github.io/DT/
# cd /Volumes/cerebral-organoids/RNA-Seq/data/hsap/dge_analysis; R
args = commandArgs(trailingOnly = TRUE)
# LOAD packages --------------------------------------------------------------------------------------------------------
......@@ -16,9 +18,8 @@ load_pack(shinyjqui)
# GET path--------------------------------------------------------------------------------------------------------------
# Determine data directory from execution context ---------------------------------------------------------------------
#Sys.getenv("DA_BIN_ICH")
# dataPath= args[1] %>% dirname()%>% dirname()%>% dirname()
# https://stackoverflow.com/questions/1815606/rscript-determine-path-of-the-executing-script
......@@ -28,6 +29,9 @@ script.name <- sub(file.arg.name, "", initial.options[grep(file.arg.name, initia
# script.name="/Volumes/cerebral-organoids/RNA-Seq/data/hsap/dge_analysis/expression_explorer.app/Contents/MacOS/expression_explorer"
dataPath= script.name %>% dirname() %>% dirname()%>% dirname() %>% dirname()
# dataPath= getwd()
# FUNCTIONS ------------------------------------------------------------------------------------------------------------
calc_ci = function(df, variable, ci_interval=0.95){
......@@ -39,12 +43,12 @@ calc_ci = function(df, variable, ci_interval=0.95){
# echo(glue::glue("varname is {ci_name}"))
df %>% summarize(
mean=mean(!!variable),
sd=sd(!!variable),
mean = mean(!!variable),
sd = sd(!!variable),
N = n(),
se=sd/sqrt(N),
se = sd/sqrt(N),
!!ci_name := qt(ci_interval/2+0.5, N-1)*se,
!!mean_name :=mean
!!mean_name := mean
) %>% select(-c(mean, sd, N, se, mean))
}
......@@ -53,7 +57,7 @@ calc_ci = function(df, variable, ci_interval=0.95){
# data %>% head()
de_res <- read_tsv(file.path(dataPath, "de_results.txt")) %>%
transmute(external_gene_name, condition_1, condition_2, logfc = c1_over_c2_logfc, pvalue, padj, is_hit, c1_overex)
transmute(external_gene_name, ensembl_gene_id, condition_1, condition_2, logfc = c1_over_c2_logfc, pvalue, padj, is_hit, c1_overex)
de_res[,c(4:6)] <- round(de_res[,c(4:6)], 3)
design <- read_tsv(file.path(dataPath, "basic_design.txt")) %>% select(condition, replicate)
......@@ -96,7 +100,6 @@ app <- shinyApp(
),
fixedRow(
column(4, style = "height:100px",
selectInput(inputId = "gene_name", label = "Gene name", choices = gene_names, multiple = TRUE, selected = first_entry, selectize=TRUE)
),
......@@ -140,6 +143,34 @@ app <- shinyApp(
server <- function(input, output, session) {
observe({
query <- parseQueryString(session$clientData$url_search)
if (!is.null(query[['gene_id']])) {
# http://127.0.0.1:7324/?gene_id=ENSG00000000457
# map ids to symbols if needed
#separate multiple ids
url_provided_ids = str_split(query[['gene_id']], ",") %>% unlist
# browser()
if(any(str_detect(url_provided_ids, "E.*[0-9]{10,}"))){
url_provided_ids = all %>% filter(ensembl_gene_id %in% url_provided_ids) %$% unique(gene_name)
}
## see https://shiny.rstudio.com/reference/shiny/0.14/updateSelectInput.html
updateSelectInput(session, "gene_name", selected=url_provided_ids)
}
if (!is.null(query[['gene_name']])) {
# http://127.0.0.1:7324/?gene_name=TNMD
url_provided_ids = str_split(query[['gene_name']], ",") %>% unlist
# updateTextInput(session, "gene_name", value = url_provided_ids)
updateSelectInput(session, "gene_name", selected=url_provided_ids)
}
})
# prepare output data
table_data <- reactive({
de_res %>% filter(external_gene_name %in% input$gene_name) %>% select(-is_hit, -c1_overex)
......@@ -178,7 +209,7 @@ app <- shinyApp(
plot <- plot + geom_errorbar(aes(ymin=rep_values_mean-rep_values_ci, ymax=rep_values_mean+rep_values_ci), size = 0.2, position=pd)
}
if (is.element("plot_line", input$options) || is.element("plot_ci", input$options)) {
if (is.element("plot_line", input$options) || is.element("plot_ci", input$options)) {
} else {
plot <- plot + stat_summary(fun.y="mean", geom="point", pch = "_", size=8, position = pd)
}
......
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