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

\item{data}{A data.frame already loaded from the stratified file.
If both \code{file} and \code{data} are provided, \code{data} is used.}
}
\value{
A tidy data.frame with columns: \code{function_id}, \code{taxon},
  \code{sample}, \code{abundance}.
}
\description{
Parses the \code{pred_metagenome_strat.tsv} file produced by PICRUSt2's
\code{--strat_out} flag and converts the wide format to tidy long format.
}
\details{
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.
}
\examples{
\donttest{
# 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)
}

}
