• 0 views
•
link
Exon density in uniform bins across bam files
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?
• 1,250 views
•
link
1 answer
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)
• 0 views
•
link
Log in to answer this question.