Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
datautils
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bioinfo
datautils
Commits
cf633248
Commit
cf633248
authored
Aug 26, 2016
by
Holger Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use load_pack more consistently; started cp-utils
parent
aa5ad2a4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
125 additions
and
24 deletions
+125
-24
R/bio/bioinfo_commons.R
R/bio/bioinfo_commons.R
+1
-1
R/bio/cp_utils.R
R/bio/cp_utils.R
+101
-0
R/core_commons.R
R/core_commons.R
+21
-21
R/ggplot/ggheatmap.R
R/ggplot/ggheatmap.R
+2
-2
No files found.
R/bio/bioinfo_commons.R
View file @
cf633248
...
...
@@ -2,7 +2,7 @@
#library(Biostrings, quietly=T)
#require_auto(BiocGenerics x
#loadpack(Biostrings)
#load
_
pack(Biostrings)
## install Biostrings if not yet there
install_package
(
"Biostrings"
)
...
...
R/bio/cp_utils.R
0 → 100644
View file @
cf633248
install_package
(
clusterProfiler
)
## 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
))
}
}
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")
#biocLite("org.Hs.eg.db")
#biocLite("org.Dr.eg.db")
#biocLite("org.Dm.eg.db")
#biocLite("KEGG.db")
load_pack
(
ReactomePA
)
cp_test
<-
function
(
geneIds
){
# DEBUG geneIds <- glMapped %>% filter(cluster %in% c("cluster_9")) %$% entrez_gene_id %>% as.integer
# DEBUG geneIds <- head(glMapped,30)$entrez_gene_id
# geneIds=.$entrez_gene_id
if
(
length
(
geneIds
)
>
1500
){
geneIds
<-
sample
(
geneIds
)
%>%
head
(
1500
)
}
echo
(
"testing"
,
length
(
geneIds
),
" genes for enrichment"
)
# PANTHER10_ontology <- read.delim("http://data.pantherdb.org/PANTHER10.0/ontology/Protein_Class_7.0")
# browser()
# pantherResults <- enricher(gene = geneIds, organism = cpSpecies, qvalueCutoff = qCutoff, readable = TRUE, TERM2GENE = PANTHER10_ontology) %>% summary()
keggResults
<-
clusterProfiler
::
enrichKEGG
(
gene
=
geneIds
,
organism
=
cpSpecies
,
qvalueCutoff
=
qCutoff
,
use_internal_data
=
T
)
%>%
summary
()
reactomeResults
<-
enrichPathway
(
gene
=
geneIds
,
organism
=
cpSpecies
,
qvalueCutoff
=
qCutoff
)
%>%
summary
()
goResultsCC
<-
clusterProfiler
::
enrichGO
(
gene
=
geneIds
,
OrgDb
=
annoDb
,
qvalueCutoff
=
qCutoff
,
ont
=
"CC"
)
%>%
summary
()
goResultsMF
<-
clusterProfiler
::
enrichGO
(
gene
=
geneIds
,
OrgDb
=
annoDb
,
qvalueCutoff
=
qCutoff
,
ont
=
"MF"
)
%>%
summary
()
goResultsBP
<-
clusterProfiler
::
enrichGO
(
gene
=
geneIds
,
OrgDb
=
annoDb
,
qvalueCutoff
=
qCutoff
,
ont
=
"BP"
)
%>%
summary
()
#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
# echo("numResults", nrow(enrResults))
}
## example
if
(
F
){
someGenes
=
c
(
""
)
## todo continue
cpSpecies
<-
guess_cp_species
(
someGenes
)
annoDb
<-
guess_anno_db
(
someGenes
)
# e.g. "org.Hs.eg.db"
enrResults
<-
cp_test
(
someGenes
)
## or for grouped data
#enrResults <- quote(glMapped %>% do(cp_test(.$entrez_gene_id))) %>% cache_it(paste0("enrdata_", digest(glMapped)))
## test custom ontology
#enrichrFile_TFchip = "/projects/bioinfo/holger/data/enrichr_datasets/ENCODE_TF_ChIP-seq_2015.txt"
#tfChipOnt <- convert_enrichr_cp(enrichrFile_TFchip)
}
\ No newline at end of file
R/core_commons.R
View file @
cf633248
...
...
@@ -31,7 +31,7 @@ options(gsubfn.engine = "R")
## automatic package installation
require_auto
<-
function
(
x
){
warning
(
"require_auto is deprecated, use loadpack() instead"
)
warning
(
"require_auto is deprecated, use load
_
pack() instead"
)
x
<-
as.character
(
substitute
(
x
))
...
...
@@ -75,7 +75,7 @@ load_pack <- function(x, warn_conflicts=T){
install_package
(
x
)
## load it using a library function so that loadpack errors if package is still not ins
## load it using a library function so that load
_
pack errors if package is still not ins
eval
(
parse
(
text
=
paste
(
"library("
,
x
,
", quietly=T, warn.conflicts="
,
warn_conflicts
,
")"
,
sep
=
""
)))
}
...
...
@@ -86,7 +86,7 @@ loadpack <- function(x, warn_conflicts=T){
install_package
(
x
)
## load it using a library function so that loadpack errors if package is still not ins
## load it using a library function so that load
_
pack errors if package is still not ins
eval
(
parse
(
text
=
paste
(
"library("
,
x
,
", quietly=T, warn.conflicts="
,
warn_conflicts
,
")"
,
sep
=
""
)))
}
...
...
@@ -100,34 +100,34 @@ check_version = function(pkg_name, min_version) {
########################################################################################################################
## load core packages
loadpack
(
plyr
)
loadpack
(
stringr
)
loadpack
(
reshape2
)
#loadpack(reshape2, quietly=T, warn_conflicts=F)
load
_
pack
(
plyr
)
load
_
pack
(
stringr
)
load
_
pack
(
reshape2
)
#load
_
pack(reshape2, quietly=T, warn_conflicts=F)
## load on purpose after plyr
loadpack
(
dplyr
,
warn_conflicts
=
F
)
loadpack
(
magrittr
,
warn_conflicts
=
F
)
loadpack
(
tidyr
,
warn_conflicts
=
F
)
load
_
pack
(
dplyr
,
warn_conflicts
=
F
)
load
_
pack
(
magrittr
,
warn_conflicts
=
F
)
load
_
pack
(
tidyr
,
warn_conflicts
=
F
)
## needed for caching
loadpack
(
digest
)
loadpack
(
readr
)
suppressWarnings
(
loadpack
(
readxl
))
## supress differring build number
#loadpack(readxl) ## supress differring build number
load
_
pack
(
digest
)
load
_
pack
(
readr
)
suppressWarnings
(
load
_
pack
(
readxl
))
## supress differring build number
#load
_
pack(readxl) ## supress differring build number
## common plotting requirements since they are omnipresent
loadpack
(
ggplot2
)
loadpack
(
scales
,
warn_conflicts
=
F
)
loadpack
(
grid
)
load
_
pack
(
ggplot2
)
load
_
pack
(
scales
,
warn_conflicts
=
F
)
load
_
pack
(
grid
)
## for table exploration without using Rstudio
loadpack
(
DT
)
load
_
pack
(
DT
)
## moved into datatable_commons because replaced almost everywhere with dplyr
#loadpack(data.table)
#load
_
pack(data.table)
...
...
@@ -461,6 +461,6 @@ assert <- function (expr, error) {
}
### table rendering
table_browser
<-
function
(
df
){
datatable
(
df
,
filter
=
"bottom"
,
extensions
=
'Buttons'
,
options
=
list
(
dom
=
'Bfrtip'
,
buttons
=
c
(
'copy'
,
'csv'
,
'excel'
)))
table_browser
<-
function
(
df
,
...
){
datatable
(
df
,
filter
=
"bottom"
,
extensions
=
'Buttons'
,
options
=
list
(
dom
=
'Bfrtip'
,
buttons
=
c
(
'copy'
,
'csv'
,
'excel'
))
,
...
)
}
R/ggplot/ggheatmap.R
View file @
cf633248
...
...
@@ -2,8 +2,8 @@
#library(ggplot2)
#library(reshape2)
require_auto
(
ggdendro
)
require_auto
(
grid
)
load_pack
(
ggdendro
)
load_pack
(
grid
)
## Adopted from http://cwcode.wordpress.com/2013/01/30/ggheatmap-version-2/
...
...
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