Skip to content

Synthetic data

Data drawn on a known tree, so a reconstruction can be scored against the answer with robinson_foulds.

datasets

Synthetic data on a known tree, for testing and for the docs.

simulate

simulate(
    n_leaves: int = 64,
    n_features: int = 200,
    *,
    kind: Literal[
        "binary", "random_branches", "unbalanced"
    ] = "binary",
    branch_length: float = 1.0,
    noise_sd: float = 0.1,
    noise_spread: float = 2.0,
    seed: int = 0,
) -> SimulatedData

Brownian motion on a known tree, with per-cell per-feature error bars.

Parameters:

Name Type Description Default
n_leaves int

Cells. A power of two for "binary" and "random_branches".

64
n_features int

Features.

200
kind Literal['binary', 'random_branches', 'unbalanced']

"binary" (balanced, equal branches), "random_branches" (balanced, log-uniform branches on [0.5, 2]) or "unbalanced" (grown by splitting random leaves).

'binary'
branch_length float

Branch length. Ignored by "random_branches".

1.0
noise_sd float

Error-bar scale relative to the spread of the data.

0.1
noise_spread float

Each error bar is noise_sd times a log-uniform draw on [1 / noise_spread, noise_spread]. 1.0 is homoscedastic.

2.0
seed int

Seed.

0

Returns:

Type Description
SimulatedData

The tree and the data drawn on it.

simulate_counts

simulate_counts(
    n_leaves: int = 64,
    n_genes: int = 300,
    *,
    library_size: float = 3000.0,
    seed: int = 0,
) -> SimulatedCounts

UMI counts drawn on a known tree.

The noise-free leaf positions of simulate become log fold changes about a per-gene mean quotient, and counts are Poisson on top: count ~ Poisson(N_c * exp(log_q_g + x_gc)). Library sizes N_c are log-normal about library_size.

Parameters:

Name Type Description Default
n_leaves int

Cells, a power of two.

64
n_genes int

Genes.

300
library_size float

Median UMIs per cell.

3000.0
seed int

Seed for both the tree and the counts.

0

Returns:

Type Description
SimulatedCounts

The tree, the counts and the library sizes they were drawn with.