Generate matrix of simulated doublets
simulate_doublets.RdGenerate a matrix of simulated doublets from a non-normalized
(features x cells) matrix. Random cell pairs are drawn with replacement,
each side is independently downsampled at the entry level via
BPCells::sample_bernoulli(), and the two sides are added with the
lazy IterableMatrix + operator. The whole pipeline is one
streaming C++ pass over mat; no full-matrix materialization occurs.
Usage
simulate_doublets(
mat,
n_doublets = 1000,
n_trials = NULL,
sample_ratio = 0.5,
seed = 1L,
verbose = getOption("MarchR.verbose", FALSE),
...
)Arguments
- mat
(IterableMatrix) Input matrix to generate simulated doublets from.
- n_doublets
(numeric) Number of doublets per trial.
- n_trials
(numeric or NULL) Number of simulation trials. If
NULL(default),5 * max(floor(n_cells / n_doublets), 1).- sample_ratio
(numeric, (0, 1]) Per-entry keep probability applied independently to each side of the pair before summing. Default 0.5.
- seed
(integer) Reproducibility seed for both the cell-pair draws and the Bernoulli downsampling. Default 1L.
- verbose
(logical) Print progress messages. Default
getOption("MarchR.verbose", FALSE).
Value
A lazy IterableMatrix chain (bernoulli + bernoulli + add) with
dimensions (features x (n_doublets x n_trials)). Downstream callers
materialize it via write_matrix_dir() (e.g. inside
project.IterativeLSI()), so no tempdir is created here.