Exon density in uniform bins across bam files
1
I'd like to calculate the percent of bases that overlap exons in uniformly sized (n mB) windows across several bam files. Could anyone help me determine this preferably using bedtools or R?
alignment
sequencing
• 1.1k views
using R GenomicRanges and given two granges objects exonic_bed and bins
hits <- GenomicRanges::findOverlaps(query = exonic_bed,
subject = bins, ignore.strand = TRUE)
overlaps <- pintersect(bins[subjectHits(hits)],
exonic_bed[queryHits(hits)], ignore.strand = TRUE)
subjecthits <- bins[subjectHits(hits)]
subjecthits$n_overlap <- width(overlaps)
subjecthits <-
subjecthits %>%
as_tibble() %>%
dplyr::group_by(seqnames, start, end, width) %>%
dplyr::summarize(overlap = sum(n_overlap)) %>%
dplyr::mutate(percent_overlap = overlap/width)
Login before adding your answer.
this seems relevant