library(rbiom)
infile <- system.file("extdata", "hmp50.bz2", package = "rbiom")
biom <- read.biom(infile)
summary(biom)
# Taxa Abundances
as.matrix(biom$counts[1:4,1:4])
top5 <- names(head(rev(sort(slam::row_sums(biom$counts))), 5))
biom$taxonomy[top5,c('Family', 'Genus')]
as.matrix(biom$counts[top5, 1:6])
# Metadata
table(biom$metadata$Sex, biom$metadata$`Body Site`)
sprintf("Mean age: %.1f", mean(biom$metadata$Age))
# Phylogenetic tree
tree <- biom$phylogeny
top5.tree <- rbiom::subtree(tree, top5)
ape::plot.phylo(top5.tree)
Run the code above in your browser using DataLab