subset | R Documentation |
Dropping samples or OTUs will lead to observations being removed from the
OTU matrix (biom$counts
). OTUs and samples with zero observations are
automatically removed from the rbiom object.
## S3 method for class 'rbiom'
subset(x, subset, clone = TRUE, ...)
## S3 method for class 'rbiom'
x[i, j, ..., clone = TRUE, drop = FALSE]
## S3 method for class 'rbiom'
na.omit(object, fields = ".all", clone = TRUE, ...)
subset_taxa(x, subset, clone = TRUE, ...)
x |
An rbiom object, such as from |
subset |
Logical expression for rows to keep. See |
clone |
Create a copy of |
... |
Not used. |
i , j |
The sample or OTU names to keep. Or a logical/integer vector
indicating which sample names from |
drop |
Not used |
object |
An rbiom object, such as from |
fields |
Which metadata field(s) to check for |
An rbiom object.
Other transformations:
modify_metadata
,
rarefy()
,
rarefy_cols()
,
slice_metadata
,
with()
library(rbiom)
library(dplyr)
# Subset to specific samples
biom <- hmp50[c('HMP20', 'HMP42', 'HMP12')]
biom$metadata
# Subset to specific OTUs
biom <- hmp50[c('LtbAci52', 'UncO2012'),] # <- Trailing ,
biom$taxonomy
# Subset to specific samples and OTUs
biom <- hmp50[c('LtbAci52', 'UncO2012'), c('HMP20', 'HMP42', 'HMP12')]
as.matrix(biom)
# Subset samples according to metadata
biom <- subset(hmp50, `Body Site` %in% c('Saliva') & Age < 25)
biom$metadata
# Subset OTUs according to taxonomy
biom <- subset_taxa(hmp50, Phylum == 'Cyanobacteria')
biom$taxonomy
# Remove samples with NA metadata values
biom <- mutate(hmp50, BS2 = na_if(`Body Site`, 'Saliva'))
biom$metadata
biom <- na.omit(biom)
biom$metadata
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.