pool_samples | R Documentation |
Pools abundances from samples according to a grouping factor.
pool_samples(x, ...) ## Default S3 method: pool_samples(x, groups, FUN = sum, return.dataset = FALSE) ## S3 method for class 'Dataset' pool_samples(x, groups, FUN = sum, return.dataset = FALSE)
x |
Either a numerical matrix or a Dataset object. For a numerical matrix, samples are given as columns and taxa as rows. |
groups |
For the default and Dataset methods this can be either a vector
or factor specifying to which group each sample belongs. Vectors will be
converted to a factor with the |
FUN |
Function to apply when collapsing the data. Defaults to |
return.dataset |
Logical, if TRUE returns a dataset |
Wrapper for collapse_matrix
. This function is useful to calculate
per-group summary statistics per taxon.
The default method takes an abundance matrix and a grouping factor, then applies the aggregating function FUN to the groups of samples defined by the grouping factor.
The Dataset method takes a Dataset object and obtains the grouping factor from the Map element.
The default method returns a matrix
object, unless return.dataset
is TRUE, in which case it returns a Dataset.
The Dataset method returns a Dataset
object when Dat includes a Tax element
(see create_dataset
); when the Tax element is missing it returns a
matrix
object. If return.dataset is TRUE, return a dataset
Sur Herrera Paredes
library(AMOR) data(Rhizo) data(Rhizo.map) data(Rhizo.tax) Dat <- create_dataset(Rhizo,Rhizo.map,Rhizo.tax) # The following returns a numeric matrix Collapsed1 <- pool_samples(x = Dat$Tab,groups = Dat$Map$fraction) # The following returns a Dataset Collapsed2 <- pool_samples(x = Dat,groups = "fraction") # You can also directly pass a grouping factor to the Dataset method Collapsed3 <- pool_samples(x = Dat,groups = Dat$Map$fraction) # A way to calculate the overall counts per taxa res <- pool_samples(Dat$Tab, groups = rep("all", length.out = ncol(Rhizo)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.