read_contrib_file: Read PICRUSt2 contribution file

View source: R/taxa_contribution.R

read_contrib_fileR Documentation

Read PICRUSt2 contribution file

Description

Parses the pred_metagenome_contrib.tsv file produced by PICRUSt2's --per_sequence_contrib flag.

Usage

read_contrib_file(file = NULL, data = NULL)

Arguments

file

Path to the contribution file (.tsv, .txt, or .csv).

data

A data.frame already loaded from the contribution file. If both file and data are provided, data is used.

Details

The contribution file records how much each ASV/OTU contributes to the predicted abundance of each gene family in each sample. The norm_taxon_function_contrib column gives the proportion of a function's abundance attributable to each taxon.

Value

A data.frame with columns: sample, function_id, taxon, taxon_function_abun, norm_taxon_function_contrib, and any additional columns from the original file.

Examples


# From a data.frame
contrib_df <- data.frame(
  sample = rep(c("S1", "S2"), each = 4),
  `function` = rep(c("K00001", "K00002"), 4),
  taxon = rep(c("ASV1", "ASV2"), each = 2, times = 2),
  taxon_function_abun = runif(8),
  norm_taxon_function_contrib = runif(8),
  check.names = FALSE
)
result <- read_contrib_file(data = contrib_df)
head(result)



ggpicrust2 documentation built on April 10, 2026, 5:06 p.m.