-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
146 lines (100 loc) · 3.87 KB
/
README.Rmd
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
---
title: "README"
author: "Mohamed Nadhir Djekidel"
date: "6/30/2020"
output:
md_document:
variant: markdown_github
---
## Load required libraries
```{r message=FALSE, warning=FALSE}
require(mhsmm)
require(BSgenome.Mmusculus.UCSC.mm10)
require(rtracklayer)
require(dplyr)
require(glue)
# for plotting genome browswer view (optional)
require(Gviz)
require(TxDb.Mmusculus.UCSC.mm10.knownGene)
require(org.Mm.eg.db)
# just for colorful plotting
require(crayon)
```
## Load the scripts
```{r}
source("utils.R")
```
## Define the list of bw files
```{r}
bw_file_paths = list(H2K27me3_MII = "bigWig_examples/H3K27me3_MII_mm10.sorted.Q10.dedup.sorted.bw",
H2K27me3_2C = "bigWig_examples/H3K27me3_2C_mm10.sorted.Q10.dedup.sorted.bw",
H2K27me3_4C = "bigWig_examples/H3K27me3_4C_mm10.sorted.Q10.dedup.sorted.bw"
)
```
## Load the mm10 blacklist regions (optional)
```{r}
mm10_blacklist = "mm10-blacklist.v2.bed"
mm10_blacklist_gr = data.table::fread(mm10_blacklist)
colnames(mm10_blacklist_gr) = c("seqnames","start","end","Type")
mm10_blacklist_gr = GRanges(mm10_blacklist_gr)
mm10_blacklist_gr = subset(mm10_blacklist_gr, Type == "High Signal Region")
head(mm10_blacklist_gr)
```
## Call Domains
```{r}
H3K27me3_domains <- list()
for(bw in names(bw_file_paths)){
bw_file= bw_file_paths[[bw]]
H3K27me3_domains[[bw]] = CallDomains(bw_file = bw_file,
winsize = 5000,
stepsize = 5000,
training.chrom = glue("chr{1:4}"),
chromsToUse = glue("chr{1:19}"),
genome = 'mm10',
smooth = FALSE,
mm10_blacklist_gr = mm10_blacklist_gr,
saveProbs = FALSE,
plot.model = TRUE,
outDir = "HMMDomains"
)
}
```
## Check the output folder
```{r}
list.files("HMMDomains/",full.names = T)
```
## Visualize the detected domains
Let's display the Hoxc locus as example
```{r fig.height=6, fig.width=15}
hoxc.gr = GRanges("chr15:100859671-104043685")
txdb <- TxDb.Mmusculus.UCSC.mm10.knownGene
TxByGns <- genes(txdb)
TxByGns = subset(TxByGns, seqnames == seqlevels(hoxc.gr))
TxByGns$gene_name <- mapIds(org.Mm.eg.db,
keys = as.character(TxByGns$gene_id),
column = "SYMBOL",
keytype = "ENTREZID",
multiVals = "first")
TxDbTrack <- GeneRegionTrack(TxByGns,chromosome=seqlevels(hoxc.gr),gene = TxByGns$gene_name)
#idio_track <- IdeogramTrack(genome = "mm10", chromosome = seqnames(hoxc.gr)[1])
gtrack <- GenomeAxisTrack()
bw_tracks <- c(gtrack, TxDbTrack)
bw_range = BigWigSelection(ranges = hoxc.gr)
seqlen = seqlengths(BSgenome.Mmusculus.UCSC.mm10)[seqlevels(hoxc.gr)]
region <- GRanges(seqlevels(hoxc.gr), IRanges(1,seqlen))
for(bw in names(bw_file_paths)){
bw_file= bw_file_paths[[bw]]
coverage <- import.bw(bw_file,which=region)#,selection = bw_range)
dt <- DataTrack(coverage,chomosome=seqlevels(hoxc.gr),name = glue("{bw} signal"))
bw_tracks = c(bw_tracks, dt)
#domains_inregion = subsetByOverlaps(H3K27me3_domains[[bw]], hoxc.gr)
atrack <- AnnotationTrack(H3K27me3_domains[[bw]], name = glue("{bw} domains"),chromosome = seqlevels(hoxc.gr))
bw_tracks = c(bw_tracks, atrack)
}
plotTracks(bw_tracks,
chromosome=seqlevels(hoxc.gr),
from = start(hoxc.gr),
to = end(hoxc.gr),
type="h",
transcriptAnnotation="gene")
```