# Making up an InteractionSet for binned data.
nfrags <- 50
frag.sizes <- as.integer(runif(nfrags, 5, 10))
ends <- cumsum(frag.sizes)
cuts <- GRanges("chrA", IRanges(c(1, ends[-nfrags]+1), ends))
param <- pairParam(cuts)
regions <- diffHic:::.getBinID(cuts, 20)$region
all.combos <- combn(length(regions), 2)
y <- InteractionSet(matrix(0, ncol(all.combos), 1),
GInteractions(anchor1=all.combos[2,], anchor2=all.combos[1,],
regions=regions, mode="reverse"),
colData=DataFrame(lib.size=1000), metadata=List(param=param, width=20))
# Generating partially overlapping regions.
set.seed(3424)
re <- sample(nfrags, 20)
rs <- as.integer(runif(20, 1, re+1))
regions <- GRanges("chrA", IRanges(start(cuts)[rs], end(cuts)[re]))
regions$nfrags <- re - rs + 1L
regions <- sort(regions)
all.combos <- combn(length(regions), 2)
y2 <- InteractionSet(matrix(0, ncol(all.combos), 1),
GInteractions(anchor1=all.combos[2,], anchor2=all.combos[1,],
regions=regions, mode="reverse"),
colData=DataFrame(lib.size=1000), metadata=List(param=param))
#### Getting areas. ####
getArea(y)
getArea(y, bp=FALSE)
getArea(y2)
getArea(y2, bp=FALSE)
Run the code above in your browser using DataLab