Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
ngs_tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bioinfo
ngs_tools
Commits
3f3d952d
Commit
3f3d952d
authored
9 years ago
by
Holger Brandl
Browse files
Options
Downloads
Patches
Plain Diff
cont. cp enrichment tool
parent
bf6699e5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/cp_enrichment.R
+69
-6
69 additions, 6 deletions
common/cp_enrichment.R
with
69 additions
and
6 deletions
common/cp_enrichment.R
+
69
−
6
View file @
3f3d952d
...
@@ -13,14 +13,15 @@ Options:
...
@@ -13,14 +13,15 @@ Options:
'
'
opts
<-
docopt
(
doc
,
commandArgs
(
TRUE
))
## does not work when spining
opts
<-
docopt
(
doc
,
commandArgs
(
TRUE
))
## does not work when spining
#opts <- docopt(doc, "--overlay_expr_data ../ctrl_fc_expr_filtered.txt geneClusters.RData" )
# opts <- docopt(doc, "--overlay_expr_data ctrl_fc_expr_filtered.txt geneClusters.RData" )
#opts <- docopt(doc, "--overlay_expr_data ../ctrl_fc_expr_filtered.txt grpdGoiClusters.RData" )
devtools
::
source_url
(
"https://raw.githubusercontent.com/holgerbrandl/datautils/v1.1
2
/R/core_commons.R"
)
devtools
::
source_url
(
"https://raw.githubusercontent.com/holgerbrandl/datautils/v1.1
3
/R/core_commons.R"
)
devtools
::
source_url
(
"https://raw.githubusercontent.com/holgerbrandl/datautils/v1.1
2
/R/ggplot_commons.R"
)
devtools
::
source_url
(
"https://raw.githubusercontent.com/holgerbrandl/datautils/v1.1
3
/R/ggplot_commons.R"
)
devtools
::
source_url
(
"https://raw.githubusercontent.com/holgerbrandl/datautils/v1.1
2
/R/bio/diffex_commons.R"
)
devtools
::
source_url
(
"https://raw.githubusercontent.com/holgerbrandl/datautils/v1.1
3
/R/bio/diffex_commons.R"
)
require.auto
(
knitr
)
require.auto
(
knitr
)
require.auto
(
clusterProfiler
)
require.auto
(
ReactomePA
)
## to fix child support issue with knitr, see also
## to fix child support issue with knitr, see also
## http://stackoverflow.com/questions/20030523/knitr-nested-child-documents
## http://stackoverflow.com/questions/20030523/knitr-nested-child-documents
...
@@ -38,6 +39,8 @@ if(!is.null(opts$overlay_expr_data)){
...
@@ -38,6 +39,8 @@ if(!is.null(opts$overlay_expr_data)){
overlayData
<-
read.delim
(
opts
$
overlay_expr_data
)
overlayData
<-
read.delim
(
opts
$
overlay_expr_data
)
}
}
## TODO expose options to run gesa instead (by assuming that gene lists are sorted)
## see http://www.bioconductor.org/packages/release/bioc/vignettes/clusterProfiler/inst/doc/clusterProfiler.pdf for details
resultsBaseName
=
basename
(
opts
$
grouped_gene_lists_rdata
)
%>%
trim_ext
(
".RData"
)
%>%
paste0
(
"."
)
resultsBaseName
=
basename
(
opts
$
grouped_gene_lists_rdata
)
%>%
trim_ext
(
".RData"
)
%>%
paste0
(
"."
)
...
@@ -57,8 +60,68 @@ geneLists %>% inner_join(listLabels) %>%
...
@@ -57,8 +60,68 @@ geneLists %>% inner_join(listLabels) %>%
ylab
(
""
)
ylab
(
""
)
#enrResults <- geneLists %>% do(davidAnnotationChart(.$ensembl_gene_id))
guess_cp_species
<-
function
(
ensIds
){
an_id
<-
ensIds
[
1
]
if
(
str_detect
(
an_id
,
"ENSG"
)){
return
(
"human"
)
}
else
if
(
str_detect
(
an_id
,
"ENSMUSG"
)){
return
(
"mouse"
)
}
else
if
(
str_detect
(
an_id
,
"ENSDARG"
)){
return
(
"zebrafish"
)
}
else
if
(
str_detect
(
an_id
,
"FBgn"
)){
return
(
"fly"
)
}
else
{
stop
(
paste
(
"could not clusterProfiler species name from "
,
an_id
))
}
}
guess_anno_db
<-
function
(
ensIds
){
an_id
<-
ensIds
[
1
]
if
(
str_detect
(
an_id
,
"ENSG"
)){
return
(
"org.Hs.eg.db"
)
}
else
if
(
str_detect
(
an_id
,
"ENSMUSG"
)){
return
(
"org.Mm.eg.db"
)
}
else
if
(
str_detect
(
an_id
,
"ENSDARG"
)){
return
(
"org.Dr.eg.db"
)
}
else
if
(
str_detect
(
an_id
,
"FBgn"
)){
return
(
"org.Dm.eg.db"
)
}
else
{
stop
(
paste
(
"could not anno db mart from "
,
an_id
))
}
}
#source("https://bioconductor.org/biocLite.R")
#biocLite("org.Mm.eg.db")
#biocLite("org.Hm.eg.db")
#biocLite("org.Dr.eg.db")
#biocLite("org.Dm.eg.db")
cpSpecies
<-
guess_cp_species
(
geneLists
$
ensembl_gene_id
)
annoDb
<-
guess_anno_db
(
geneLists
$
ensembl_gene_id
)
# e.g. "org.Hs.eg.db"
## supported ids
#idType("org.Hs.eg.db")
## convert to entrez gene ids
geneLists
%<>%
mutate
(
entrez_gene_id
=
bitr
(
x
,
fromType
=
"ENSEMBL"
,
toType
=
"ENTREZID"
,
annoDb
=
annoDb
))
## TODO expose as argument
pCutoff
<-
0.05
geneIds
<-
geneLists
%>%
filter
(
cluster
%in%
c
(
"cluster_2"
))
%$%
geneLists
enrichKEGG
(
gene
=
geneIds
,
organism
=
cpSpecies
,
pvalueCutoff
=
pCutoff
,
readable
=
TRUE
)
enrichPathway
(
gene
=
geneIds
,
organism
=
cpSpecies
,
pvalueCutoff
=
pCutoff
,
readable
=
TRUE
)
enrichGO
(
gene
=
gene
,
universe
=
names
(
geneList
),
organism
=
"human"
,
ont
=
"CC"
,
pAdjustMethod
=
"BH"
,
pvalueCutoff
=
0.01
,
qvalueCutoff
=
0.05
,
readable
=
TRUE
)
enrResults
<-
quote
(
geneLists
%>%
do
(
davidAnnotationChart
(
.
$
ensembl_gene_id
)))
%>%
enrResults
<-
quote
(
geneLists
%>%
do
(
davidAnnotationChart
(
.
$
ensembl_gene_id
)))
%>%
cache_it
(
paste0
(
"enrdata_"
,
digest
(
geneLists
)))
cache_it
(
paste0
(
"enrdata_"
,
digest
(
geneLists
)))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment