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
46d37f8c
Commit
46d37f8c
authored
8 years ago
by
Holger Brandl
Browse files
Options
Downloads
Patches
Plain Diff
moved utility cp functions into commons
parent
bfd2dad5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/gsea_enrichment.R
+9
-46
9 additions, 46 deletions
common/gsea_enrichment.R
with
9 additions
and
46 deletions
common/gsea_enrichment.R
+
9
−
46
View file @
46d37f8c
#!/usr/bin/env Rscript
#+ echo=FALSE, error=F
# cd
suppressMessages
(
require
(
docopt
))
## todo use textual input here for ease of use
doc
<-
'
Perform an enrichment analysis for a set of genes
Usage:gsea_enrichment.R[options] <sorted_gene_lists_tsv>
<group_col>
Usage:gsea_enrichment.R[options] <sorted_gene_lists_tsv>
Options:
--list_id_col Column containing the grouping variable to speparate different lists [default: ]
...
...
@@ -23,10 +20,11 @@ opts <- docopt(doc, commandArgs(TRUE)) ## does not work when spining
devtools
::
source_url
(
"https://raw.githubusercontent.com/holgerbrandl/datautils/v1.27/R/core_commons.R"
)
devtools
::
source_url
(
"https://raw.githubusercontent.com/holgerbrandl/datautils/v1.27/R/ggplot_commons.R"
)
devtools
::
source_url
(
"https://raw.githubusercontent.com/holgerbrandl/datautils/v1.27/R/bio/diffex_commons.R"
)
## todo relase and use proper version here
devtools
::
source_url
(
"https://raw.githubusercontent.com/holgerbrandl/datautils/master/R/bio/diffex_commons.R"
)
loadpack
(
knitr
)
loadpack
(
DT
)
#
loadpack(DT)
#loadpack(clusterProfiler)
...
...
@@ -41,7 +39,8 @@ loadpack(DT)
## load the data
geneLists
<-
read_tsv
(
opts
$
sorted_gene_lists_tsv
)
group_col
=
opts
$
group_col
#group_col=opts$group_col
group_col
=
"contrast"
geneLists
%<>%
group_by_
(
.dots
=
group_col
)
#geneLists %<>% filter(cluster %in% c("cluster_1", "cluster_2"))
...
...
@@ -68,46 +67,10 @@ vec2df(unlist(opts)) %>% filter(!str_detect(name, "^[<-]")) %>% kable()
listLabels
<-
geneLists
%>%
select
(
-
ensembl_gene_id
)
%>%
distinct
listLabels
%<>%
transform
(
list_label
=
do.call
(
paste
,
c
(
listLabels
,
sep
=
"__"
)))
geneLists
%>%
inner_join
(
listLabels
)
%>%
ggplot
(
aes
(
list_label
))
+
geom_bar
()
+
coord_flip
()
+
ggtitle
(
"gene list sizes to be tested for term enrichment"
)
+
ylab
(
""
)
## todo move to diffex commons
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
))
}
}
stopifnot
(
unlen
(
count
(
geneLists
)
$
n
)
==
1
)
# make sure that all input lists have the same length (to avoid that just degs are provided as input
count
(
geneLists
)
%>%
kable
()
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("http://bioconductor.org/biocLite.R")
#biocLite("org.Mm.eg.db")
...
...
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