Description Usage Arguments Value DETAILS Author(s) See Also Examples
View source: R/binFeatureProfiles.R
Bin coverage profiles given as a matrix or RleList of profiles.
1 2 3 4 5 6 7 8 | binFeatureProfiles(
FeatureProfiles,
nbins = 100L,
binwidth = NULL,
aggregFUN = "mean",
asMatrix = FALSE,
...
)
|
FeatureProfiles |
A |
nbins |
Integer. Number of bins to define along each feature. Default value is 100 bins. |
binwidth |
Integer. Size of the bins to define on the features. Default value is NULL and 100 bins are used instead. |
aggregFUN |
A character string (or a function name), such as "median", "mean", etc., with the name of a function used to aggregate the data within the bins. Defaults to "mean".
A user-defined aggregFUN should take an |
asMatrix |
Logical (default to FALSE). If TRUE, the binned profiles are returned as a matrix (only possible if featrures have the same number of bins). |
... |
Further arguments passed to aggregFUN. |
An RleList
or a matrix
(if asMatrix
is TRUE) of binned profiles.
The function removes features of length < nbins (or binwidth) and returns an message with the number of removed features.
The remaining features are sliced into nbins
(possibly different bin sizes for different features) or into bins of size binwidth
(possibly different number of bins for different features).
Then the data in each bins is aggregated using the aggregFUN function
Pascal GP Martin
profcomp
annotationCoverageAroundFeatures
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ## Obtain coverage for all genes:
covr <- GenomicRanges::coverage(Genegr)
## Select a (random) set of (100) genes
set.seed(123)
randGenes <- sample(names(Genegr), 100)
## Windows of interests covering the gene bodies + 50bp on each side
woi <- Genegr[randGenes] +50
## Remove windows that go beyond chromosome borders
woi <- woi[GenomicRanges::width(GenomicRanges::trim(woi)) -
GenomicRanges::width(woi) == 0]
## Coverage on these windows of interest:
profs <- profcomp(covr, woi)
## Make 10 bins:
binFeatureProfiles(profs, nbins = 10)
## Return a matrix instead:
binFeatureProfiles(profs[1:3], nbins=10, asMatrix = TRUE)
## Make bins of size 20bp:
binFeatureProfiles(profs, binwidth=20)
##use your own function to aggregate the data within the bins
mymean <- function(x) {mean(as.numeric(x), trim=0.1)}
binFeatureProfiles(profs[1:3], aggregFUN=mymean, nbins=10, asMatrix = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.