Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
hacked GRanges averaging
averageGranges <- GRanges()
interval_length <- 10000
for (scaffold_index in 1:nrow(myscaffolds)) {
scaffold <- myscaffolds$id[scaffold_index]
scaffold_length <- myscaffolds$to[scaffold_index]
num_intervals <- scaffold_length / interval_length
for (interval_index in 0:(num_intervals-1) ) {
grangesInterval <- GRanges(scaffold, IRanges(interval_index * interval_length,
min( scaffold_length,
(interval_index+1)* interval_length )))
subsetGranges <- subsetByOverlaps( bigGranges , grangesInterval)
grangesInterval$averagemyValue <- mean(subsetGranges$myValue)
averageGranges <- append(averageGranges, grangesInterval)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment