只需要bw文件和bed文件即可
参考https://github.com/teunbrand/tornadoplot/blob/master/data-raw/octsox_peaks.R
# Libraries ---------------------------------------------------------
library(GenomicRanges)
library(rtracklayer)
# Files import ---------------------------------------------------------
dir <- file.path("C:/High-throughput sequencing/torplot")
dir <- file.path("/DATA", "users", "t.vd.brand", "test_data")
files <- file.path(dir,c("H3K27ac_0h.bed","H3K27ac_4h.bed"))
# Data import -------------------------------------------------------------
si <- SeqinfoForUCSCGenome("mm10")
si <- keepStandardChromosomes(si, "Mus_musculus")
bed <- lapply(files, import)
bed <- lapply(bed, keepStandardChromosomes, "Mus_musculus", "coarse")
bed <- as(bed, "GRangesList")
bed <- setNames(bed, c("H3K27ac_LH0h", "H3K27ac_LH4h"))
red <- reduce(stack(bed))
red$H3K27ac_LH0h <- overlapsAny(red, bed$H3K27ac_LH0h)
red$H3K27ac_LH4h <- overlapsAny(red, bed$H3K27ac_LH4h)
red$cat <- ifelse(red$H3K27ac_LH0h & red$H3K27ac_LH4h, "both",
ifelse(red$H3K27ac_LH0h, "H3K27ac_LH0h", "H3K27ac_LH4h"))
red <- GRanges(seqnames(red), IRanges(start(red), end(red)),
seqinfo = si, cat = red$cat)
# Choosing sites ----------------------------------------------------------
set.seed(0)
octsox_peaks <- GRangesList(
LH0h_unique = sample(red[red$cat == "H3K27ac_LH0h"], 420),
LH4h_unique = sample(red[red$cat == "H3K27ac_LH4h"], 420),
Both = sample(red[red$cat == "both"], 420)
)
###420是随机抽多少个条目展示,抽样越多累加堆积越好看
octsox_peaks <- sort(octsox_peaks)
#bw data import----------------------------------------------
library(BiocFileCache)
bfc <- BiocFileCache()
source<-c(
"LH_0h"="H3K27ac_hcg_0h.bw",
"LH_4h"="H3K27ac_hcg_4h.bw")
#sample name-----------------------------------------------
bigwigs <- setNames(bfcrpath(bfc, source),
c("H3K27ac_LH0h", "H3K27ac_LH4h"))
library(tornadoplot)
feats <- octsox_peaks
bigwigs <- BigWigFileList(bigwigs)
tornado_plot(features = feats, data = bigwigs)