Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Ontologies - statistics biases tools networks and interpretation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Stefan Bassler
Ontologies - statistics biases tools networks and interpretation
Commits
27b4cae3
Verified
Commit
27b4cae3
authored
4 years ago
by
Renato Alves
Browse files
Options
Downloads
Patches
Plain Diff
Add solution to exercise 3 for day 3
parent
3771ca0f
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
Day_3/Solutions/Exercise_3_Multicluster_R_code_2020.R
+106
-0
106 additions, 0 deletions
Day_3/Solutions/Exercise_3_Multicluster_R_code_2020.R
with
106 additions
and
0 deletions
Day_3/Solutions/Exercise_3_Multicluster_R_code_2020.R
0 → 100644
+
106
−
0
View file @
27b4cae3
# Let's learn how to perform comparative multi cluster analysis
#
# Matt Rogon
# rogon@embl.de
# 10.2020
# ver. 0.5
library
(
dplyr
)
library
(
STRINGdb
)
library
(
reshape2
)
library
(
ReactomePA
)
library
(
clusterProfiler
)
library
(
pathview
)
library
(
DOSE
)
library
(
org.Mm.eg.db
)
setwd
(
"/Users/rogon/Work/01. Teaching/CBNA Courses/2020 CBNA-DeNBI Enrichment course - my materials/Part 2 - R-code session ClusterProfiler, ReactomePA, pathfindR/Exercise 4/"
)
# load complete 5 cluster-dataset
hit_list
<-
read.delim
(
"550prot_clusters.txt"
,
stringsAsFactors
=
FALSE
)
#--------------------------------------------------------------
# let's annotate uniprot to entrez for ClusterProfiler
#------------------------------------------------------------------------------------
# Annotation with bitr in ClusterProfiler for enrichment check
#------------------------------------------------------------------------------------
keytypes
(
org.Mm.eg.db
)
entrez_map
<-
bitr
(
hit_list
$
UniProt
,
fromType
=
"UNIPROT"
,
toType
=
c
(
"ENTREZID"
,
"SYMBOL"
),
OrgDb
=
"org.Mm.eg.db"
,
drop
=
FALSE
)
write.table
(
entrez_map
,
file
=
"output/entrez_map.txt"
,
row.names
=
F
,
quote
=
FALSE
,
sep
=
"\t"
)
#--------------------------------------------------------------
# Enrichment with ClusterProfiler
#--------------------------------------------------------------
# expression values:
#data(geneList)
#de <- names(geneList)[geneList > 1]
# to do enrichment on a 'per cluster' basis I need the cluster column from the data frame: main_string_mapping_select
input_for_enrichment
<-
merge
(
hit_list
,
entrez_map
,
by.x
=
"UniProt"
,
by.y
=
"UNIPROT"
,
all
=
TRUE
)
input_for_enrichment
<-
input_for_enrichment
[
complete.cases
(
input_for_enrichment
),]
# extract entrez id's from the annotation frame 'results' created earlier
# for each cluster separately
#c1 <- subset(input_for_enrichment, cluster==1)
#c1_s <- dplyr::select(c1, ENTREZID)
#c1_s <- unique(c1_s)
#c1_list <- as.list(c1_s$ENTREZID)
#same in 2 lines
c1
<-
dplyr
::
select
(
subset
(
input_for_enrichment
,
cluster
==
1
),
ENTREZID
)
c1_list
<-
as.list
(
c1
$
ENTREZID
)
c2
<-
dplyr
::
select
(
subset
(
input_for_enrichment
,
cluster
==
2
),
ENTREZID
)
c2_list
<-
as.list
(
c2
$
ENTREZID
)
c3
<-
dplyr
::
select
(
subset
(
input_for_enrichment
,
cluster
==
3
),
ENTREZID
)
c3_list
<-
as.list
(
c3
$
ENTREZID
)
c4
<-
dplyr
::
select
(
subset
(
input_for_enrichment
,
cluster
==
4
),
ENTREZID
)
c4_list
<-
as.list
(
c4
$
ENTREZID
)
c5
<-
dplyr
::
select
(
subset
(
input_for_enrichment
,
cluster
==
5
),
ENTREZID
)
c5_list
<-
as.list
(
c5
$
ENTREZID
)
hit_list_Entrez_flat
<-
unlist
(
hit_list_Entrez
)
hit_list_Entrez2_flat
<-
unlist
(
hit_list_Entrez2
)
#---------------------------------------------------------------------------------------
# Individual cluster enrichment
#---------------------------------------------------------------------------------------
go_1
<-
enrichGO
(
c1_list
,
OrgDb
=
"org.Mm.eg.db"
,
ont
=
"BP"
,
universe
=
input_for_enrichment
$
ENTREZID
,
pvalueCutoff
=
0.05
,
pAdjustMethod
=
"BH"
,
qvalueCutoff
=
0.1
,
minGSSize
=
5
)
head
(
as.data.frame
(
go_1
))
#----
# Multi-cluster analysis
#----
input_all
=
list
()
input_all
$
X1
<-
c1_list
input_all
$
X2
<-
c2_list
input_all
$
X3
<-
c3_list
input_all
$
X4
<-
c4_list
input_all
$
X5
<-
c5_list
summary
(
input_all
)
# Gene Ontology comparison
res_go
<-
compareCluster
(
input_all
,
fun
=
"enrichGO"
,
OrgDb
=
"org.Mm.eg.db"
,
pvalueCutoff
=
0.1
)
dotplot
(
res_go
,
title
=
"GO Enrichment Comparison"
)
res_reactome
<-
compareCluster
(
input_all
,
fun
=
"enrichPathway"
,
organism
=
'mouse'
,
pvalueCutoff
=
0.01
,
pAdjustMethod
=
"BH"
,
qvalueCutoff
=
0.1
)
dotplot
(
res_reactome
,
title
=
"Reactome Enrichment Comparison"
)
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