Sample single cells from the scRNA-seq dataset to match the estimated cell type composition in the ST data.
Arguments
- sc_data
Single-cell expression matrix (genes x cells).
- cell_types
Named character vector of cell types for each cell.
- target_counts
Named integer vector of target cell counts per type.
- method
Sampling method:
- "duplicates"
Allow duplicating cells when needed (default). Ensures all original cells are included first.
- "synthetic"
Generate synthetic cells by sampling gene expression values from the same cell type.
- seed
Random seed for reproducibility.
Value
A list containing:
- expression
Sampled expression matrix
- cell_ids
Vector of original cell IDs
- cell_types
Vector of cell types for sampled cells
- is_synthetic
Logical vector indicating synthetic cells
Examples
if (FALSE) { # \dontrun{
# Define target counts per cell type
targets <- c(B_cell = 100, T_cell = 200, Macrophage = 50)
# Sample cells
sampled <- sample_cells(sc_expr, cell_labels, targets)
} # }