View source: R/genomic-helper.R
| genomic_density | R Documentation |
Computes the density or count of genomic regions in sliding or fixed windows across the genome. The density can be reported as the percentage of uncovered bases or the number of overlapping regions within each window.
genomic_density(
region,
window_size = 1e+07,
n_window = NULL,
overlap = TRUE,
mode = c("coverage", "count"),
seqlengths = NULL
)
region |
A data frame with at least 3 columns: chromosome, start, and end.
|
window_size |
Numeric, the width of each window (default is |
n_window |
Integer, the number of windows per chromosome. If provided,
overrides |
overlap |
Logical, whether to use overlapping windows (default |
mode |
Character, either
|
seqlengths |
Optional named vector of chromosome lengths. If missing,
the maximum |
This function splits the input by chromosome and tiles the genomic space into windows, optionally overlapping. For each window, it calculates:
the number of regions that overlap it (if mode = "count"), or
the fraction of bases covered by any region (if mode = "percent").
A data frame containing the first three columns from region,
plus a fourth column density, which represents either the region count
or the coverage percentage, depending on mode.
region <- data.frame(
chr = rep("chr1", 3),
start = c(100, 5000000, 15000000),
end = c(2000000, 7000000, 17000000)
)
genomic_density(region, window_size = 1e7, mode = "count")
genomic_density(region, n_window = 3, overlap = FALSE, mode = "coverage")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.