View source: R/taxa_contribution.R
| read_strat_file | R Documentation |
Parses the pred_metagenome_strat.tsv file produced by PICRUSt2's
--strat_out flag and converts the wide format to tidy long format.
read_strat_file(file = NULL, data = NULL)
file |
Path to the stratified file (.tsv, .txt, .csv, or gzipped variants). |
data |
A data.frame already loaded from the stratified file.
If both |
The stratified file has function IDs in the first column, sequence/taxon IDs in the second column, and sample abundances in the remaining columns (wide format). This function pivots to long format for downstream analysis. Function IDs, taxon IDs, and sample column names must be non-empty; sample column names must also be unique.
A tidy data.frame with columns: function_id, taxon,
sample, abundance.
# From a data.frame
strat_df <- data.frame(
`function` = c("K00001", "K00001", "K00002"),
sequence = c("ASV1", "ASV2", "ASV1"),
S1 = c(10, 5, 8),
S2 = c(12, 3, 7),
check.names = FALSE
)
result <- read_strat_file(data = strat_df)
head(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.