Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bioinfo
ngs_tools
Commits
f77c2280
Commit
f77c2280
authored
Apr 28, 2017
by
Holger Brandl
Browse files
removed plyr dependency
parent
e759b13d
Changes
1
Hide whitespace changes
Inline
Side-by-side
common/cp_enrichment.R
View file @
f77c2280
...
...
@@ -20,7 +20,8 @@ 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.39/R/core_commons.R"
)
coreCommons
=
"https://raw.githubusercontent.com/holgerbrandl/datautils/v1.39/R/core_commons.R"
devtools
::
source_url
(
coreCommons
)
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"
)
...
...
@@ -28,8 +29,6 @@ devtools::source_url("https://raw.githubusercontent.com/holgerbrandl/datautils/v
load_pack
(
knitr
)
load_pack
(
DT
)
#load_pack(clusterProfiler)
#devtools::session_info() # nice!
## to fix child support issue with knitr, see also
...
...
@@ -307,8 +306,12 @@ walk(term_barplot_files$file, function(pngFile){ cat(paste0("<img src='", pngFil
#+ eval=(!is.null(opts$overlay_expr_data) & (nrow(enrResults %>% filter(ontology=="kegg")) >0))
## todo why is tidyr not processing an empty dataframe
keggPathways
<-
enrResults
%>%
filter
(
ontology
==
"kegg"
)
%$%
ac
(
ID
)
%>%
unique
()
# %>% head(3) ## todo remove debug head
keggPathways
=
enrResults
%>%
filter
(
ontology
==
"kegg"
)
%$%
ac
(
ID
)
%>%
unique
()
# %>% head(3) ## todo remove debug head
## remove mmu04723 if present (see bug report https://support.bioconductor.org/p/95354/)
# keggPathways = c("mmu04660", "mmu03060", "mmu04110", "mmu04260", "mmu04723", "mmu05322", "mmu04114")
keggPathways
%<>%
purrr
::
discard
(
~
.
==
"mmu04723"
)
## overloaded by scales packages
## #+ results='asis', echo=FALSE
if
(
!
exists
(
"keggPathways"
)
||
length
(
keggPathways
)
==
0
){
...
...
@@ -340,7 +343,6 @@ keggOrCode <- guess_pathview_species(geneLists$ensembl_gene_id)
#sliceData <- overlayData %>% column2rownames("ensembl_gene_id")
## sort slices in natural order
rify_names
<-
function
(
df
){
names
(
df
)
<-
names
(
df
)
%>%
str_replace_all
(
" "
,
"_"
);
df
}
overlayData
%<>%
select_
(
.
,
.dots
=
naturalsort
(
ac
(
names
(
.
))))
sliceData
<-
overlayData
%>%
column2rownames
(
"ensembl_gene_id"
)
...
...
@@ -363,26 +365,21 @@ dir.create(pwPlotDir)
# inner_join( sliceData %>% add_rownames("ensembl_gene_id") )
# install.packages("session")
# session::save.session(".
pview_
debug.dat");
# session::restore.session(".
pview_
debug.dat");
# session::save.session(".
cp_enrichment.
debug.dat");
# session::restore.session(".
cp_enrichment.
debug.dat");
## from http://stackoverflow.com/questions/7505547/detach-all-packages-while-working-in-r
unload_packages
()
devtools
::
source_url
(
"https://raw.githubusercontent.com/holgerbrandl/datautils/v1.26/R/core_commons.R"
)
#load_pack(plyr)
#load_pack(dplyr)
#load_pack(dplyr)
#load_pack(stringr)
devtools
::
source_url
(
coreCommons
)
load_pack
(
pathview
)
load_pack
(
png
)
plot_pathway
<-
function
(
pathwayID
,
sliceData
){
# pathwayID="mmu04015"; sliceData <- sliceData
# pathwayID="mmu05216"; sliceData <- sliceData
# pathwayID="mmu04723"; sliceData <- sliceData
# browser()
# echo("processing pathway", pathwayID)
pv.out
<-
pathview
(
...
...
@@ -422,12 +419,15 @@ plot_pathway <- function(pathwayID, sliceData){
#keggPathways <- c("mmu00830")
capture.output
#+ echo=FALSE, warning=FALSE
pathwayPlots
<-
keggPathways
%>%
# head(3) %>%
llply
(
function
(
pathwayID
){
plot_pathway
(
pathwayID
,
sliceData
)
})
# head(3) %>%
map
(
function
(
pathwayID
){
# echo("processing pathway", pathwayID)
plot_pathway
(
pathwayID
,
sliceData
)
})
#save(pathwayPlots, file=".pathwayPlots.RData")
...
...
@@ -441,10 +441,10 @@ pathwayPlots <- pathwayPlots[lapply(pathwayPlots, is.character) == 0]
## make sure that all files exist
stopifnot
(
llply
(
pathwayPlots
,
function
(
x
)
file.exists
(
x
$
plotfile
))
%>%
unlist
%>%
all
)
stopifnot
(
map_lgl
(
pathwayPlots
,
~
file.exists
(
.
$
plotfile
))
%>%
all
)
.
instpack
(
"biomaRt"
)
inst
all_
pack
age
(
"biomaRt"
)
## prepare tooltips with expression scores
ens2entrez
<-
quote
({
...
...
@@ -543,4 +543,9 @@ pathwayPlots %>% plyr::l_ply(createImgMap)
#' ## Notes
#' Other interesting tools to perform enrichment testing
#' * [piano](http://www.bioconductor.org/packages/release/bioc/html/piano.html)
\ No newline at end of file
#' * [piano](http://www.bioconductor.org/packages/release/bioc/html/piano.html)
#' System info:
#+ results="asis"
devtools
::
session_info
()
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment