as_tibble-phyloseq | R Documentation |
These functions extend the as_tibble()
function defined by the tibble
package to work on phyloseq objects or phyloseq-component objects.
## S3 method for class 'otu_table'
as_tibble(x, pivot = TRUE, .name_repair = base::make.unique)
## S3 method for class 'sample_data'
as_tibble(x, .name_repair = base::make.unique)
## S3 method for class 'taxonomyTable'
as_tibble(x, .name_repair = base::make.unique)
## S3 method for class 'XStringSet'
as_tibble(x)
## S3 method for class 'phyloseq'
as_tibble(x, tax = TRUE, ref = FALSE, .name_repair = base::make.unique)
x |
A phyloseq object or component. |
pivot |
Whether to pivot the otu table to long format. |
.name_repair |
Function to repair names in the case of conflicts. |
tax |
Whether to include taxonomy data. |
ref |
Whether to include reference sequences. |
Tibbles (tbl_df objects) do not support rownames; the taxa and sample names in the returned tibbles will always be stored in the first or second columns. The names ".otu", ".sample", ".abundance", and ".sequence" are special column names reserved for the otu/taxa names, sample names, abundances, and reference sequences.
A tibble (tbl_df)
library(tibble) # for as_tibble() and glimpse()
data(GlobalPatterns)
# Subset to 1/100 of the original taxa to speed operations
ps <- GlobalPatterns %>%
filter_tax_table(dplyr::row_number() %% 100 == 1)
# On phyloseq objects, as_tibble is similar to psmelt()
psmelt(ps) %>% glimpse
as_tibble(ps) %>% glimpse
# By default, the otu_table method provides a tibble in long-format like
# psmelt and the phyloseq method
otu_table(ps) %>% as_tibble %>% glimpse
# Sample data and taxonomy tables produced by as_tibble can be converted
# back into their respective phyloseq objects using speedyseq's tbl_df
# constructors
sample_data(ps) <- sample_data(ps) %>%
as_tibble %>%
dplyr::mutate(sample_sum = sample_sums(ps)) %>%
sample_data
sample_data(ps) %>% glimpse
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.