在 R 中使用 Bioconductor 进行 ChIP-seq 分析
Peter Humburg
Statistician, Macquarie University


加载数据:
reads <- readGAlignments(bam)
reads_gr <- granges(reads[[1]])
获取平均片段长度:
frag_length <- fragmentlength(qc_report)["GSM1598218"]
延伸reads并计算覆盖度:
reads_ext <- resize(reads_gr, width=frag_length)
cover_ext <- coverage(reads_ext)

在全基因组创建200 bp分箱。
bins <- tileGenome(seqinfo(reads), tilewidth=200,
cut.last.tile.in.chrom=TRUE)
查找与峰值重叠的所有分箱。
peak_bins_overlap <- findOverlaps(bins, peaks)
peak_bins <- bins[from(peak_bins_overlap), ]
统计每个峰值分箱的重叠reads数。
peak_bins$score <- countOverlaps(peak_bins, reads)
count_bins <- function(reads, target, bins){
# Find all bins overlapping peaks
overlap <- from(findOverlaps(bins, target))
target_bins <- bins[overlap, ]
# Count the number of reads overlapping each peak bin
target_bins$score <- countOverlaps(target_bins, reads)
target_bins
}
peak_bins <- count_bins(reads_ext, peaks, bins)
bl_bins <- count_bins(reads_ext, blacklist.hg19, bins)
移除已计入的所有分箱。
bkg_bins <- subset(bins, !bins %in% peak_bins & !bins %in% bl_bins)
统计每个剩余分箱的重叠reads数。
bkg_bins$score <- countOverlaps(bkg_bins, reads_ext)



在 R 中使用 Bioconductor 进行 ChIP-seq 分析