% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/parse_count_tables.R
\name{parse_count_tables}
\alias{parse_count_tables}
\title{Parse per-sample TSV files into combined MAG-by-sample matrices}
\usage{
parse_count_tables(
  path,
  pattern = "*.tsv",
  columns = c(count = 1L, relative_abundance = 2L, covered_fraction = 3L),
  clean_names = TRUE,
  drop_first_row = TRUE
)
}
\arguments{
\item{path}{Directory containing the TSV files.}

\item{pattern}{Glob pattern passed to \code{\link[base:list.files]{base::list.files()}}.}

\item{columns}{Named integer vector mapping result names to column
indices.  Defaults to
\code{c(count = 1L, relative_abundance = 2L, covered_fraction = 3L)}.
Set to \code{NULL} or a subset to read only the matrices you need.}

\item{clean_names}{Logical; apply \code{\link[=clean_sample_names]{clean_sample_names()}} to column
names?}

\item{drop_first_row}{Logical; drop the first data row (header
duplication artifact in raw TSVs)?}
}
\value{
A named list of data.frames, one per entry in \code{columns}.  Each
data.frame has MAG IDs as row names and samples as columns.
}
\description{
Reads a directory of per-sample TSV files (as produced by read-mapping
pipelines) and merges them into MAG-by-sample matrices for read counts,
relative abundance, and covered fraction.
}
\details{
Each TSV is expected to have MAG identifiers as row names and at least
three data columns (count, relative abundance, covered fraction).  The
first row in the raw files is often a duplicated header and is dropped by
default (\code{drop_first_row = TRUE}).
}
\examples{
d <- tempfile("tsvdir")
dir.create(d)
writeLines(c("MAG\tcount\trel_abund\tcov_frac",
  "MAG1\t100\t0.5\t0.8", "MAG2\t200\t0.3\t0.6"),
  file.path(d, "sample1.tsv"))
tables <- parse_count_tables(d, drop_first_row = FALSE)
tables$count

}
