| filter.asv | R Documentation |
Filters an ASV count matrix by:
(1) removing samples with library size below min.lib;
(2) keeping features (taxa) that are "present" in at least
ceiling(prev.prop * nrow(S.counts)) samples, where presence is
defined by either min.count (counts) or min.rel (relative).
After feature filtering, zero-total samples are dropped and a row-normalized
relative-abundance matrix is returned alongside the filtered counts.
filter.asv(
S.counts,
min.lib = 1000,
prev.prop = 0.05,
min.count = 2,
min.rel = NULL,
min.feat.total = NULL,
verbose = TRUE
)
S.counts |
Numeric matrix (samples x features) of nonnegative counts. |
min.lib |
Integer. Minimum library size (row sum of counts) to keep a sample. Default: 1000. |
prev.prop |
Numeric in (0,1]. Minimum fraction of samples where a feature must be present. Default: 0.05. |
min.count |
Integer (>=1) or NULL. Reads to call "present" (ignored if |
min.rel |
Numeric in (0,1) or NULL. Relative abundance to call "present" (overrides |
min.feat.total |
Integer (>=0) or NULL. Optional minimum total reads across all samples per feature. Default: NULL. |
verbose |
Logical. Print keep/drop summaries. Default: TRUE. |
Sample filtering is applied on raw counts first. Prevalence is computed on the
post-sample-filter matrix using either a count or relative rule. A feature is
retained if prevalence \ge \lceil \text{prev.prop} \times n_{\text{samples}} \rceil.
After feature filtering, samples with zero remaining counts are dropped and
the relative matrix rel is row-normalized.
A list with elements:
Filtered count matrix (samples x features).
Row-normalized relative-abundance matrix.
Kept sample indices (original order).
Kept feature indices (original order).
Per-feature prevalence counts for kept features.
List of thresholds actually used.
Dot-delimited names; rows are samples, columns are features. Supply raw counts.
set.seed(1)
S <- matrix(rpois(100 * 20, lambda = 5), nrow = 100, ncol = 20)
res <- filter.asv(S, min.lib = 50, prev.prop = 0.1, min.count = 2)
dim(res$counts); dim(res$rel)
range(rowSums(res$rel))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.