-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisulizationChIPseq.R
32 lines (25 loc) · 1.17 KB
/
visulizationChIPseq.R
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
library(ggplot2)
library(rtracklayer)
dat <- import(con = "Downloads/GSM3325412_12_P4_Sox17_s7.bigWig", format = "bigWig")
head(dat)
df <- data.frame(chr = as.character(seqnames(dat)),
start = start(dat),
end = end(dat),
strand = as.character(strand(dat)),
score = score(dat),
stringsAsFactors = F)
startSite <- 8394823
endSite <- 8397823
chrome <- "chr1"
startSeg <- which(df$chr == chrome & df$start <= startSite & df$end >= startSite)
endSeg <- which(df$chr == chrome & df$start <= endSite & df$end >= endSite)
subbigwig <- df[startSeg:endSeg, ]
flattenBigWig <- rep(0, subbigwig$end[length(subbigwig$end)] - subbigwig$start[1] + 1)
names(flattenBigWig) <- c(subbigwig$start[1] : subbigwig$end[length(subbigwig$end)])
for(i in 1:nrow(subbigwig)){
flattenBigWig[as.character(c(subbigwig$start[i]:subbigwig$end[i]))] <- subbigwig$score[i]
}
chipseqSignal <- flattenBigWig[as.character(c(startSite:endSite))]
datForVisulize <- data.frame(sites = as.integer(names(chipseqSignal)),
signal = chipseqSignal)
ggplot(datForVisulize, aes(sites, signal)) + geom_point() + theme_bw()