Commit e759b13d authored by Holger Brandl's avatar Holger Brandl
Browse files

more consistent slice tooltip order

parent f8d4fbf4
......@@ -20,10 +20,10 @@ Options:
opts <- docopt(doc, commandArgs(TRUE)) ## does not work when spining
# opts <- docopt(doc, "--overlay_expr_data ../plot_score_matrix.txt ../degs_by_contrast.txt contrast" )
devtools::source_url("https://raw.githubusercontent.com/holgerbrandl/datautils/v1.38/R/core_commons.R")
devtools::source_url("https://raw.githubusercontent.com/holgerbrandl/datautils/v1.38/R/ggplot_commons.R")
devtools::source_url("https://raw.githubusercontent.com/holgerbrandl/datautils/v1.38/R/bio/cp_utils.R")
devtools::source_url("https://raw.githubusercontent.com/holgerbrandl/datautils/v1.38/R/bio/diffex_commons.R")
devtools::source_url("https://raw.githubusercontent.com/holgerbrandl/datautils/v1.39/R/core_commons.R")
devtools::source_url("https://raw.githubusercontent.com/holgerbrandl/datautils/v1.39/R/ggplot_commons.R")
devtools::source_url("https://raw.githubusercontent.com/holgerbrandl/datautils/v1.39/R/bio/cp_utils.R")
devtools::source_url("https://raw.githubusercontent.com/holgerbrandl/datautils/v1.39/R/bio/diffex_commons.R")
load_pack(knitr)
load_pack(DT)
......@@ -57,14 +57,7 @@ if(!is.null(opts$overlay_expr_data)){
resultsBaseName <- if(str_length(opts$project)>0) paste0(opts$project, ".") else basename(opts$gene_lists_tsv) %>% trim_ext("txt") #%>% paste0(".")
#resultsBaseName=basename(opts$gene_lists_tsv) %>% trim_ext("txt") #%>% paste0(".")
## TODO expose as argument
#pCutoff <- 0.05
#qCutoff <- 0.01
qCutoff <- as.numeric(opts$qcutoff)
#reload_dplyr()
q_cutoff <- as.numeric(opts$qcutoff)
########################################################################################################################
#' ## Enrichment Analysis
......@@ -85,7 +78,7 @@ geneLists %>% inner_join(listLabels) %>%
ylab("")
cpSpecies <- guess_cp_species(geneLists$ensembl_gene_id)
cp_species <- guess_cp_species(geneLists$ensembl_gene_id)
annoDb <- guess_anno_db(geneLists$ensembl_gene_id) # e.g. "org.Hs.eg.db"
## supported ids
......@@ -130,7 +123,7 @@ glMapped %<>% filter(!is.na(entrez_gene_id))
## prety slow
## user purrr::map here
enrResults <- quote(glMapped %>% do(cp_test(.$entrez_gene_id, annoDb, cpSpecies, q_cutoff=qCutoff))) %>%
enrResults <- quote(glMapped %>% do(cp_test(.$entrez_gene_id, annoDb, cp_species, q_cutoff=q_cutoff))) %>%
cache_it(paste0("enrdata_", digest(glMapped)))
## run the actual enrichment test for all clusters and all ontologies
......@@ -348,7 +341,8 @@ keggOrCode <- guess_pathview_species(geneLists$ensembl_gene_id)
## sort slices in natural order
rify_names <- function(df){ names(df) <- names(df) %>% str_replace_all(" ", "_"); df}
sliceData <- overlayData %>% rify_names() %>% select_(., .dots=naturalsort(ac(names(.)))) %>% column2rownames("ensembl_gene_id")
overlayData %<>% select_(., .dots=naturalsort(ac(names(.))))
sliceData <- overlayData %>% column2rownames("ensembl_gene_id")
#sliceData <- sliceData[,1:5]
......@@ -466,11 +460,11 @@ ens2entrez <- quote({
toolTipData <- overlayData %>% left_join(ens2entrez)
makeTooltip <- function(entrez_id){
toolTipData %>% filter(entrezgene==entrez_id) %>% dplyr::select(-entrezgene) %>% gather() %$% paste(key, value, sep=": ") %>% paste(collapse="\n") #%>% cat
toolTipData %>%
filter(entrezgene == entrez_id) %>%
dplyr::select(-entrezgene, -ensembl_gene_id) %>%
gather() %$% paste(key, value, sep = ": ") %>% paste(collapse = "\n") #%>% cat
}
#entrez_id=14679
#entrez_id=34234234234234
#makeTooltip("14679")
......
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