% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/main.r
\name{get_sample_metadata}
\alias{get_sample_metadata}
\title{Extracts constant metadata for each sample from a cell-level data frame.}
\usage{
get_sample_metadata(cell_data_df, sample_col)
}
\arguments{
\item{cell_data_df}{A data frame containing cell-level metadata. This should
include the sample ID column and all potential metadata columns.}

\item{sample_col}{A character string specifying the name of the column that
defines the unique sample ID for each cell (e.g., "Sample_ID").}
}
\value{
A new data frame where:
\itemize{
\item Each row corresponds to a unique sample from the input data.
\item The row names are set to the values of the input
\code{sample_col}.
\item Columns contain only the metadata fields that were constant
across all cells within \strong{each} sample. The \code{sample_col}
itself is excluded from the final columns but used for
row names.
}
}
\description{
This function identifies columns in a cell-level metadata data frame that
have a \strong{constant} value for all cells belonging to the same sample. It
aggregates this constant information, returning a new data frame where each
row represents a unique sample. Columns that vary within any sample are
excluded from the output.
}
\examples{
# Assuming you have a data frame 'cell_df'
cell_df <- data.frame(
    Cell_ID = paste0("C", seq(10)),
    Sample_ID = c(rep("S1", 5), rep("S2", 5)),
    Age = c(rep(30, 5), rep(45, 5)),
    Gender = c(rep("M", 5), rep("F", 5)),
    Cell_Type = c(rep("A", 3), rep("B", 2), rep("A", 3), rep("B", 2))
)

# The 'Age' and 'Gender' columns are constant within each sample (S1 and S2).
# The 'Cell_ID' and 'Cell_Type' columns vary within sample S1 and/or S2.

sample_meta <- get_sample_metadata(cell_df, "Sample_ID")
print(sample_meta)
# Output will have 'Age' and 'Gender' as columns,
# with row names 'S1' and 'S2'.
}
