Skip to content
Snippets Groups Projects
Commit 49891eaf authored by Holger Brandl's avatar Holger Brandl
Browse files

use abs.max for gene aggregation

parent b31b589b
No related branches found
No related tags found
No related merge requests found
......@@ -20,14 +20,14 @@ 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.22/R/core_commons.R")
devtools::source_url("https://raw.githubusercontent.com/holgerbrandl/datautils/v1.22/R/ggplot_commons.R")
devtools::source_url("https://raw.githubusercontent.com/holgerbrandl/datautils/v1.22/R/bio/diffex_commons.R")
devtools::source_url("https://raw.githubusercontent.com/holgerbrandl/datautils/v1.25/R/core_commons.R")
devtools::source_url("https://raw.githubusercontent.com/holgerbrandl/datautils/v1.25/R/ggplot_commons.R")
devtools::source_url("https://raw.githubusercontent.com/holgerbrandl/datautils/v1.25/R/bio/diffex_commons.R")
require_auto(knitr)
require_auto(DT)
loadpack(knitr)
loadpack(DT)
require_auto(clusterProfiler)
loadpack(clusterProfiler)
#devtools::session_info() # nice!
......@@ -370,14 +370,15 @@ l_ply(term_barplot_files$file, function(pngFile){ cat(paste0("<img src='", pngFi
## todo why is tidyr not processing an empty dataframe
keggPathways <- enrResults %>% filter(ontology=="kegg") %$% ac(ID) %>% unique() # %>% head(3) ## todo remove debug head
##+ results='asis'
#if(!exists("keggPathways") | nrow(keggPathways)==0){
# cat("No enriched pathways found")
#}
require_auto(pathview)
require_auto(png)
require_auto(naturalsort)
loadpack(pathview)
loadpack(png)
loadpack(naturalsort)
# keggPathways <- keggPathways[1]
......@@ -406,11 +407,22 @@ pwPlotDir <-".pathways"
dir.create(pwPlotDir)
#Toxoplasmose debugging of 11796
#c(11796,11797,11798) %>%
# clusterProfiler::bitr(fromType="ENTREZID", toType="ENSEMBL", annoDb="org.Mm.eg.db") %>%
# set_names("entrez_gene_id", "ensembl_gene_id" ) %>%
# inner_join( sliceData %>% add_rownames("ensembl_gene_id") )
# session::save.session(".pview_debug.dat");
# session::restore.session(".pview_debug.dat");
plot_pathway <- function(pathwayID, sliceData){
# pathwayID="mmu04015"; sliceData <- sliceData
# pathwayID="mmu05145"; sliceData <- sliceData
# browser()
# echo("processing pathway", pathwayID)
pv.out <- pathview(
pv.out <- pathview(
# gene.data = sliceData %>% add_rownames("ensembl_gene_id") %>% tbl_df %>% filter(ensembl_gene_id %in% c("ENSMUSG00000073901", "ENSMUSG00000032000", "ENSMUSG00000021025")) %>% column2rownames("ensembl_gene_id"),
gene.data = sliceData,
pathway.id = pathwayID,
species = keggOrCode,
......@@ -418,7 +430,7 @@ plot_pathway <- function(pathwayID, sliceData){
# out.suffix = pathwayID,
multi.state = ncol(sliceData)>1,
# kegg.native=F,
# node.sum = "mean", # the method name to calculate node summary given that multiple genes or compounds are mapped to it
node.sum = "max.abs", # the method name to calculate node summary given that multiple genes or compounds are mapped to it
limit = list(gene = c(-4,4)),
gene.idtype="ensembl"
)
......@@ -434,10 +446,7 @@ plot_pathway <- function(pathwayID, sliceData){
system(paste("rm", paste0(pathwayID, ".xml"), paste0(pathwayID, ".png")))
## interactive plotting
# ima <- readPNG(outfile)
# plot.new()
# lim <- par()
# rasterImage(ima, lim$usr[1], lim$usr[3], lim$usr[2], lim$usr[4])
# ima <- readPNG(figuresPlotFile); plot.new(); lim <- par(); rasterImage(ima, lim$usr[1], lim$usr[3], lim$usr[2], lim$usr[4]);
pv.out$plotfile=figuresPlotFile
pv.out$pathway_id=pathwayID
......@@ -507,13 +516,19 @@ makeTooltip <- function(entrez_id){
#</style>
#")
pathwayName <- function(pathwayID, enrResults) enrResults %>% filter(ontology=="kegg") %>% filter(ID==pathwayID) %$% Description
#
## todo add tooltips with additinal info
## http://stackoverflow.com/questions/5478940/how-to-create-a-html-tooltip-on-top-of-image-map
## extended version with clickable links
createImgMap <- function(plotData){
#browser()
warning("compiling overlay toolips...")
# cat(paste0("pathway:", plotData$pathway_id) # todo rather show the pathway name here and create anhor list on top of section
# pathwayName("mmu05145", enrResults)
cat(paste0("<h3>",pathwayName(plotData$pathway_id, enrResults), "</h3>"))
#pngFile="mmu04015.pathview.png"
#plotData <- pathwayPlots[[1]]
#plotData <- unlist(pathwayPlots)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment