Extracts the count table, taxonomy and sample metadata of a
phyloseq object into the plain data frames that every
MicroBioMeta function takes.
Value
A list with two data frames:
tableTaxa in rows, samples in columns, and a last column
taxonomywith the full taxonomic string (e.g."k__Bacteria; p__Firmicutes; c__Bacilli").metadataSample metadata whose first column,
SAMPLEID, holds the sample names oftable.
See also
from_tse for (Tree)SummarizedExperiment
objects.
Examples
if (requireNamespace("phyloseq", quietly = TRUE)) {
counts <- matrix(c(10, 0, 5, 3, 8, 1),
nrow = 3,
dimnames = list(c("ASV1", "ASV2", "ASV3"), c("S1", "S2"))
)
tax <- matrix(
c(
"Bacteria", "Bacteria", "Bacteria",
"Firmicutes", "Proteobacteria", NA
),
nrow = 3, dimnames = list(rownames(counts), c("Kingdom", "Phylum"))
)
samples <- data.frame(
Soil = c("Rhizosphere", "Bulk soil"),
row.names = c("S1", "S2")
)
ps <- phyloseq::phyloseq(
phyloseq::otu_table(counts, taxa_are_rows = TRUE),
phyloseq::tax_table(tax),
phyloseq::sample_data(samples)
)
mbm <- from_phyloseq(ps)
mbm$table
mbm$metadata
}
#> SAMPLEID Soil
#> 1 S1 Rhizosphere
#> 2 S2 Bulk soil