% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/main.r
\name{get_celltype_counts}
\alias{get_celltype_counts}
\title{Get the cell type counts from a long data frame (e.g. seurat object metadata)
where each cell is a row.}
\usage{
get_celltype_counts(cell_data_df, sample_col, celltype_col)
}
\arguments{
\item{cell_data_df}{A data frame where each row represents a single cell, and
columns contain cell-level information, including sample ID and cell type
annotation.}

\item{sample_col}{The column that defines the sample ID for each cell}

\item{celltype_col}{The column that defines the cell type annotation for each
cell}
}
\value{
A data frame with cell types as rows and samples as columns,
containing the count of each cell type per sample.
}
\description{
Get the cell type counts from a long data frame (e.g. seurat object metadata)
where each cell is a row.
}
\examples{
# Create example data frame
cell_data_df <- data.frame(
    Cell_ID = paste0("C", seq(10)),
    Sample_Name = c(rep("S1", 5), rep("S2", 5)),
    Cluster_Annotation = factor(c(
        "B_Cell", "T_Cell", "B_Cell", NA, "T_Cell",
        "T_Cell", "Macrophage", "B_Cell", "T_Cell", "T_Cell"
    ))
)
#
# Calculate cell type counts per sample
celltype_counts <- get_celltype_counts(
    cell_data_df = cell_data_df,
    sample_col = "Sample_Name",
    celltype_col = "Cluster_Annotation"
)
#
print(celltype_counts)
# Note how the NA cell type count is handled and renamed to "NA".
}
