% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/matchSamples.R
\name{matchSamples}
\alias{matchSamples}
\title{Match Paired Samples Across Host and Microbiome Datasets}
\usage{
matchSamples(
  host_se,
  mb_se,
  sample_col_host = NULL,
  sample_col_mb = NULL,
  min_paired = 5L
)
}
\arguments{
\item{host_se}{A \code{SummarizedExperiment} from
\code{\link{loadHostData}}, with samples as columns.}

\item{mb_se}{A \code{SummarizedExperiment} from
\code{\link{loadMicrobiomeData}}, with samples as columns.}

\item{sample_col_host}{A \code{character(1)} naming the column in
\code{colData(host_se)} that contains the sample identifier. If
\code{NULL} (default), uses \code{colnames(host_se)}.}

\item{sample_col_mb}{A \code{character(1)} naming the column in
\code{colData(mb_se)} that contains the sample identifier. If
\code{NULL} (default), uses \code{colnames(mb_se)}.}

\item{min_paired}{An \code{integer(1)} minimum number of paired
samples required to proceed. Default: \code{5}.}
}
\value{
A \code{MultiAssayExperiment} with two experiments:
  \describe{
    \item{\code{"host"}}{Subset of \code{host_se} for paired samples.}
    \item{\code{"microbiome"}}{Subset of \code{mb_se} for paired
      samples.}
  }
  The \code{colData} of the MAE is taken from \code{host_se} for the
  paired samples.
}
\description{
Identifies samples present in both host and microbiome
\code{SummarizedExperiment} objects, subsets both to the common
samples, and assembles a \code{MultiAssayExperiment} (MAE) that
serves as the primary input for downstream analysis functions.
}
\details{
In paired multi-omics studies, not all samples necessarily have both
data types due to sequencing failures, QC exclusions, or study design.
\code{matchSamples} transparently reports how many samples are retained
and warns if fewer than \code{min_paired} paired samples are found.

The output \code{MultiAssayExperiment} stores the host and microbiome
\code{SummarizedExperiment} objects under the names \code{"host"} and
\code{"microbiome"} respectively, with a unified \code{colData} drawn
from the host sample metadata.
}
\examples{
set.seed(42)
# Host data: 200 genes, 20 samples
host_counts <- matrix(rpois(200 * 20, 150),
                      nrow = 200, ncol = 20,
                      dimnames = list(paste0("Gene", 1:200),
                                      paste0("Sample", 1:20)))
host_se <- loadHostData(host_counts)

# Microbiome data: 50 taxa, 18 samples (2 missing)
mb_counts <- matrix(rpois(50 * 18, 30),
                    nrow = 50, ncol = 18,
                    dimnames = list(paste0("Taxon", 1:50),
                                    paste0("Sample", 1:18)))
mb_se <- loadMicrobiomeData(mb_counts)

mae <- matchSamples(host_se, mb_se, min_paired = 5)
mae

}
\seealso{
\code{\link{loadHostData}}, \code{\link{loadMicrobiomeData}},
  \code{\link{MultiOmicsBridgeAnalysis}}
}
