% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/taxa_contribution.R
\name{read_contrib_file}
\alias{read_contrib_file}
\title{Read PICRUSt2 contribution file}
\usage{
read_contrib_file(file = NULL, data = NULL)
}
\arguments{
\item{file}{Path to the contribution file (.tsv, .txt, or .csv).}

\item{data}{A data.frame already loaded from the contribution file.
If both \code{file} and \code{data} are provided, \code{data} is used.}
}
\value{
A data.frame with columns: \code{sample}, \code{function_id},
  \code{taxon}, \code{taxon_function_abun}, \code{norm_taxon_function_contrib},
  and any additional columns from the original file.
}
\description{
Parses the \code{pred_metagenome_contrib.tsv} file produced by PICRUSt2's
\code{--per_sequence_contrib} flag.
}
\details{
The contribution file records how much each ASV/OTU contributes to the
predicted abundance of each gene family in each sample. The
\code{norm_taxon_function_contrib} column gives the proportion of a
function's abundance attributable to each taxon.
}
\examples{
\donttest{
# 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)
}

}
