structboost.sim_scrnaseq_anndata¶
- structboost.sim_scrnaseq_anndata(*, n=1000, n_genes=50, stageno=10, stagep=None, stagen=None, stageoverlap=None, hierarchy=True, markers_per_level=None, imbalanced=False, base_mean=2.0, gene_mean_shape=4.0, effect_size=10.0, effect_size_sd=0.0, dispersion=0.2, lib_size_sd=0.0, n_batches=1, batch_effect_sd=0.0, ambient_frac=0.0, dropout_mid=None, dropout_shape=-1.0, seed=1, target_sum=10000.0, standardize=True)[source]¶
Simulate scRNA-seq counts and package them as an AnnData object.
Wraps
sim_scrnaseq_data()and applies the standard preprocessing pipeline. Raw counts and library-size-normalized log1p values are always kept as layers, soadata.Xcan be swapped without re-simulating.Only the two preprocessing arguments are documented below; every other parameter is passed through to
sim_scrnaseq_data()unchanged.- Parameters:
target_sum (float) – Library size each cell is normalized to before
log1p.standardize (bool) – If True,
adata.Xholds the per-gene z-score of the log1p-normalized values, ready forBAE. If False,adata.Xholds the log1p-normalized values themselves.n (int)
n_genes (int)
stageno (int)
stagep (int | None)
stagen (int | None)
stageoverlap (int | None)
imbalanced (bool)
base_mean (float)
gene_mean_shape (float)
effect_size (float)
effect_size_sd (float)
dispersion (float)
lib_size_sd (float)
n_batches (int)
batch_effect_sd (float)
ambient_frac (float)
dropout_mid (float | None)
dropout_shape (float)
seed (int)
- Returns:
anndata.AnnData – Shape (n, n_genes) with:
X— z-scored log1p values, or log1p values whenstandardize=Falselayers["counts"]— raw integer UMI countslayers["lognorm"]— log1p of library-size-normalized countsobs["stage"]— ground-truth stage label per cellobs["stage_id"],obs["batch"],obs["size_factor"],obs["total_counts"]var["is_marker"],var["marker_stages"],var["n_marker_stages"],var["base_mean"]varm["marker_mask"]— (n_genes, stageno) ground-truth marker matrixuns["simulation"]— simulation parameters
- Raises:
ImportError – If anndata is not installed.
ValueError – If
target_sum <= 0or any parameter ofsim_scrnaseq_data()is out of range.
- Return type:
ad.AnnData
Examples
>>> from structboost import sim_scrnaseq_anndata >>> adata = sim_scrnaseq_anndata(n=100, n_genes=20, stageno=4, seed=0) >>> adata.obs["stage"].nunique() 4