- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVerdaDO_ExampleScript.R
More file actions
Latest commit
163 lines (123 loc) · 5.48 KB
/
Copy pathVerdaDO_ExampleScript.R
File metadata and controls
163 lines (123 loc) · 5.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
library(DOSE)
library(clusterProfiler)
library(ggplot2)
library(tidyverse)
library(readr)
library(ChIPseeker)
library(regioneR)
library(TxDb.Hsapiens.UCSC.hg19.knownGene)
txdb<-TxDb.Hsapiens.UCSC.hg19.knownGene
setwd("/Users/scottt7/Desktop/")
# Load in all the data
Adrenal_clust_cs<- read_tsv("Adrenal_internalClusters_individualHMRs_cellspecific.txt", col_names=F)
colnames(Adrenal_clust_cs)<-c("Chr","Start","End","Length")
Adrenal_clust_cs<-Adrenal_clust_cs %>%
dplyr::select("Chr","Start","End") %>%
mutate("ID"=row_number(), "Strand"=".", "OtherCol"="1")
Bcell_clust_cs<- read_tsv("Bcell_internalClusters_individualHMRs_cellspecific.txt", col_names=F)
colnames(Bcell_clust_cs)<-c("Chr","Start","End","Length")
Bcell_clust_cs<-Bcell_clust_cs %>%
dplyr::select("Chr","Start","End") %>%
mutate("ID"=row_number(), "Strand"=".", "OtherCol"="1")
# Convert them to GRanges
Adrenal_clust_cs_granges<- toGRanges(as.data.frame(Adrenal_clust_cs))
Bcell_clust_cs_granges<- toGRanges(as.data.frame(Bcell_clust_cs))
Adrenal_clust_sh_granges<- toGRanges(as.data.frame(Adrenal_clust_sh))
Bcell_clust_sh_granges<- toGRanges(as.data.frame(Bcell_clust_sh))
# Combine into a list
list_of_regions<-list(Adrenal=Adrenal_clust_cs_granges,
Bcell=Bcell_clust_cs_granges,
Liver=Liver_clust_cs_granges,
fSpinal=fSpinal_clust_cs_granges,
H1ESC=H1ESC_clust_cs_granges,
Rvent=Rvent_clust_cs_granges)
# Apply AnnotatePeak to this list
# GENE ASSIGNMENT
peakAnnoList<- lapply(list_of_regions, annotatePeak, TxDb=txdb,
tssRegion=c(-1000, 2000), verbose=FALSE)
# # Gene segment annotation
# # plotAnnoPie(peakAnno)
# # lapply(peakAnnoList, plotAnnoPie)
# plotAnnoBar(peakAnnoList)
# # Distance to TSs
# lapply(peakAnnoList, plotDistToTSS, title="Distance to Nearest TSS")
# plotDistToTSS(peakAnnoList, title="Distance to Nearest TSS")
############################
# Gene prep
genes= lapply(peakAnnoList, function(i) as.data.frame(i)$geneId)
# Venn Plot of genes
# vennplot(genes_5_noAdr)
# vennplot(genes_clust_sh_5_noAdr)
############### ENRICHMENT ANALYSES
# Don't know if you'll need this following line
names(genes) = sub("_", "\n", names(genes))
compDO<- compareCluster(geneCluster=genes,
fun="enrichDO", #enrichGO #enrichKEGG
pvalueCutoff=0.2,
pAdjustMethod="BH")
dotplot(compDO, showCategory=10, title="DO Enrichment Analysis")
compDO_point1<- compareCluster(geneCluster=genes,
fun="enrichDO",
pvalueCutoff=0.1,
pAdjustMethod="BH")
dotplot(compDO_point1, showCategory=10, title="DO Enrichment Analysis")
###### GO
compGO<- compareCluster(geneCluster=genes,
fun="enrichGO",
OrgDb=org.Hs.eg.db,
ont="BP",
pAdjustMethod="BH",
pvalueCutoff=0.01,
qvalueCutoff=0.05)
dotplot(compGO, showCategory=7, title="GO Enrichment Analysis")
######### KEGG
compKEGG_point1<- compareCluster(geneCluster=genes,
fun="enrichKEGG",
pvalueCutoff=0.1,
pAdjustMethod="BH")
dotplot(compKEGG_point1, showCategory=10, title="KEGG Enrichment Analysis")
compKEGG_point05<- compareCluster(geneCluster=genes,
fun="enrichKEGG",
pvalueCutoff=0.05,
pAdjustMethod="BH")
dotplot(compKEGG_point05, showCategory=10, title="KEGG Enrichment Analysis")
compKEGG_point01<- compareCluster(geneCluster=genes,
fun="enrichKEGG",
pvalueCutoff=0.01,
pAdjustMethod="BH")
dotplot(compKEGG_point01, showCategory=10, title="KEGG Enrichment Analysis")
# Wanted to know if the kidney overlap with Liver
# Was powered by liver-kidney genes identified by the Human Protein Atlas database
# Wanna look at the liver genes
as.data.frame(peakAnnoList$Liver)$geneId
Liver_gene_symbols<- unique(bitr(as.data.frame(peakAnnoList$Liver)$geneId,
fromType="ENTREZID",
toType="SYMBOL",
OrgDb=org.Hs.eg.db))
####### TESTs
# Try out ChipSeeker to annotate the nearest gene
# test_bed <- annotatePeak(Bcell_clust_cs, tssRegion=c(-1000,2000),
# TxDb=txdb, annoDb="org.Hs.eg.db")
# test <- annotatePeak(Bcell_clust_cs_granges, tssRegion=c(-1000,2000),
# TxDb=txdb, annoDb="org.Hs.eg.db")
#
# test_geneIDs <- as.data.frame(test)$geneId
# names(test_geneIDs) = sub("_", "\n", names(test_geneIDs))
#
# testDO <- enrichDO(test_geneIDs,
# ont = "DO",
# pvalueCutoff = 0.2,
# pAdjustMethod = "BH",
# minGSSize = 2,
# qvalueCutoff = 0.2)
# dotplot(testDO, showCategory=15)
#
# testGO <- enrichGO(test_geneIDs,
# ont = "BP",
# pvalueCutoff = 0.2,
# pAdjustMethod = "BH",
# minGSSize = 2,
# qvalueCutoff = 0.2,
# org.Hs.eg.db)
#
# dotplot(testGO, showCategory=15)