Downsample expression matrix to a target number of transcripts
per cell. This helps ensure that cell assignments are not biased by
overall expression levels.
Usage
downsample_expression(data, target_count = 1500, seed = NULL)
Arguments
- data
Gene expression count matrix (genes x cells).
- target_count
Target number of transcripts per cell. Default is 1500.
- seed
Random seed for reproducibility. Default is NULL.
Value
Downsampled matrix with the same dimensions as input.
Details
For each cell, if the total count exceeds target_count, transcripts
are randomly sampled without replacement. Cells with fewer transcripts are
left unchanged.
Examples
if (FALSE) { # \dontrun{
downsampled <- downsample_expression(counts, target_count = 1500)
} # }