Commit 976dbd42 authored by domingue's avatar domingue
Browse files

Bug fix: random selection of genes if list is too large

- `cp_test` was randomly selecting 1500 genes if the input was larger than this number
- this lead to irreproducibility
- fix was to remove this line, and add the fixed function to the script, replacing the sourced code

Fixes #98
parent b431e9b4
......@@ -34,6 +34,36 @@ devtools::source_url("https://git.mpi-cbg.de/bioinfo/ngs_tools/raw/v6/common/cp_
devtools::source_url("https://git.mpi-cbg.de/bioinfo/ngs_tools/raw/v6/dge_workflow/diffex_commons.R")
## Replace source function which randomly selects genes
## This is a temporary solution until we use corescf
## see https://git.mpi-cbg.de/bioinfo/ngs_tools/-/issues/98
cp_test = function(geneIds, annoDb, cp_species, q_cutoff=0.05){
## disable gene symbols output for yeast because it's not supported by undlying annotation db
## see also https://github.com/GuangchuangYu/clusterProfiler/issues/91
readable=cp_species!="yeast"
echo("testing", length(geneIds), " genes for enrichment")
keggResults <- clusterProfiler::enrichKEGG(gene = geneIds, organism = cp_species, keyType="ncbi-geneid", qvalueCutoff = q_cutoff) %>% as.data.frame()
reactomeResults <- ReactomePA::enrichPathway(gene = geneIds, organism = cp_species, qvalueCutoff = q_cutoff, readable = readable) %>% as.data.frame()
goResultsCC <- clusterProfiler::enrichGO(gene = geneIds, OrgDb = annoDb, qvalueCutoff = q_cutoff, ont = "CC", readable = readable) %>% as.data.frame()
goResultsMF <- clusterProfiler::enrichGO(gene = geneIds, OrgDb = annoDb, qvalueCutoff = q_cutoff, ont = "MF", readable = readable) %>% as.data.frame()
goResultsBP <- clusterProfiler::enrichGO(gene = geneIds, OrgDb = annoDb, qvalueCutoff = q_cutoff, ont = "BP", readable = readable) %>% as.data.frame()
#cp-bug: if no pathways are enriched odd strucuture is retured ##todo file issue
if(!("data.frame" %in% class(keggResults))) keggResults <- filter(goResultsBP, Description="foobar")
enrResults <- bind_rows(
mutate(keggResults, ontology="kegg"),
mutate(reactomeResults, ontology="reactome"),
mutate(goResultsBP, ontology="go_bp"),
mutate(goResultsMF, ontology="go_mf"),
mutate(goResultsCC, ontology="go_cc")
)
enrResults
}
# should be no longer needed
# devtools::source_url("https://git.mpi-cbg.de/bioinfo/datautils/raw/v1.44/R/bio/diffex_commons.R")
# devtools::source_url("https://www.dropbox.com/s/vkmm66n11qyunma/diffex_commons.R?dl=1")
......
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