taxa.rollup {rbiom} | R Documentation |
Generate a matrix of samples by taxa, at the specified taxonomic rank.
Description
Generate a matrix of samples by taxa, at the specified taxonomic rank.
Usage
taxa.rollup(biom, rank = "OTU", map = NULL, lineage = FALSE, sparse = FALSE)
Arguments
biom |
A |
rank |
The taxonomic rank. E.g. “OTU”, “Phylum”, etc. May also be given numerically: 0 for OTU, 1 for the highest level (i.e. Kingdom), and extending to the number of taxonomic ranks encoded in the original biom file. See example below to fetch the names of all available ranks. |
map |
A character matrix defining the value that each taxa IDs is
assigned for each taxonomic rank. If |
lineage |
Include all ranks in the name of the taxa. For instance,
setting to |
sparse |
If true, returns a sparse matrix as described by
|
Value
A numeric matrix with samples as column names, and taxonomic identifiers as row names.
Examples
library(rbiom)
infile <- system.file("extdata", "hmp50.bz2", package = "rbiom")
biom <- read.biom(infile)
colnames(biom$taxonomy)
phyla <- taxa.rollup(biom, 'Phylum')
phyla[1:4,1:6]
# Custom matrices should be formatted like so:
counts <- as.matrix(biom$counts)
map <- biom$taxonomy
counts[1:3,1:6]
map[1:3,1:4]
phyla <- taxa.rollup(counts, 'Phylum', map=map)
phyla[1:3,1:6]