datasets.simulate_clustered

datasets.simulate_clustered(
    n_samples=8,
    n_per=80,
    n_genes=30,
    field=500,
    sd_lib_sample=0.15,
    sd_lib_celltype=0.35,
    sd_patient=0.7,
    sd_nested=0,
    seed=1,
)

Synthetic null with patient-level clustering.

Port of spiDE’s internal .toyClustered() (dropped from R in c8db60a; kept here). A per-(gene, sample) intercept is shared by every cell of a sample and there is no niche or condition effect; condition is a sample-level label, so a cell-level test is anti-conservative while a patient-level test stays calibrated. The generative model is R’s; the random draws are not (numpy vs Mersenne-Twister), and the global numpy RNG is not touched. obs has no Age.

Parameters

Name Type Description Default
n_samples int Number of samples; as in simulate_toy. 8
n_per int Cells per sample; as in simulate_toy. 80
n_genes int Number of genes; as in simulate_toy. 30
field float Side length of the square spatial field; as in simulate_toy. 500
sd_lib_sample float Log-scale SD of the sample-level library-size term; as in simulate_toy. 0.15
sd_lib_celltype float Log-scale SD of the cell-type-level library-size term; as in simulate_toy. 0.35
sd_patient float Planted between-sample intercept SD. 0.7
sd_nested float SD of an optional per-(gene, sample, cell type) intercept on top (drawn only if > 0). 0
seed int Seed of the numpy.random.default_rng used for every draw. 1

Returns

Name Type Description
anndata.AnnData As simulate_toy but obs has no Age column.

See Also

simulate_toy : The version with a planted effect.

Examples

from spidepy.datasets import simulate_clustered
adata = simulate_clustered(n_samples=4, n_per=50, n_genes=10, seed=1)
adata.shape
(200, 10)
"Age" in adata.obs.columns
False