Description Usage Arguments Value Examples
Randomly samples interactions from data frame with atomic interactions into length(ratio)
data frames with interactions in such a way that i-th dataframe have ratio[i]
fraction of interactions of initial atomic interactions data frame.
1 2 3 4 5 | bootstrap_interactions(
interactions,
ratio = c(0.5, 0.5),
with.replacement = FALSE
)
|
interactions |
data frame containing row with i and j coordinate for every single interaction |
ratio |
numeric vector indicating on how many atomic interaction sets should initial atomic interaction set be divided; each entry of ratio vector contains fraction of interaction to be put in corresponding atomic interactions set; ratio vector must sum to 1 and all its entries must be larger than one |
data frame representing sparse Hi-C maps (with i, j, val columns) belonging to corresponding bootstrapped interactions subset - ratio.number column indicates index of fraction from ratio vector
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # create data frame with artificial interactions, where val
# indicates total number of interactions between bins i and j
sparse.mtx <- data.frame(i = c(1,3,5,7,8,9,11), j = c(7,2,1,1,3,10,9), val = c(10,8,3,1,1,2,20))
atomic.interactions <- sparse2interactions(sparse.mtx)
print(head(atomic.interactions))
b1 <- bootstrap_interactions(atomic.interactions)
print(b1)
ratios.desired <- c(0.4,0.3,0.2,0.1)
b2 <- bootstrap_interactions(atomic.interactions, ratio = ratios.desired)
print(b2)
sum.interactions <- nrow(atomic.interactions)
ratios.sampled <- sapply(split(b2, b2$ratio.number), function(x){ sum(x$val) / sum.interactions })
print(ratios.desired)
print(ratios.sampled)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.