Closed TKMarkCheng closed 2 months ago
Recent development versions of rbiom allow assignment to biom$otus
, like below:
remotes::install_github("cmmr/rbiom")
biom <- rbiom::hmp50$clone()
# See the current OTU names
head(biom$otus)
# Change the OTU names
biom$otus <- paste0("OTU", seq_len(biom$n_otus))
# See the new OTU names
head(biom$otus)
biom$taxonomy
as.matrix(biom$counts[1:4,1:4])
@dansmith01 thank you for the swift response. How about for subsetting by otus? (Or otu levels housed in biom$taxonomy)
thank you so much in advance!
To drop otus or taxa, you can assign a new otu abundance matrix to biom$counts
.
remotes::install_github("cmmr/rbiom")
library(rbiom)
biom <- hmp50$clone()
# Keep 300 most abundant OTUs
keep <- taxa_means(biom) %>% names() %>% head(300)
biom$counts <- biom$counts[keep,]
# Drop specific OTUs
drop <- c("CnbTube3", "PpbAcne6")
keep <- setdiff(biom$otus, drop)
biom$counts <- biom$counts[keep,]
# Keep only OTUs from a specific Phylum
keep <- biom$taxonomy %>% filter(Phylum == "Firmicutes") %>% pull(.otu)
biom$counts <- biom$counts[keep,]
At the moment there is no convenient option to perform changes on .otus like sample names/metadata
A Work around currently is:
biom$counts$dimnames[1]
followed by changingbiom$taxonomy$.otu
in the same way.