Skip to content

Parameters

One frozen dataclass per parameter set, flat, the way Rust sees it. Grouped by the module that takes them; Shared goes to more than one.

Shared

Parameter bundles for the single cell suite.

One frozen dataclass per parameter bundle, flat as Rust sees them: ScrubletParams(no_pcs=10, k=0) rather than nested blocks. Field names match the keys the Rust structs deserialise; each bundle checks its ranges in __post_init__. ScenicParams sits in bixverse.params._scenic.

BbknnParams dataclass

BbknnParams(
    *,
    neighbours_within_batch: int = 3,
    set_op_mix_ratio: float = 1.0,
    local_connectivity: float = 1.0,
    trim: int | None = None,
    k: int | None = None,
    knn_method: Literal[
        "kmknn",
        "hnsw",
        "annoy",
        "nndescent",
        "ivf",
        "exhaustive",
    ] = "kmknn",
    ann_dist: Literal["euclidean", "cosine"] = "euclidean",
    n_trees: int = 50,
    search_budget: int | None = None,
    delta: float = 0.001,
    diversify_prob: float = 0.0,
    ef_budget: int | None = None,
    m: int = 16,
    ef_construction: int = 200,
    ef_search: int = 100,
    n_list: int | None = None,
    n_probe: int | None = None,
)

Wrapper function for the BBKNN parameters

Attributes:

Name Type Description
neighbours_within_batch int

Number of neighbours to consider per batch.

set_op_mix_ratio float

Mixing ratio between union (1.0) and intersection (0.0).

local_connectivity float

UMAP connectivity computation parameter, how many nearest neighbours of each cell are assumed to be fully connected.

trim int | None

Trim the neighbours of each cell to these many top connectivities. May help with population independence and improve the tidiness of clustering. If None, it defaults to 10 * neighbours_within_batch * n_batches, as in the reference implementation.

k int | None

Number of neighbours.

knn_method Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']

Which method to use for the approximate nearest neighbour search. "nndescent" hands back the graph the NN-Descent built, with no index and no query pass. Rows the descent left short are re-queried exactly.

ann_dist Literal['euclidean', 'cosine']

Which distance metric to use for the approximate nearest neighbour search.

n_trees int

Annoy param: number of trees to generate for Annoy.

search_budget int | None

Annoy param: optional search budget per tree for Annoy. If not provided, it will default to n_tree * k * 20.

delta float

NNDescent param: early termination criterium for NNDescent.

diversify_prob float

NNDescent param: diversification probability. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

ef_budget int | None

NNDescent param: optional query budget. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

m int

HNSW param: number of connections between layers for HNSW.

ef_construction int

HNSW param: size of dynamic candidate list during construction.

ef_search int

HNSW param: size of candidate list (higher = better recall, slower).

n_list int | None

IVF param: number of clusters/centroids to generate. None generates sqrt(n) lists.

n_probe int | None

IVF param: number of clusters/centroids to query. None queries sqrt(n_lists) clusters.

FastmnnParams dataclass

FastmnnParams(
    *,
    ndist: float = 3.0,
    cos_norm: bool = True,
    no_pcs: int = 30,
    sparse_svd: bool = True,
    k: int = 20,
    knn_method: Literal[
        "kmknn",
        "hnsw",
        "annoy",
        "nndescent",
        "ivf",
        "exhaustive",
    ] = "kmknn",
    ann_dist: Literal["euclidean", "cosine"] = "cosine",
    n_trees: int = 50,
    search_budget: int | None = None,
    delta: float = 0.001,
    diversify_prob: float = 0.0,
    ef_budget: int | None = None,
    m: int = 16,
    ef_construction: int = 200,
    ef_search: int = 100,
    n_list: int | None = None,
    n_probe: int | None = None,
    mean_center: bool = True,
    normalise_variance: bool = True,
    clr: bool = False,
    size_factor: float = 10000.0,
    svd_solver: Literal[
        "auto", "covariance", "randomised", "exact"
    ] = "auto",
)

Wrapper function for the fastMNN parameters

Attributes:

Name Type Description
ndist float

Number of median distances for the tricube kernel bandwidth.

cos_norm bool

Apply cosine normalisation before computing distances.

no_pcs int

Number of PCs to use for MNN calculations.

sparse_svd bool

Shall the sparse SVD be used.

k int

Number of neighbours.

knn_method Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']

Which method to use for the approximate nearest neighbour search. "nndescent" hands back the graph the NN-Descent built, with no index and no query pass. Rows the descent left short are re-queried exactly.

ann_dist Literal['euclidean', 'cosine']

Which distance metric to use for the approximate nearest neighbour search.

n_trees int

Annoy param: number of trees to generate for Annoy.

search_budget int | None

Annoy param: optional search budget per tree for Annoy. If not provided, it will default to n_tree * k * 20.

delta float

NNDescent param: early termination criterium for NNDescent.

diversify_prob float

NNDescent param: diversification probability. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

ef_budget int | None

NNDescent param: optional query budget. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

m int

HNSW param: number of connections between layers for HNSW.

ef_construction int

HNSW param: size of dynamic candidate list during construction.

ef_search int

HNSW param: size of candidate list (higher = better recall, slower).

n_list int | None

IVF param: number of clusters/centroids to generate. None generates sqrt(n) lists.

n_probe int | None

IVF param: number of clusters/centroids to query. None queries sqrt(n_lists) clusters.

mean_center bool

Shall the data be mean centred

normalise_variance bool

Shall the data have normalised variance

clr bool

Shall the CLR-type PFlogPF be applied, see Booeshaghi, et al.

size_factor float

The used size factor during I/O. It needs to be the same as during I/O to have correct results when using the PFlogPF transformation.

svd_solver Literal['auto', 'covariance', 'randomised', 'exact']

Which solver to use. "auto" takes Lanczos on the sparse path and "covariance" on the dense one, the fastest exact option on each. "covariance" builds the gene x gene cross-product and eigendecomposes it: its cost grows with the square of the gene number in memory and the cube in time. "randomised" is a randomised SVD, approximate in the trailing components. "exact" is a full SVD on the dense path and Lanczos on the sparse one.

HarmonyParams dataclass

HarmonyParams(
    *,
    k: int | None = None,
    sigma: tuple[float, ...] = (0.1,),
    theta: tuple[float, ...] = (2.0,),
    lambda_: tuple[float, ...] = (1.0,),
    block_size: float = 0.2,
    max_iter_kmeans: int = 20,
    max_iter_harmony: int = 10,
    epsilon_kmeans: float = 0.001,
    epsilon_harmony: float = 0.01,
    window_size: int = 3,
    k_means_iter: int = 10,
    k_means_algorithm: Literal[
        "emeans", "lloyd"
    ] = "emeans",
    e_means_epochs: float | None = None,
    k_means_init: Literal[
        "parallel", "random"
    ] = "parallel",
    gemm: bool | None = False,
    hamerly: bool | None = True,
)

Default parameters for Harmony batch correction

Attributes:

Name Type Description
k int | None

Number of clusters for k-means clustering. If not provided, it will be automatically determined as min(round(N / 30), 100).

sigma tuple[float, ...]

Per-cluster diversity weights. Either a single value (broadcast to all clusters) or a vector of length k.

theta tuple[float, ...]

Per-variable diversity penalties. Either a single value (broadcast to all variables) or a vector of length equal to the number of batch variables.

lambda_ tuple[float, ...]

Ridge regression penalty for the linear model. Typically a single value that is broadcast to every batch column of the design matrix; the intercept is not penalised.

block_size float

Fraction of cells to update per block during optimisation (0.0-1.0). Lower values reduce memory usage but increase computation time.

max_iter_kmeans int

Maximum number of k-means iterations per Harmony round.

max_iter_harmony int

Maximum number of Harmony outer iterations.

epsilon_kmeans float

Convergence threshold for k-means clustering. Stops when the relative change in cluster assignments falls below this value.

epsilon_harmony float

Convergence threshold for Harmony. Stops when the relative change in the objective function falls below this value.

window_size int

Number of previous iterations to consider when checking convergence.

k_means_algorithm Literal['emeans', 'lloyd']

"emeans" or "lloyd".

e_means_epochs float | None

e-means only. Passes over the data; None for the default.

k_means_iter int

Lloyd's only. The number of iterations to use for the clustering.

k_means_init Literal['parallel', 'random']

Lloyd's only. The initialisation.

gemm bool | None

Controls which CPU implementation is used by the method. GEMM is faster with large dimensionality.

hamerly bool | None

Shall a faster exact method be used leveraging the triangle inequality. Faster on large data sets with large numbers of centroids.

HarmonyV2Params dataclass

HarmonyV2Params(
    *,
    k: int | None = None,
    sigma: tuple[float, ...] = (0.1,),
    theta: tuple[float, ...] = (2.0,),
    lambda_: tuple[float, ...] = (1.0,),
    block_size: float = 0.05,
    max_iter_kmeans: int = 4,
    max_iter_harmony: int = 10,
    epsilon_kmeans: float = 0.001,
    epsilon_harmony: float = 0.01,
    window_size: int = 3,
    alpha: float = 0.2,
    tau: float = 0.0,
    batch_proportion_cutoff: float = 1e-05,
    use_dynamic_lambda: bool = True,
    k_means_iter: int = 10,
    k_means_algorithm: Literal[
        "emeans", "lloyd"
    ] = "emeans",
    e_means_epochs: float | None = None,
    k_means_init: Literal[
        "parallel", "random"
    ] = "parallel",
    gemm: bool | None = False,
    hamerly: bool | None = True,
)

Default parameters for Harmony v2 batch correction

Attributes:

Name Type Description
k int | None

Number of clusters for k-means clustering. If not provided, it will be automatically determined as min(round(N / 30), 100).

sigma tuple[float, ...]

Per-cluster diversity weights. Either a single value (broadcast to all clusters) or a vector of length k.

theta tuple[float, ...]

Per-variable diversity penalties. Either a single value (broadcast to all variables) or a vector of length equal to the number of batch variables.

lambda_ tuple[float, ...]

Ridge regression penalty for the linear model. Typically a single value that is broadcast to every batch column of the design matrix; the intercept is not penalised. Ignored when use_dynamic_lambda = True.

block_size float

Fraction of cells to update per block during optimisation (0.0-1.0). Lower values reduce memory usage but increase computation time.

max_iter_kmeans int

Maximum number of k-means iterations per Harmony round.

max_iter_harmony int

Maximum number of Harmony outer iterations.

epsilon_kmeans float

Convergence threshold for k-means clustering. Stops when the relative change in cluster assignments falls below this value.

epsilon_harmony float

Convergence threshold for Harmony. Stops when the relative change in the objective function falls below this value.

window_size int

Number of previous iterations to consider when checking convergence.

alpha float

Scaling factor for dynamic lambda estimation. Must be in (0, 1). Only relevant when use_dynamic_lambda = True.

tau float

Scaling factor for theta based on batch size. A value of 0 disables batch-size scaling of theta.

batch_proportion_cutoff float

Cutoff for pruning batches with small proportions during ridge regression.

use_dynamic_lambda bool

If True, lambda is estimated per cluster as alpha times the expected counts, as in Harmony v2, instead of using the fixed lambda value.

k_means_algorithm Literal['emeans', 'lloyd']

"emeans" or "lloyd".

e_means_epochs float | None

e-means only. Passes over the data; None for the default.

k_means_iter int

Lloyd's only. The number of iterations to use for the clustering.

k_means_init Literal['parallel', 'random']

Lloyd's only. The initialisation.

gemm bool | None

Controls which CPU implementation is used by the method. GEMM is faster with large dimensionality.

hamerly bool | None

Shall a faster exact method be used leveraging the triangle inequality. Faster on large data sets with large numbers of centroids.

HvgParams dataclass

HvgParams(
    *,
    method: Literal[
        "vst",
        "meanvarbin",
        "dispersion",
        "scran",
        "residual",
    ] = "vst",
    loess_span: float = 0.3,
    num_bin: int = 20,
    bin_method: Literal[
        "equal_width", "equal_freq"
    ] = "equal_width",
    mean_filter: bool = True,
    min_mean: float = 0.1,
    transform: bool = True,
    use_min_width: bool = False,
    min_width: float = 1.0,
    min_window_count: int = 200,
)

Wrapper function for HVG detection parameters.

Attributes:

Name Type Description
method Literal['vst', 'meanvarbin', 'dispersion', 'scran', 'residual']

"scran" fits a weighted lowess trend to the variance of the log- expression against its mean and ranks genes by the residual, as in scran's modelGeneVar(). "residual" ranks genes by the residual variance of a model fitted with fit_residuals(), and needs that fit on the object first. It also treats hvg_no as a per-group count and returns the union across groups, so a grouped fit can select more than hvg_no genes.

loess_span float

The span parameter for the loess function that is used to standardise the variance for method = "vst", and the lowess span of the trend for method = "scran".

num_bin int

Number of bins for the meanvarbin and dispersion methods.

bin_method Literal['equal_width', 'equal_freq']

The binning method.

mean_filter bool

Shall genes below min_mean be left out of the trend fit.

min_mean float

Minimum mean log-expression for a gene to enter the trend fit.

transform bool

Shall the variances be fourth-root transformed before the fit.

use_min_width bool

Shall the lowess window be defined by min_width and min_window_count instead of the span.

min_width float

Minimum window width, only used with use_min_width = True.

min_window_count int

Minimum number of genes per window, only used with use_min_width = True.

KnnParams dataclass

KnnParams(
    *,
    k: int = 15,
    knn_method: Literal[
        "kmknn",
        "hnsw",
        "annoy",
        "nndescent",
        "ivf",
        "exhaustive",
    ] = "kmknn",
    ann_dist: Literal["euclidean", "cosine"] = "euclidean",
    n_trees: int = 50,
    search_budget: int | None = None,
    delta: float = 0.001,
    diversify_prob: float = 0.0,
    ef_budget: int | None = None,
    m: int = 16,
    ef_construction: int = 200,
    ef_search: int = 100,
    n_list: int | None = None,
    n_probe: int | None = None,
)

Parameters for single cell kNN searches

Attributes:

Name Type Description
k int

Number of neighbours.

knn_method Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']

Which method to use for the approximate nearest neighbour search. "nndescent" hands back the graph the NN-Descent built, with no index and no query pass. Rows the descent left short are re-queried exactly.

ann_dist Literal['euclidean', 'cosine']

Distance metric to use.

n_trees int

Annoy param: number of trees.

search_budget int | None

Annoy param: optional search budget per tree. If None, defaults to n_trees * k * 20 internally.

delta float

NNDescent param: early termination criterion.

diversify_prob float

NNDescent param: diversification probability. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

ef_budget int | None

NNDescent param: optional query budget. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

m int

HNSW param: number of connections between layers.

ef_construction int

HNSW param: size of the dynamic candidate list during construction.

ef_search int

HNSW param: size of the candidate list at query time. Higher values improve recall at the cost of speed.

n_list int | None

IVF param: number of clusters to generate. If None, defaults to sqrt(n) internally.

n_probe int | None

IVF param: number of clusters to query. If None, defaults to sqrt(n_list) internally.

NeighboursParams dataclass

NeighboursParams(
    *,
    knn_sym: Literal["snn", "umap", "knn"] = "snn",
    snn_similarity: Literal["jaccard", "rank"] = "jaccard",
    pruning: float = 0.0625,
    rescue: bool = True,
    local_connectivity: float = 1.0,
    mix_ratio: float = 1.0,
    binary: bool = False,
    k: int = 15,
    knn_method: Literal[
        "kmknn",
        "hnsw",
        "annoy",
        "nndescent",
        "ivf",
        "exhaustive",
    ] = "kmknn",
    ann_dist: Literal["euclidean", "cosine"] = "euclidean",
    n_trees: int = 50,
    search_budget: int | None = None,
    delta: float = 0.001,
    diversify_prob: float = 0.0,
    ef_budget: int | None = None,
    m: int = 16,
    ef_construction: int = 200,
    ef_search: int = 100,
    n_list: int | None = None,
    n_probe: int | None = None,
)

Wrapper function for parameters for neighbour identification in single cell

Attributes:

Name Type Description
knn_sym Literal['snn', 'umap', 'knn']

How to symmetrise the kNN into a graph. Clustering resolutions do not carry over between the methods: the "umap" and "knn" graphs only hold kNN pairs, the sNN graph also links cells that share neighbours and prunes weak edges. The same resolution can give more or fewer communities depending on the data, so retune it when switching.

snn_similarity Literal['jaccard', 'rank']

"snn" only. "jaccard" weighs an edge by the Jaccard index of the two (self-inclusive) neighbour sets. "rank" takes the shared neighbour with the lowest combined rank, so closer shared neighbours give heavier edges. Both are scaled to [0, 1].

pruning float

"snn" only. Edges below this weight are dropped. For the Jaccard weight a threshold p keeps pairs that share at least a fraction 2p / (1 + p) of their (self-inclusive) neighbourhoods, rounded up to whole cells, so the same value means the same thing at any k. The default asks for about 12%, i.e. 2 of 16 shared cells at k = 15, in line with Seurat's 1/15. Avoid a threshold that equals one of the discrete weights exactly, or float rounding decides whether the edge survives.

rescue bool

"snn" only. Reconnect the small components that pruning cuts off via their strongest sNN edge, so they do not turn up as tiny clusters.

local_connectivity float

"umap" only. Number of nearest neighbours assumed to be fully connected, as in umap-learn.

mix_ratio float

"umap" only. 1 is the fuzzy union of the directed kNN memberships, 0 the fuzzy intersection (umap-learn's set_op_mix_ratio).

binary bool

"knn" only. If True, every edge weighs 1. Otherwise mutual neighbours weigh 2 and one-sided ones 1.

k int

Number of neighbours.

knn_method Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']

Which method to use for the approximate nearest neighbour search. "nndescent" hands back the graph the NN-Descent built, with no index and no query pass. Rows the descent left short are re-queried exactly.

ann_dist Literal['euclidean', 'cosine']

Which distance metric to use for the approximate nearest neighbour search.

n_trees int

Annoy param: number of trees to generate for Annoy.

search_budget int | None

Annoy param: optional search budget per tree for Annoy. If not provided, it will default to n_tree * k * 20.

delta float

NNDescent param: early termination criterium for NNDescent.

diversify_prob float

NNDescent param: diversification probability. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

ef_budget int | None

NNDescent param: optional query budget. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

m int

HNSW param: number of connections between layers for HNSW.

ef_construction int

HNSW param: size of dynamic candidate list during construction.

ef_search int

HNSW param: size of candidate list (higher = better recall, slower).

n_list int | None

IVF param: number of clusters/centroids to generate. None generates sqrt(n) lists.

n_probe int | None

IVF param: number of clusters/centroids to query. None queries sqrt(n_lists) clusters.

PcaParams dataclass

PcaParams(
    *,
    mean_center: bool = True,
    normalise_variance: bool = True,
    clr: bool = False,
    size_factor: float = 10000.0,
    svd_solver: Literal[
        "auto", "covariance", "randomised", "exact"
    ] = "auto",
)

Wrapper for PCA specifically designed for single cells

Attributes:

Name Type Description
mean_center bool

Shall the data be mean centred

normalise_variance bool

Shall the data have normalised variance

clr bool

Shall the CLR-type PFlogPF be applied, see Booeshaghi, et al.

size_factor float

The used size factor during I/O. It needs to be the same as during I/O to have correct results when using the PFlogPF transformation.

svd_solver Literal['auto', 'covariance', 'randomised', 'exact']

Which solver to use. "auto" takes Lanczos on the sparse path and "covariance" on the dense one, the fastest exact option on each. "covariance" builds the gene x gene cross-product and eigendecomposes it: its cost grows with the square of the gene number in memory and the cube in time. "randomised" is a randomised SVD, approximate in the trailing components. "exact" is a full SVD on the dense path and Lanczos on the sparse one.

WnnParams dataclass

WnnParams(
    *,
    k_nn: int = 20,
    knn_range: int = 200,
    sigma_method: Literal[
        "snn_farthest", "sigma_idx"
    ] = "snn_farthest",
    sigma_idx: int = 19,
    s_nn: int = 20,
    sd_scale: float = 1.0,
    kernel_power: float = 1.0,
    cross_const: float = 0.0001,
    sigma_floor: float = 1e-08,
    k: int = 15,
    knn_method: Literal[
        "kmknn",
        "hnsw",
        "annoy",
        "nndescent",
        "ivf",
        "exhaustive",
    ] = "kmknn",
    ann_dist: Literal["euclidean", "cosine"] = "euclidean",
    n_trees: int = 50,
    search_budget: int | None = None,
    delta: float = 0.001,
    diversify_prob: float = 0.0,
    ef_budget: int | None = None,
    m: int = 16,
    ef_construction: int = 200,
    ef_search: int = 100,
    n_list: int | None = None,
    n_probe: int | None = None,
)

Wrapper function for WNN parameters

Attributes:

Name Type Description
k_nn int

Final number of multimodal neighbours per cell.

knn_range int

Candidate pool size per modality. Each cell's kNN input must contain at least this many neighbours.

sigma_method Literal['snn_farthest', 'sigma_idx']

Bandwidth method.

sigma_idx int

"sigma_idx" only: 0-based kNN index for the bandwidth (i.e. k_nn - 1).

s_nn int

"snn_farthest" only: kNN size used to build the SNN graph.

sd_scale float

Multiplier on sigma.

kernel_power float

Kernel exponent power.

cross_const float

Cross-modality kernel stabiliser.

sigma_floor float

Minimum sigma value (avoids division by zero).

k int

Number of neighbours.

knn_method Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']

Which method to use for the approximate nearest neighbour search. "nndescent" hands back the graph the NN-Descent built, with no index and no query pass. Rows the descent left short are re-queried exactly.

ann_dist Literal['euclidean', 'cosine']

Which distance metric to use for the approximate nearest neighbour search.

n_trees int

Annoy param: number of trees to generate for Annoy.

search_budget int | None

Annoy param: optional search budget per tree for Annoy. If not provided, it will default to n_tree * k * 20.

delta float

NNDescent param: early termination criterium for NNDescent.

diversify_prob float

NNDescent param: diversification probability. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

ef_budget int | None

NNDescent param: optional query budget. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

m int

HNSW param: number of connections between layers for HNSW.

ef_construction int

HNSW param: size of dynamic candidate list during construction.

ef_search int

HNSW param: size of candidate list (higher = better recall, slower).

n_list int | None

IVF param: number of clusters/centroids to generate. None generates sqrt(n) lists.

n_probe int | None

IVF param: number of clusters/centroids to query. None queries sqrt(n_lists) clusters.

Input and output

Parameter bundles for the single cell suite.

One frozen dataclass per parameter bundle, flat as Rust sees them: ScrubletParams(no_pcs=10, k=0) rather than nested blocks. Field names match the keys the Rust structs deserialise; each bundle checks its ranges in __post_init__. ScenicParams sits in bixverse.params._scenic.

MtxIoParams dataclass

MtxIoParams(
    *,
    path_mtx: str,
    path_obs: str,
    path_var: str,
    cells_as_rows: bool,
    has_hdr: bool,
)

Wrapper function to provide data for mtx-based loading

Attributes:

Name Type Description
path_mtx str

Path to the .mtx or .mtx.gz file

path_obs str

Path to the file containing cell/barcode info.

path_var str

Path to the file containing gene/variable info.

cells_as_rows bool

Do cells represent the rows or columns.

has_hdr bool

Do the plain text files have headers.

SyntheticCellsweepParams dataclass

SyntheticCellsweepParams(
    *,
    n_real: int = 600,
    n_empty: int = 2000,
    n_genes: int = 200,
    n_celltypes: int = 3,
    n_markers: int = 20,
    marker_weight: float = 25.0,
    ambient_dominance: float = 0.6,
    alpha_mean: float = 0.3,
    alpha_sd: float = 0.12,
    real_lib_size: int = 3000,
    empty_lib_size: int = 120,
)

Default parameters for generation of synthetic CellSweep data

Shapes the fixture with a planted ambient profile that generate_cellsweep_test_data() builds. The defaults give 600 real barcodes over 3 cell types plus 2000 empty droplets, on 200 genes.

Attributes:

Name Type Description
n_real int

Number of real barcodes. Cell types are assigned round-robin over them.

n_empty int

Number of empty droplets. The ambient profile is estimated off these, so at least 30 and preferably a lot more.

n_genes int

Number of genes.

n_celltypes int

Number of cell types.

n_markers int

Width of each cell type's marker block. The blocks are contiguous and disjoint, so n_markers * n_celltypes has to fit into n_genes.

marker_weight float

Enrichment of a marker gene over background in its own cell type's profile. Must exceed 1.

ambient_dominance float

Fraction of the soup coming from the first cell type. The remainder is flat background.

alpha_mean float

Mean planted ambient fraction across real barcodes.

alpha_sd float

Spread of the planted ambient fraction.

real_lib_size int

Expected library size of a real barcode.

empty_lib_size int

Expected library size of an empty droplet.

SyntheticDataAdtParams dataclass

SyntheticDataAdtParams(
    *,
    n_cells: int = 1000,
    n_proteins: int = 15,
    n_batches: int = 1,
    marker_genes: dict[str, dict[str, list[int]]] = (
        lambda: {
            "cell_type_1": {"marker_genes": [0, 1, 2]},
            "cell_type_2": {"marker_genes": [3, 4, 5]},
            "cell_type_3": {"marker_genes": [6, 7, 8]},
        }
    )(),
    isotype_controls: tuple[int, ...] = (12, 13, 14),
    batch_effect_strength: Literal[
        "strong", "medium", "weak"
    ] = "strong",
)

Default parameters for generation of synthetic single cell data (ADT)

For the generation of synthetic single cell data mostly for testing or showcasing purposes. In this case, ADT counts to test multi-modal integration. The default configurations generates 1000 cells x 15 proteins with probes 1:3 being cell markers for cell type 1, genes 4:6 for cell type 2 and genes 7:9 for cell type. Columns 13:15 represents isotype controls.

Attributes:

Name Type Description
n_cells int

Number of cells.

n_proteins int

Number of proteins

n_batches int

Number of batches.

marker_genes dict[str, dict[str, list[int]]]

A nested list that indicates which gene indices are markers for which cell.

isotype_controls tuple[int, ...]

The columns that defines the isotype controls. (0-indexed!)

batch_effect_strength Literal['strong', 'medium', 'weak']

The strength of the batch effect to add.

SyntheticDataParams dataclass

SyntheticDataParams(
    *,
    n_cells: int = 1000,
    n_genes: int = 100,
    n_batches: int = 1,
    marker_genes: dict[str, dict[str, list[int]]] = (
        lambda: {
            "cell_type_1": {
                "marker_genes": [
                    0,
                    1,
                    2,
                    3,
                    4,
                    5,
                    6,
                    7,
                    8,
                    9,
                ]
            },
            "cell_type_2": {
                "marker_genes": [
                    10,
                    11,
                    12,
                    13,
                    14,
                    15,
                    16,
                    17,
                    18,
                    19,
                ]
            },
            "cell_type_3": {
                "marker_genes": [
                    20,
                    21,
                    22,
                    23,
                    24,
                    25,
                    26,
                    27,
                    28,
                    29,
                ]
            },
        }
    )(),
    batch_effect_strength: Literal[
        "strong", "medium", "weak"
    ] = "strong",
    n_samples: int | None = None,
    sample_bias: str | None = None,
)

Default parameters for generation of synthetic single cell data (RNA)

For the generation of synthetic single cell data mostly for testing or showcasing purposes. The default configurations generates 1000 cells x 100 genes with genes 1:10 being cell markers for cell type 1, genes 11:20 for cell type 2 and genes 21:30 for cell type.

Attributes:

Name Type Description
n_cells int

Number of cells.

n_genes int

Number of genes.

n_batches int

Number of batches.

marker_genes dict[str, dict[str, list[int]]]

A nested list that indicates which gene indices are markers for which cell.

batch_effect_strength Literal['strong', 'medium', 'weak']

The strength of the batch effect to add.

n_samples int | None

Shall sample membership be added to the synthetic data. If you want sample information you need to provide n_samples and sample_bias.

sample_bias str | None

One of c("even", "slightly_uneven", "very_uneven")

SyntheticDialogueParams dataclass

SyntheticDialogueParams(
    *,
    n_samples: int = 14,
    cells_per_sample: int = 25,
    n_cell_types: int = 3,
    n_features: int = 8,
    n_sample_features: int = 5,
    n_genes: int = 400,
    n_planted: int = 8,
)

Default parameters for generation of synthetic DIALOGUE data

Shapes the fixture with a planted multicellular programme that generate_dialogue_test_data() builds. The defaults give 14 samples x 25 cells x 3 cell types = 1050 cells over 400 genes.

Attributes:

Name Type Description
n_samples int

Samples the experiment spans. DIALOGUE needs at least 5.

cells_per_sample int

Cells per sample per cell type.

n_cell_types int

Number of cell types. Must be at least 2.

n_features int

Feature columns per cell type. Must be at least 2.

n_sample_features int

Feature columns carrying a per-sample component. The first of those is the shared programme, the rest are cell-type-specific nuisance; anything past this count is pure noise and exists so the ANOVA filter has something to reject.

n_genes int

Number of genes.

n_planted int

Planted genes per cell type. The blocks are contiguous, so n_planted * n_cell_types has to fit into n_genes.

Preprocessing

Parameter bundles for the single cell suite.

One frozen dataclass per parameter bundle, flat as Rust sees them: ScrubletParams(no_pcs=10, k=0) rather than nested blocks. Field names match the keys the Rust structs deserialise; each bundle checks its ranges in __post_init__. ScenicParams sits in bixverse.params._scenic.

AprParams dataclass

AprParams(
    *,
    theta: float = 100.0,
    min_cells: int = 5,
    clip_min: float | None = None,
    clip_max: float | None = None,
)

Wrapper function for analytic Pearson residual parameters

The closed-form alternative to scTransform: one shared dispersion instead of a fitted model per gene. Much cheaper, and on most data sets it ranks genes about as well.

Attributes:

Name Type Description
theta float

The shared negative binomial dispersion. Inf gives the Poisson limit.

min_cells int

Minimum number of cells a gene must be detected in to be retained. 0 keeps everything.

clip_min float | None

Lower residual clipping bound. None uses -sqrt(n_cells). Must be given together with clip_max.

clip_max float | None

Upper residual clipping bound. None uses sqrt(n_cells). Must be given together with clip_min.

HvgDefaults dataclass

HvgDefaults(
    *,
    min_gene_var_pctl: float = 0.7,
    hvg_method: Literal[
        "vst", "meanvarbin", "dispersion", "scran"
    ] = "vst",
    loess_span: float = 0.3,
    clip_max: float | None = None,
    n_bins: int = 20,
    binning_strategy: Literal[
        "equal_width", "equal_frequency"
    ] = "equal_width",
)

Helper function to generate HVG defaults

Attributes:

Name Type Description
min_gene_var_pctl float

Which percentile of the highly variable genes to include.

hvg_method Literal['vst', 'meanvarbin', 'dispersion', 'scran']

Which method to use to identify HVG. "scran" runs with the default trend parameters, see HvgScranDefaults.

loess_span float

In case of "vst" the span of the loess function.

clip_max float | None

The maximum clipping value (optional).

n_bins int

The number of bins to use for the "meanvarbin" and "dispersion" HVG detection.

binning_strategy Literal['equal_width', 'equal_frequency']

Which binning strategy to use for "meanvarbin" and "dispersion".

HvgScranDefaults dataclass

HvgScranDefaults(
    *,
    mean_filter: bool = True,
    min_mean: float = 0.1,
    transform: bool = True,
    use_min_width: bool = False,
    min_width: float = 1.0,
    min_window_count: int = 200,
)

Helper function to generate the scran HVG trend defaults

Trend parameters for method = "scran" in HvgParams. They mirror scrapper's fitVarianceTrend() defaults before scrapper 1.8, which switched use.min.width to True. The lowess span comes from loess_span in HvgParams.

Attributes:

Name Type Description
mean_filter bool

Shall genes below min_mean be left out of the trend fit.

min_mean float

Minimum mean log-expression for a gene to enter the trend fit.

transform bool

Shall the variances be fourth-root transformed before the fit.

use_min_width bool

Shall the lowess window be defined by min_width and min_window_count instead of the span.

min_width float

Minimum window width, only used with use_min_width = True.

min_window_count int

Minimum number of genes per window, only used with use_min_width = True.

MagicParams dataclass

MagicParams(
    *,
    n_steps: int = 3,
    clip_threshold: float = 0.01,
    gene_batch_size: int = 1000,
    layer: Literal["norm", "raw"] = "norm",
    allow_large: bool = False,
)

Wrapper function for MAGIC imputation parameters

Parameters controlling the MAGIC imputation run by run_magic(). The defaults mirror the reference implementation.

Attributes:

Name Type Description
n_steps int

Diffusion steps applied to the counts. Zero is legal and hands back the un-imputed values, which is a cheap way to compare the two.

clip_threshold float

Imputed values below this are zeroed after the last step.

gene_batch_size int

Genes streamed off the binary store per block. Bounds the scratch memory and is clamped to the number of requested genes.

layer Literal['norm', 'raw']

Which stored layer to impute. The operator preserves per-cell mass, so imputed values sit on the scale of whatever went in: imputing raw counts and imputing log-normalised counts are different operations rather than the same one rescaled.

allow_large bool

Skip the output size guard. The dense output is capped at 1e9 elements, i.e. 4 GB of f32.

PcaDefaults dataclass

PcaDefaults(
    *,
    no_pcs: int = 30,
    svd_solver: Literal[
        "randomised", "auto", "covariance", "exact"
    ] = "randomised",
)

Helper function to generate default parameters for PCA

Attributes:

Name Type Description
no_pcs int

Number of PCs to consider.

svd_solver Literal['randomised', 'auto', 'covariance', 'exact']

Which solver to use. "randomised" (default) is a randomised SVD, approximate in the trailing components. "covariance" builds the gene x gene cross-product and eigendecomposes it. "auto" takes Lanczos on the sparse path and "covariance" on the dense one. "exact" is Lanczos on the sparse path and a full SVD on the dense one. See PcaParams for the trade-offs.

SctransformParams dataclass

SctransformParams(
    *,
    n_genes: int = 2000,
    n_cells: int = 2000,
    min_cells: int = 5,
    bw_adjust: float = 3.0,
    gmean_eps: float = 1.0,
    outlier_th: float = 10.0,
    poisson_diff_theta: float = 0.001,
    clip_min: float | None = None,
    clip_max: float | None = None,
)

Wrapper function for scTransform (v2) parameters

Defaults are sctransform's own with vst.flavor = "v2" applied. Only the step-1 fit scales with n_genes and n_cells: those bound the subsample the negative binomial models are fitted on, and every later pass streams gene by gene. Raising them costs fitting time, not memory.

Attributes:

Name Type Description
n_genes int

Genes in the step-1 subsample.

n_cells int

Cells in the step-1 subsample.

min_cells int

Minimum number of cells a gene must be detected in to be modelled.

bw_adjust float

Bandwidth multiplier for the kernel regression that regularises the parameters.

gmean_eps float

Offset in the geometric mean.

outlier_th float

Threshold, in median absolute deviations, past which a step-1 fit is treated as an outlier.

poisson_diff_theta float

Below this, the fitted dispersion is taken as the Poisson limit.

clip_min float | None

Lower residual clipping bound. None uses -sqrt(n_cells). Must be given together with clip_max.

clip_max float | None

Upper residual clipping bound. None uses sqrt(n_cells). Must be given together with clip_min.

Neighbours and clusters

Parameter bundles for the single cell suite.

One frozen dataclass per parameter bundle, flat as Rust sees them: ScrubletParams(no_pcs=10, k=0) rather than nested blocks. Field names match the keys the Rust structs deserialise; each bundle checks its ranges in __post_init__. ScenicParams sits in bixverse.params._scenic.

FastClusterParams dataclass

FastClusterParams(
    *,
    n_centroids: int | None = None,
    km_type: Literal[
        "emeans", "standard", "minibatch"
    ] = "emeans",
    e_means_epochs: float | None = None,
    k_means_iter: int = 100,
    batch_size: int = 4096,
    drift_threshold: float = 0.0001,
    lr_alpha: float = 1.0,
    dist: Literal["euclidean", "cosine"] = "euclidean",
    cell_mediated: bool = False,
    n_anchors: int = 5,
    centroid_k: int = 15,
    knn_sym: Literal["snn", "umap", "knn"] = "snn",
    snn_similarity: Literal["jaccard", "rank"] = "jaccard",
    pruning: float = 0.0625,
    rescue: bool = True,
    local_connectivity: float = 1.0,
    mix_ratio: float = 1.0,
    binary: bool = False,
    algorithm: Literal["louvain", "leiden"] = "louvain",
    n_iterations: int | None = None,
    beta: float = 0.01,
    min_gain: float = 0.0,
    local_moving: Literal["queue", "coloured"]
    | None = None,
    node_order: Literal["bfs", "shuffle"] | None = None,
    multi_level: bool = True,
    max_evals: int = 10,
)

Fast single cell clustering parameters

Fast clustering coarsens the cells with k-means, builds a graph over the centroids and runs Louvain or Leiden on it. The community of each centroid is handed back to its cells.

Attributes:

Name Type Description
n_centroids int | None

Number of k-means centroids. If None, defaults to floor(4 * sqrt(n_cells)).

km_type Literal['emeans', 'standard', 'minibatch']

Which k-means to run for the coarsening: "emeans", "standard" (Lloyd's) or "minibatch".

e_means_epochs float | None

km_type = "emeans" only. Passes over the data; None for the default.

k_means_iter int

Number of k-means iterations. Ignored by e-means.

batch_size int

km_type = "minibatch" only. Batch size.

drift_threshold float

km_type = "minibatch" only. The mini batch k-means stops once the centroid drift falls below this.

lr_alpha float

km_type = "minibatch" only. Learning rate alpha.

dist Literal['euclidean', 'cosine']

Distance for the k-means and the centroid graph.

cell_mediated bool

Shall the cell-mediated centroid graph from Secuer be built instead of the kNN graph on the centroids. Centroids are then linked by the cells that sit near both, so two centroids that are close in space but have no cells between them stay apart. If True, centroid_k and centroid_graph are ignored.

n_anchors int

Number of nearest centroids each cell links to in the cell- mediated graph. Only used if cell_mediated = True.

centroid_k int

Neighbours per centroid in the exact centroid kNN. Only used if cell_mediated = False.

knn_sym Literal['snn', 'umap', 'knn']

How to symmetrise the kNN into a graph. Clustering resolutions do not carry over between the methods: the "umap" and "knn" graphs only hold kNN pairs, the sNN graph also links cells that share neighbours and prunes weak edges. The same resolution can give more or fewer communities depending on the data, so retune it when switching.

snn_similarity Literal['jaccard', 'rank']

"snn" only. "jaccard" weighs an edge by the Jaccard index of the two (self-inclusive) neighbour sets. "rank" takes the shared neighbour with the lowest combined rank, so closer shared neighbours give heavier edges. Both are scaled to [0, 1].

pruning float

"snn" only. Edges below this weight are dropped. For the Jaccard weight a threshold p keeps pairs that share at least a fraction 2p / (1 + p) of their (self-inclusive) neighbourhoods, rounded up to whole cells, so the same value means the same thing at any k. The default asks for about 12%, i.e. 2 of 16 shared cells at k = 15, in line with Seurat's 1/15. Avoid a threshold that equals one of the discrete weights exactly, or float rounding decides whether the edge survives.

rescue bool

"snn" only. Reconnect the small components that pruning cuts off via their strongest sNN edge, so they do not turn up as tiny clusters.

local_connectivity float

"umap" only. Number of nearest neighbours assumed to be fully connected, as in umap-learn.

mix_ratio float

"umap" only. 1 is the fuzzy union of the directed kNN memberships, 0 the fuzzy intersection (umap-learn's set_op_mix_ratio).

binary bool

"knn" only. If True, every edge weighs 1. Otherwise mutual neighbours weigh 2 and one-sided ones 1.

algorithm Literal['louvain', 'leiden']

Community detection on the centroid graph.

n_iterations int | None

Number of iterations of the community detection. A negative value iterates until stable. If None, 2.

beta float

Leiden only. Randomness of the refinement step.

min_gain float

With a negative n_iterations, also stop once an iteration gains no more than this in modularity.

local_moving Literal['queue', 'coloured'] | None

"queue" is Traag's sequential queue. "coloured" moves the nodes of one colour class in parallel, which only kicks in on larger levels of the graph. None is "queue" for Leiden and "coloured" for Louvain.

node_order Literal['bfs', 'shuffle'] | None

Visit order of the queue, "bfs" (sweep in BFS order from a random start) or "shuffle" (as igraph). None is "bfs" for Leiden and "shuffle" for Louvain.

multi_level bool

Shall the communities be aggregated and refined in levels.

max_evals int

Cap on the node evaluations per local moving phase, in units of the number of nodes.

Batch correction

Parameter bundles for the single cell suite.

One frozen dataclass per parameter bundle, flat as Rust sees them: ScrubletParams(no_pcs=10, k=0) rather than nested blocks. Field names match the keys the Rust structs deserialise; each bundle checks its ranges in __post_init__. ScenicParams sits in bixverse.params._scenic.

SeuratCcaParams dataclass

SeuratCcaParams(
    *,
    num_cc: int = 30,
    dims: int = 30,
    k_anchor: int = 5,
    k_filter: int = 200,
    k_score: int = 30,
    k_weight: int = 100,
    n_top_features: int = 200,
    l2_norm: bool = True,
    sd: float = 1.0,
    k: int = 15,
    knn_method: Literal[
        "kmknn",
        "hnsw",
        "annoy",
        "nndescent",
        "ivf",
        "exhaustive",
    ] = "kmknn",
    ann_dist: Literal["euclidean", "cosine"] = "cosine",
    n_trees: int = 50,
    search_budget: int | None = None,
    delta: float = 0.001,
    diversify_prob: float = 0.0,
    ef_budget: int | None = None,
    m: int = 16,
    ef_construction: int = 200,
    ef_search: int = 100,
    n_list: int | None = None,
    n_probe: int | None = None,
    mean_center: bool = True,
    normalise_variance: bool = True,
    clr: bool = False,
    size_factor: float = 10000.0,
    svd_solver: Literal[
        "auto", "covariance", "randomised", "exact"
    ] = "auto",
)

Wrapper function for the Seurat CCA parameters

Attributes:

Name Type Description
num_cc int

Number of canonical correlation dimensions to compute for the anchor space. The effective rank used is max(num_cc, dims).

dims int

Number of dimensions used for the anchor kNN queries and the size of the returned embedding.

k_anchor int

Neighbourhood size for the mutual nearest neighbour anchor search.

k_filter int

Neighbourhood size for the gene-space anchor filter.

k_score int

Neighbourhood size for the shared-neighbour anchor scoring.

k_weight int

Neighbourhood size for the kernel weights applied during the correction.

n_top_features int

Number of top-loading genes used for the gene-space anchor filter.

l2_norm bool

Shall the canonical correlation embedding be L2-normalised per cell.

sd float

Bandwidth divisor of the Gaussian kernel used for the anchor weights.

k int

Number of neighbours.

knn_method Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']

Which method to use for the approximate nearest neighbour search. "nndescent" hands back the graph the NN-Descent built, with no index and no query pass. Rows the descent left short are re-queried exactly.

ann_dist Literal['euclidean', 'cosine']

Which distance metric to use for the approximate nearest neighbour search.

n_trees int

Annoy param: number of trees to generate for Annoy.

search_budget int | None

Annoy param: optional search budget per tree for Annoy. If not provided, it will default to n_tree * k * 20.

delta float

NNDescent param: early termination criterium for NNDescent.

diversify_prob float

NNDescent param: diversification probability. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

ef_budget int | None

NNDescent param: optional query budget. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

m int

HNSW param: number of connections between layers for HNSW.

ef_construction int

HNSW param: size of dynamic candidate list during construction.

ef_search int

HNSW param: size of candidate list (higher = better recall, slower).

n_list int | None

IVF param: number of clusters/centroids to generate. None generates sqrt(n) lists.

n_probe int | None

IVF param: number of clusters/centroids to query. None queries sqrt(n_lists) clusters.

mean_center bool

Shall the data be mean centred

normalise_variance bool

Shall the data have normalised variance

clr bool

Shall the CLR-type PFlogPF be applied, see Booeshaghi, et al.

size_factor float

The used size factor during I/O. It needs to be the same as during I/O to have correct results when using the PFlogPF transformation.

svd_solver Literal['auto', 'covariance', 'randomised', 'exact']

Which solver to use. "auto" takes Lanczos on the sparse path and "covariance" on the dense one, the fastest exact option on each. "covariance" builds the gene x gene cross-product and eigendecomposes it: its cost grows with the square of the gene number in memory and the cube in time. "randomised" is a randomised SVD, approximate in the trailing components. "exact" is a full SVD on the dense path and Lanczos on the sparse one.

SeuratRpcaParams dataclass

SeuratRpcaParams(
    *,
    dims: int = 30,
    k_anchor: int = 5,
    k_score: int = 30,
    k_weight: int = 100,
    l2_norm: bool = True,
    sd: float = 1.0,
    k: int = 15,
    knn_method: Literal[
        "kmknn",
        "hnsw",
        "annoy",
        "nndescent",
        "ivf",
        "exhaustive",
    ] = "kmknn",
    ann_dist: Literal["euclidean", "cosine"] = "cosine",
    n_trees: int = 50,
    search_budget: int | None = None,
    delta: float = 0.001,
    diversify_prob: float = 0.0,
    ef_budget: int | None = None,
    m: int = 16,
    ef_construction: int = 200,
    ef_search: int = 100,
    n_list: int | None = None,
    n_probe: int | None = None,
    mean_center: bool = True,
    normalise_variance: bool = True,
    clr: bool = False,
    size_factor: float = 10000.0,
    svd_solver: Literal[
        "auto", "covariance", "randomised", "exact"
    ] = "auto",
)

Wrapper function for the Seurat rPCA parameters

Attributes:

Name Type Description
dims int

Number of dimensions used for the per-batch PCA projections, the anchor kNN queries and the size of the returned embedding.

k_anchor int

Neighbourhood size for the mutual nearest neighbour anchor search.

k_score int

Neighbourhood size for the shared-neighbour anchor scoring.

k_weight int

Neighbourhood size for the kernel weights applied during the correction.

l2_norm bool

Shall the projected embeddings be L2-normalised per cell.

sd float

Bandwidth divisor of the Gaussian kernel used for the anchor weights.

k int

Number of neighbours.

knn_method Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']

Which method to use for the approximate nearest neighbour search. "nndescent" hands back the graph the NN-Descent built, with no index and no query pass. Rows the descent left short are re-queried exactly.

ann_dist Literal['euclidean', 'cosine']

Which distance metric to use for the approximate nearest neighbour search.

n_trees int

Annoy param: number of trees to generate for Annoy.

search_budget int | None

Annoy param: optional search budget per tree for Annoy. If not provided, it will default to n_tree * k * 20.

delta float

NNDescent param: early termination criterium for NNDescent.

diversify_prob float

NNDescent param: diversification probability. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

ef_budget int | None

NNDescent param: optional query budget. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

m int

HNSW param: number of connections between layers for HNSW.

ef_construction int

HNSW param: size of dynamic candidate list during construction.

ef_search int

HNSW param: size of candidate list (higher = better recall, slower).

n_list int | None

IVF param: number of clusters/centroids to generate. None generates sqrt(n) lists.

n_probe int | None

IVF param: number of clusters/centroids to query. None queries sqrt(n_lists) clusters.

mean_center bool

Shall the data be mean centred

normalise_variance bool

Shall the data have normalised variance

clr bool

Shall the CLR-type PFlogPF be applied, see Booeshaghi, et al.

size_factor float

The used size factor during I/O. It needs to be the same as during I/O to have correct results when using the PFlogPF transformation.

svd_solver Literal['auto', 'covariance', 'randomised', 'exact']

Which solver to use. "auto" takes Lanczos on the sparse path and "covariance" on the dense one, the fastest exact option on each. "covariance" builds the gene x gene cross-product and eigendecomposes it: its cost grows with the square of the gene number in memory and the cube in time. "randomised" is a randomised SVD, approximate in the trailing components. "exact" is a full SVD on the dense path and Lanczos on the sparse one.

Doublets and ambient RNA

Parameter bundles for the single cell suite.

One frozen dataclass per parameter bundle, flat as Rust sees them: ScrubletParams(no_pcs=10, k=0) rather than nested blocks. Field names match the keys the Rust structs deserialise; each bundle checks its ranges in __post_init__. ScenicParams sits in bixverse.params._scenic.

BoostParams dataclass

BoostParams(
    *,
    boost_rate: float = 0.25,
    replace: bool = False,
    resolution: float = 1.0,
    n_iters: int = 20,
    p_thresh: float = 1e-07,
    voter_thresh: float = 0.9,
    fast_cluster: bool = False,
    log_transform: bool = True,
    mean_center: bool = False,
    normalise_variance: bool = False,
    target_size: float = 1000000.0,
    min_gene_var_pctl: float = 0.7,
    hvg_method: Literal[
        "vst", "meanvarbin", "dispersion", "scran"
    ] = "vst",
    loess_span: float = 0.3,
    clip_max: float | None = None,
    n_bins: int = 20,
    binning_strategy: Literal[
        "equal_width", "equal_frequency"
    ] = "equal_width",
    no_pcs: int = 30,
    svd_solver: Literal[
        "randomised", "auto", "covariance", "exact"
    ] = "randomised",
    k: int = 0,
    knn_method: Literal[
        "kmknn",
        "hnsw",
        "annoy",
        "nndescent",
        "ivf",
        "exhaustive",
    ] = "kmknn",
    ann_dist: Literal["euclidean", "cosine"] = "euclidean",
    n_trees: int = 50,
    search_budget: int | None = None,
    delta: float = 0.001,
    diversify_prob: float = 0.0,
    ef_budget: int | None = None,
    m: int = 16,
    ef_construction: int = 200,
    ef_search: int = 100,
    n_list: int | None = None,
    n_probe: int | None = None,
    km_type: Literal[
        "emeans", "standard", "minibatch"
    ] = "emeans",
    e_means_epochs: float | None = None,
    n_centroids: int | None = None,
    k_means_iter: int = 100,
    batch_size: int = 4098,
)

Wrapper function for Boost parameters

Attributes:

Name Type Description
boost_rate float

Boosting rate for the algorithm. Must be between 0 and 1.

replace bool

Whether to use replacement during boosting.

resolution float

Resolution parameter for graph-based clustering. Higher values lead to more clusters.

n_iters int

Number of iterations to run the algorithm.

p_thresh float

P-value threshold for significance testing.

voter_thresh float

Voter threshold across iterations. Proportion of iterations a cell must be assigned to a cluster to be considered a member. Must be between 0 and 1.

fast_cluster bool

Shall fast Louvain clustering be applied, i.e., k-means clustering and use the centroids for kNN graph generation and Louvain clustering with then backpropagating the membership based on centroid proximity.

log_transform bool

Shall the counts be log-normalised.

mean_center bool

Shall mean centring be applied.

normalise_variance bool

Shall the variance be normalised.

target_size float

Target library size.

min_gene_var_pctl float

Which percentile of the highly variable genes to include.

hvg_method Literal['vst', 'meanvarbin', 'dispersion', 'scran']

Which method to use to identify HVG. "scran" runs with the default trend parameters, see HvgScranDefaults.

loess_span float

In case of "vst" the span of the loess function.

clip_max float | None

The maximum clipping value (optional).

n_bins int

The number of bins to use for the "meanvarbin" and "dispersion" HVG detection.

binning_strategy Literal['equal_width', 'equal_frequency']

Which binning strategy to use for "meanvarbin" and "dispersion".

no_pcs int

Number of PCs to consider.

svd_solver Literal['randomised', 'auto', 'covariance', 'exact']

Which solver to use. "randomised" (default) is a randomised SVD, approximate in the trailing components. "covariance" builds the gene x gene cross-product and eigendecomposes it. "auto" takes Lanczos on the sparse path and "covariance" on the dense one. "exact" is Lanczos on the sparse path and a full SVD on the dense one. See PcaParams for the trade-offs.

k int

Number of neighbours.

knn_method Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']

Which method to use for the approximate nearest neighbour search. "nndescent" hands back the graph the NN-Descent built, with no index and no query pass. Rows the descent left short are re-queried exactly.

ann_dist Literal['euclidean', 'cosine']

Which distance metric to use for the approximate nearest neighbour search.

n_trees int

Annoy param: number of trees to generate for Annoy.

search_budget int | None

Annoy param: optional search budget per tree for Annoy. If not provided, it will default to n_tree * k * 20.

delta float

NNDescent param: early termination criterium for NNDescent.

diversify_prob float

NNDescent param: diversification probability. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

ef_budget int | None

NNDescent param: optional query budget. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

m int

HNSW param: number of connections between layers for HNSW.

ef_construction int

HNSW param: size of dynamic candidate list during construction.

ef_search int

HNSW param: size of candidate list (higher = better recall, slower).

n_list int | None

IVF param: number of clusters/centroids to generate. None generates sqrt(n) lists.

n_probe int | None

IVF param: number of clusters/centroids to query. None queries sqrt(n_lists) clusters.

km_type Literal['emeans', 'standard', 'minibatch']

The k-means of the fast clustering: "emeans", "standard" (Lloyd's) or "minibatch".

e_means_epochs float | None

km_type = "emeans" only. Passes over the data; None for the default.

n_centroids int | None

The number of centroids to use. None uses sqrt(N_cells) * 4 centroids.

k_means_iter int

Number of maximum k-means iterations. Ignored by e-means.

batch_size int

Max batch size, capped at N_cells / 2 depending on the data set.

CellsweepParams dataclass

CellsweepParams(
    *,
    freeze_empties: bool = True,
    freeze_ambient_profile: bool = True,
    init_alpha: float = 0.9,
    init_beta: float = 0.1,
    alpha_cap: float = 0.9,
    repulsion_strength: float = 0.0001,
    max_frac_gene_repulsion: float = 0.2,
    celltype_lambda: float = 50.0,
    ambient_lambda: float = 50.0,
    bulk_lambda: float = 10.0,
    eps: float = 1e-12,
    log_eps: float = 9.999999999999994e-301,
    max_iter: int = 2000,
    del0_ll_tol: float = 0.001,
    min_ll_tol: float = 1e-06,
    tol_p: float = 0.0001,
    tol_f: float = 0.0001,
    norm_from_rounded: bool = False,
    seed: int = 42,
)

Default parameters for CellSweep denoising

Mirrors the CellSweep reference implementation's defaults. The pseudocounts (celltype_lambda, ambient_lambda, bulk_lambda) are given on the scale you see here and divided by the gene count internally. Two of these are worth knowing about before you touch anything else. freeze_ambient_profile = True keeps the ambient profile at its empty-droplet estimate, which is the recommended path and the only one where alpha_cap, the repulsion terms and cell-type reassignment are live. And freeze_empties only accepts True: the reference gives empty droplets a cell-type component they have no label for, which indexes past the end of the profile matrix and wraps onto the last cell type.

Attributes:

Name Type Description
freeze_empties bool

Keep the contamination fraction of empty droplets pinned at 1. Only True is supported, see the description.

freeze_ambient_profile bool

Keep the ambient profile at its empty-droplet estimate rather than re-estimating it as a mixture over the cell-type profiles.

init_alpha float

Starting ambient fraction for every real barcode. With freeze_ambient_profile = True the final result barely depends on it, so it sits at alpha_cap.

init_beta float

Starting bulk contamination fraction. Set below init_alpha on purpose: bulk and ambient are not fully separable, so this biases unassignable contamination towards ambient.

alpha_cap float

Ceiling on the per-cell ambient fraction before the log- likelihood converges. Barcodes wanting to exceed it are excluded from the cell-type profile update and allowed to switch cell type.

repulsion_strength float

Strength of the repulsion pushing cell-type profiles away from the ambient profile. Scales with cluster mass, so it is inert on small data and only bites at realistic cell counts.

max_frac_gene_repulsion float

Ceiling on the fraction of any single profile entry that repulsion may remove.

celltype_lambda float

Pseudocount smoothing the cell-type profile update. Higher values give smoother profiles.

ambient_lambda float

Pseudocount smoothing the ambient profile estimate.

bulk_lambda float

Pseudocount smoothing the bulk profile estimate.

eps float

Floor on denominators.

log_eps float

Floor on the argument of log.

max_iter int

Hard cap on EM iterations.

del0_ll_tol float

Log-likelihood change, as a fraction of the first EM step's change, below which stage one ends and parameter convergence starts being checked.

min_ll_tol float

Floor on the adaptive tolerance, relative to the current log- likelihood. Stops del0_ll_tol chasing floating point noise.

tol_p float

Convergence threshold on the maximum row-wise L1 change in the cell- type profiles.

tol_f float

Convergence threshold on the change in the total contamination fraction.

norm_from_rounded bool

Derive the normalised layer from the integerised counts rather than the denoised floats. Consistent across the two layers at the cost of the sub-integer signal, which is where CellSweep is most informative.

seed int

Seed for the stochastic rounding of the denoised counts.

EmptyDropletsParams dataclass

EmptyDropletsParams(
    *,
    method: Literal[
        "supplied", "umi_cutoff", "expected_cells", "knee"
    ] = "supplied",
    is_empty_column: str | None = "is_empty",
    umi_cutoff: int | None = None,
    expected_cells: int | None = None,
)

Parameters for identifying empty droplets

CellSweep trains its ambient profile on the empty droplets, so it needs them called before it runs. Four ways to do that, in descending order of how much you should trust them. "supplied" takes an existing logical column from the obs table. This is the common case: if you have CellRanger's filtered barcode list you already know which barcodes are empty, and nothing here will beat that. "umi_cutoff" calls everything below an absolute library size empty. "expected_cells" turns a cell count into that cutoff via the sorted library sizes. "knee" finds the cutoff from the curvature of the rank / log-count curve; it is experimental in the reference too, and smoothing puts the curvature minimum a few ranks ahead of the actual cliff, so it sweeps up the real barcodes nearest the transition.

Attributes:

Name Type Description
method Literal['supplied', 'umi_cutoff', 'expected_cells', 'knee']

How the empty droplets are called, see the description.

is_empty_column str | None

Name of the logical obs column holding the mask, True for an empty droplet. Used by method = "supplied", ignored otherwise.

umi_cutoff int | None

Barcodes with a library size strictly below this are empty. Required for method = "umi_cutoff", ignored otherwise.

expected_cells int | None

Number of real cells expected in the run. Required for method = "expected_cells", ignored otherwise.

MinQualityParams dataclass

MinQualityParams(
    *,
    min_unique_genes: int = 100,
    min_lib_size: int = 250,
    min_cells: int = 10,
    target_size: float = 10000.0,
)

Wrapper function to generate QC metric params for single cell

Attributes:

Name Type Description
min_unique_genes int

Minimum number of unique genes per cell/spot to be included.

min_lib_size int

Minimum library size per cell/spot to be included.

min_cells int

Minimum number of cells a gene has to be expressed to be included.

target_size float

The target size for the normalisation.

NormDoubletsDefaults dataclass

NormDoubletsDefaults(
    *,
    log_transform: bool = True,
    mean_center: bool = False,
    normalise_variance: bool = False,
    target_size: float = 1000000.0,
)

Helper function to generate normalisation defaults for doublet detection.

Attributes:

Name Type Description
log_transform bool

Shall the counts be log-normalised.

mean_center bool

Shall mean centring be applied.

normalise_variance bool

Shall the variance be normalised.

target_size float

Target library size.

ScdblfinderParams dataclass

ScdblfinderParams(
    *,
    n_genes: int = 1352,
    doublet_ratio: float = 1.0,
    heterotypic_bias: float = 1.0,
    cluster_resolution: float = 1.0,
    cluster_iters: int = 10,
    fast_cluster: bool = False,
    n_iterations: int = 3,
    gbm_n_trees: int = 200,
    max_depth: int = 4,
    learning_rate: float = 0.3,
    min_samples_leaf: int = 20,
    subsample_rate: float = 0.75,
    cv_folds: int = 5,
    cv_early_stop: int = 2,
    se_fraction: float = 1.0,
    include_pcs: int = 19,
    expected_doublet_rate: float | None = None,
    cxds_genes: int | None = None,
    manual_threshold: float | None = None,
    log_transform: bool = True,
    mean_center: bool = True,
    normalise_variance: bool = False,
    target_size: float = 1000000.0,
    no_pcs: int = 30,
    svd_solver: Literal[
        "randomised", "auto", "covariance", "exact"
    ] = "randomised",
    k: int = 0,
    knn_method: Literal[
        "kmknn",
        "hnsw",
        "annoy",
        "nndescent",
        "ivf",
        "exhaustive",
    ] = "kmknn",
    ann_dist: Literal["euclidean", "cosine"] = "euclidean",
    n_trees: int = 50,
    search_budget: int | None = None,
    delta: float = 0.001,
    diversify_prob: float = 0.0,
    ef_budget: int | None = None,
    m: int = 16,
    ef_construction: int = 200,
    ef_search: int = 100,
    n_list: int | None = None,
    n_probe: int | None = None,
    km_type: Literal[
        "emeans", "standard", "minibatch"
    ] = "emeans",
    e_means_epochs: float | None = None,
    n_centroids: int | None = None,
    k_means_iter: int = 100,
    batch_size: int = 4098,
)

Wrapper function for scDblFinder doublet detection parameters

Constructor for the scDblFinder parameters. This method combines cluster-aware doublet simulation with a gradient-boosted classifier trained on engineered features.

Attributes:

Name Type Description
n_genes int

Number of top-expressed genes to use as features.

doublet_ratio float

Ratio of simulated doublets to observed cells.

heterotypic_bias float

Fraction of simulated pairs forced to come from different clusters (0-1).

cluster_resolution float

Resolution for the initial Louvain clustering.

cluster_iters int

Number of Louvain iterations per clustering step.

fast_cluster bool

Shall fast Louvain clustering be applied, i.e., k-means clustering and use the centroids for kNN graph generation and Louvain clustering with then backpropagating the membership based on centroid proximity.

n_iterations int

Number of refinement iterations. Typically 2-3.

gbm_n_trees int

Maximum number of boosting rounds for the GBM classifier.

max_depth int

Maximum tree depth. Shallow trees (3-5) work best.

learning_rate float

Shrinkage applied to each tree.

min_samples_leaf int

Minimum training samples per leaf.

subsample_rate float

Fraction of samples used per tree.

cv_folds int

Number of cross-validation folds for boosting round selection.

cv_early_stop int

Early stopping patience per CV fold.

se_fraction float

Multiplier on the standard error for the SE rule used in round selection.

include_pcs int

Number of leading principal components to include as classifier features.

expected_doublet_rate float | None

Expected doublet rate as a fraction, e.g. 0.12 for 12 %. If not provided, will be calculated internally.

cxds_genes int | None

Number of CXDS genes to consider. If not provided, defaults to 500.

manual_threshold float | None

Manual score threshold. If None (default), expected-rate thresholding is used.

log_transform bool

Shall the counts be log-normalised.

mean_center bool

Shall mean centring be applied.

normalise_variance bool

Shall the variance be normalised.

target_size float

Target library size.

no_pcs int

Number of PCs to consider.

svd_solver Literal['randomised', 'auto', 'covariance', 'exact']

Which solver to use. "randomised" (default) is a randomised SVD, approximate in the trailing components. "covariance" builds the gene x gene cross-product and eigendecomposes it. "auto" takes Lanczos on the sparse path and "covariance" on the dense one. "exact" is Lanczos on the sparse path and a full SVD on the dense one. See PcaParams for the trade-offs.

k int

Number of neighbours.

knn_method Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']

Which method to use for the approximate nearest neighbour search. "nndescent" hands back the graph the NN-Descent built, with no index and no query pass. Rows the descent left short are re-queried exactly.

ann_dist Literal['euclidean', 'cosine']

Which distance metric to use for the approximate nearest neighbour search.

n_trees int

Annoy param: number of trees to generate for Annoy.

search_budget int | None

Annoy param: optional search budget per tree for Annoy. If not provided, it will default to n_tree * k * 20.

delta float

NNDescent param: early termination criterium for NNDescent.

diversify_prob float

NNDescent param: diversification probability. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

ef_budget int | None

NNDescent param: optional query budget. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

m int

HNSW param: number of connections between layers for HNSW.

ef_construction int

HNSW param: size of dynamic candidate list during construction.

ef_search int

HNSW param: size of candidate list (higher = better recall, slower).

n_list int | None

IVF param: number of clusters/centroids to generate. None generates sqrt(n) lists.

n_probe int | None

IVF param: number of clusters/centroids to query. None queries sqrt(n_lists) clusters.

km_type Literal['emeans', 'standard', 'minibatch']

The k-means of the fast clustering: "emeans", "standard" (Lloyd's) or "minibatch".

e_means_epochs float | None

km_type = "emeans" only. Passes over the data; None for the default.

n_centroids int | None

The number of centroids to use. None uses sqrt(N_cells) * 4 centroids.

k_means_iter int

Number of maximum k-means iterations. Ignored by e-means.

batch_size int

Max batch size, capped at N_cells / 2 depending on the data set.

ScrubletParams dataclass

ScrubletParams(
    *,
    sim_doublet_ratio: float = 1.5,
    expected_doublet_rate: float = 0.1,
    stdev_doublet_rate: float = 0.02,
    n_bins_histogram: int = 100,
    manual_threshold: float | None = None,
    log_transform: bool = True,
    mean_center: bool = False,
    normalise_variance: bool = False,
    target_size: float = 1000000.0,
    min_gene_var_pctl: float = 0.7,
    hvg_method: Literal[
        "vst", "meanvarbin", "dispersion", "scran"
    ] = "vst",
    loess_span: float = 0.3,
    clip_max: float | None = None,
    n_bins: int = 20,
    binning_strategy: Literal[
        "equal_width", "equal_frequency"
    ] = "equal_width",
    no_pcs: int = 30,
    svd_solver: Literal[
        "randomised", "auto", "covariance", "exact"
    ] = "randomised",
    k: int = 0,
    knn_method: Literal[
        "kmknn",
        "hnsw",
        "annoy",
        "nndescent",
        "ivf",
        "exhaustive",
    ] = "kmknn",
    ann_dist: Literal["euclidean", "cosine"] = "euclidean",
    n_trees: int = 50,
    search_budget: int | None = None,
    delta: float = 0.001,
    diversify_prob: float = 0.0,
    ef_budget: int | None = None,
    m: int = 16,
    ef_construction: int = 200,
    ef_search: int = 100,
    n_list: int | None = None,
    n_probe: int | None = None,
)

Wrapper function for Scrublet doublet detection parameters

Constructor for the various Scrublet parameters. The kNN graph uses the KnnDefaults search ("kmknn") with automatic neighbour detection (k = 0).

Attributes:

Name Type Description
sim_doublet_ratio float

Number of doublets to simulate relative to the number of observed cells. For example, 2.0 simulates twice as many doublets as there are cells.

expected_doublet_rate float

Expected doublet rate for the experiment, typically 0.05-0.10 depending on cell loading. Must be between 0 and 1.

stdev_doublet_rate float

Uncertainty in the expected doublet rate.

n_bins_histogram int

Number of bins for histogram-based automatic threshold detection. Typically 50-100.

manual_threshold float | None

Manual doublet score threshold. If None (default), the threshold comes from Otsu's method on the observed doublet scores.

log_transform bool

Shall the counts be log-normalised.

mean_center bool

Shall mean centring be applied.

normalise_variance bool

Shall the variance be normalised.

target_size float

Target library size.

min_gene_var_pctl float

Which percentile of the highly variable genes to include.

hvg_method Literal['vst', 'meanvarbin', 'dispersion', 'scran']

Which method to use to identify HVG. "scran" runs with the default trend parameters, see HvgScranDefaults.

loess_span float

In case of "vst" the span of the loess function.

clip_max float | None

The maximum clipping value (optional).

n_bins int

The number of bins to use for the "meanvarbin" and "dispersion" HVG detection.

binning_strategy Literal['equal_width', 'equal_frequency']

Which binning strategy to use for "meanvarbin" and "dispersion".

no_pcs int

Number of PCs to consider.

svd_solver Literal['randomised', 'auto', 'covariance', 'exact']

Which solver to use. "randomised" (default) is a randomised SVD, approximate in the trailing components. "covariance" builds the gene x gene cross-product and eigendecomposes it. "auto" takes Lanczos on the sparse path and "covariance" on the dense one. "exact" is Lanczos on the sparse path and a full SVD on the dense one. See PcaParams for the trade-offs.

k int

Number of neighbours.

knn_method Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']

Which method to use for the approximate nearest neighbour search. "nndescent" hands back the graph the NN-Descent built, with no index and no query pass. Rows the descent left short are re-queried exactly.

ann_dist Literal['euclidean', 'cosine']

Which distance metric to use for the approximate nearest neighbour search.

n_trees int

Annoy param: number of trees to generate for Annoy.

search_budget int | None

Annoy param: optional search budget per tree for Annoy. If not provided, it will default to n_tree * k * 20.

delta float

NNDescent param: early termination criterium for NNDescent.

diversify_prob float

NNDescent param: diversification probability. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

ef_budget int | None

NNDescent param: optional query budget. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

m int

HNSW param: number of connections between layers for HNSW.

ef_construction int

HNSW param: size of dynamic candidate list during construction.

ef_search int

HNSW param: size of candidate list (higher = better recall, slower).

n_list int | None

IVF param: number of clusters/centroids to generate. None generates sqrt(n) lists.

n_probe int | None

IVF param: number of clusters/centroids to query. None queries sqrt(n_lists) clusters.

Differential expression and abundance

Parameter bundles for the single cell suite.

One frozen dataclass per parameter bundle, flat as Rust sees them: ScrubletParams(no_pcs=10, k=0) rather than nested blocks. Field names match the keys the Rust structs deserialise; each bundle checks its ranges in __post_init__. ScenicParams sits in bixverse.params._scenic.

EdgerQlParams dataclass

EdgerQlParams(
    *,
    norm_method: Literal[
        "TMM", "TMMwsp", "RLE", "upperquartile", "none"
    ] = "TMM",
    filter: bool = True,
    min_mean: float = 0.0,
    robust: bool = False,
    legacy: bool = False,
)

Wrapper function for parameters for the edgeR quasi-likelihood workflow

Parameters for the edgeR quasi-likelihood chain, implemented in Rust via the edge-rs crate and gated against edgeR 4.8.2. Defaults are edgeR's own. The legacy switch picks between two genuinely different pipelines. The current route estimates its own dispersion from the most abundant genes and skips estimateDisp(), which is where most of the runtime went and is edgeR 4's own recommendation. The legacy route shrinks the raw residual deviance, needs a dispersion handed to it, and is the only one where the Poisson bound bites.

Attributes:

Name Type Description
norm_method Literal['TMM', 'TMMwsp', 'RLE', 'upperquartile', 'none']

Library size normalisation. "none" leaves every factor at one, which is what Milo's logMS amounts to.

filter bool

Run filterByExpr() before fitting. Turn this off for anything that is not gene expression, e.g. Milo neighbourhood counts, where the heuristic means nothing.

min_mean float

Drop features whose mean count across samples is below this. Applied on top of filter.

robust bool

Robust empirical Bayes squeezing, giving outlier features their own smaller prior degrees of freedom.

legacy bool

Take edgeR's pre-4.0 quasi-likelihood pipeline.

MeldParams dataclass

MeldParams(
    *,
    beta: float = 60.0,
    offset: float = 0.0,
    order: float = 1.0,
    filter: Literal["heat", "laplacian"] = "heat",
    chebyshev_order: int = 50,
    lap_type: Literal[
        "combinatorial", "normalised"
    ] = "combinatorial",
    normalise_indicators: bool = True,
    k: int = 15,
    knn_method: Literal[
        "kmknn",
        "hnsw",
        "annoy",
        "nndescent",
        "ivf",
        "exhaustive",
    ] = "kmknn",
    ann_dist: Literal["euclidean", "cosine"] = "euclidean",
    n_trees: int = 50,
    search_budget: int | None = None,
    delta: float = 0.001,
    diversify_prob: float = 0.0,
    ef_budget: int | None = None,
    m: int = 16,
    ef_construction: int = 200,
    ef_search: int = 100,
    n_list: int | None = None,
    n_probe: int | None = None,
)

Constructor for MELD parameters

Attributes:

Name Type Description
beta float

Smoothing strength; larger values produce smoother densities. Must be strictly positive.

offset float

Shift of the filter centre in the rescaled spectrum. Must be in [0, 1].

order float

Filter falloff sharpness; larger values approach a square low-pass. Must be strictly positive.

filter Literal['heat', 'laplacian']

Filter family to use.

chebyshev_order int

Number of Chebyshev coefficients (polynomial terms). Must be >= 2.

lap_type Literal['combinatorial', 'normalised']

Type of Laplacian to use for spectral filtering.

normalise_indicators bool

If True, each column of the indicator matrix is divided by its column sum before filtering, making cross-condition densities comparable regardless of cells-per-condition.

k int

Number of neighbours.

knn_method Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']

Which method to use for the approximate nearest neighbour search. "nndescent" hands back the graph the NN-Descent built, with no index and no query pass. Rows the descent left short are re-queried exactly.

ann_dist Literal['euclidean', 'cosine']

Which distance metric to use for the approximate nearest neighbour search.

n_trees int

Annoy param: number of trees to generate for Annoy.

search_budget int | None

Annoy param: optional search budget per tree for Annoy. If not provided, it will default to n_tree * k * 20.

delta float

NNDescent param: early termination criterium for NNDescent.

diversify_prob float

NNDescent param: diversification probability. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

ef_budget int | None

NNDescent param: optional query budget. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

m int

HNSW param: number of connections between layers for HNSW.

ef_construction int

HNSW param: size of dynamic candidate list during construction.

ef_search int

HNSW param: size of candidate list (higher = better recall, slower).

n_list int | None

IVF param: number of clusters/centroids to generate. None generates sqrt(n) lists.

n_probe int | None

IVF param: number of clusters/centroids to query. None queries sqrt(n_lists) clusters.

NebulaParams dataclass

NebulaParams(
    *,
    nebula_method: Literal["ln", "hl"] = "ln",
    min_sigma: float = 0.0001,
    min_phi: float = 0.0001,
    max_sigma: float = 10.0,
    max_phi: float = 1000.0,
    cutoff_cell: float = 20.0,
    kappa: float = 800.0,
    cpc: float = 0.005,
    mincp: int = 5,
    min_subjects: int = 0,
    reml: bool = False,
    eps: float = 1e-06,
    gene_batch_size: int = 1000,
    shrink_dispersion: bool = True,
)

Wrapper function for parameters for NEBULA

Parameters for the NEBULA negative binomial gamma mixed model, implemented in Rust via the edge-rs crate and ported from the nebula package's own C++. Defaults follow the nebula package. NEBULA splits the variance into a subject- level random effect and a cell-level overdispersion. Run it on meta cells and the cell-level term becomes the spread between aggregates within a subject rather than between cells, so it is smaller and absorbs whatever the aggregation smoothed away. The subject-level term keeps its meaning either way.

Attributes:

Name Type Description
nebula_method Literal['ln', 'hl']

Which variant to run. NEBULA downgrades "ln" to "hl" below 30 cells per subject.

min_sigma float

Lower bound on the subject-level overdispersion.

min_phi float

Lower bound on the cell-level overdispersion.

max_sigma float

Upper bound on the subject-level overdispersion.

max_phi float

Upper bound on the cell-level overdispersion.

cutoff_cell float

Refit both overdispersions when the product of the cells per subject and the estimated phi falls below this.

kappa float

Threshold on NEBULA's kappa_obs above which the subject-level overdispersion from stage one is trusted as is.

cpc float

Drop a gene whose mean count per cell is at most this.

mincp int

Drop a gene expressed in fewer than this many cells.

min_subjects int

Drop a gene that fewer than this many subjects express, a subject expressing it when its own mean count per cell is above cpc. cpc and mincp pool every cell, so one subject can carry a gene through on its own. 0 switches the check off, as in the nebula package.

reml bool

Estimate the overdispersions by restricted maximum likelihood. This arm has not been validated against a reference. Leave it off unless you know why you want it.

eps float

Absolute stopping tolerance for the optimiser.

gene_batch_size int

Genes read and fitted per batch. Bounds how much of the store is resident at once and changes nothing about the answer, since NEBULA is gene-independent.

shrink_dispersion bool

Shrink the cell-level overdispersions towards an empirical Bayes prior once the sweep is done.

Annotation

Parameter bundles for the single cell suite.

One frozen dataclass per parameter bundle, flat as Rust sees them: ScrubletParams(no_pcs=10, k=0) rather than nested blocks. Field names match the keys the Rust structs deserialise; each bundle checks its ranges in __post_init__. ScenicParams sits in bixverse.params._scenic.

SctypeCellsParams dataclass

SctypeCellsParams(
    *,
    alpha: float = 0.5,
    iterations: int = 2,
    tolerance: float = 0.0001,
    calibration: Literal["none", "column_z"] = "none",
    score_floor: float = 0.25,
    purity_threshold: float = 0.9,
)

Parameters for the per-cell ScType assignment

Controls the per-cell path of assign_sc_type(): how the raw ScType scores are rescaled, how hard the scores get smoothed over the sNN graph, and where the cut-offs for an Unknown call and for a mixed cluster sit.

Attributes:

Name Type Description
alpha float

Numeric in [0, 1]. Self-retention during smoothing. Each iteration computes alpha * original + (1 - alpha) * neighbour_average.

iterations int

Integer >= 0. Number of smoothing iterations. 0 disables smoothing.

tolerance float

Numeric > 0. Convergence tolerance for the smoothing.

calibration Literal['none', 'column_z']

"column_z" standardises each cell type's score column across cells, which removes the bias towards cell types whose marker sets happen to produce larger scores.

score_floor float

Numeric >= 0. Minimum score for a cell to get a call instead of null.

purity_threshold float

Numeric in [0, 1]. Cluster purity above which the hybrid assignment keeps the cluster-level call.

SymphonyMapParams dataclass

SymphonyMapParams(
    *, sigma: float = 0.1, lambda_: float = 1.0
)

Default parameters for Symphony query mapping

Attributes:

Name Type Description
sigma float

Soft-clustering fuzziness for query -> reference centroid assignment. The Symphony default is 0.1.

lambda_ float

Ridge penalty on batch coefficients. Symphony fixes it at 1.0.

Meta cells

Parameter bundles for the single cell suite.

One frozen dataclass per parameter bundle, flat as Rust sees them: ScrubletParams(no_pcs=10, k=0) rather than nested blocks. Field names match the keys the Rust structs deserialise; each bundle checks its ranges in __post_init__. ScenicParams sits in bixverse.params._scenic.

BtMetacellsParams dataclass

BtMetacellsParams(
    *,
    max_shared: int = 15,
    target_no_metacells: int = 1000,
    max_iter: int = 5000,
    k: int = 25,
    knn_method: Literal[
        "kmknn",
        "hnsw",
        "annoy",
        "nndescent",
        "ivf",
        "exhaustive",
    ] = "kmknn",
    ann_dist: Literal["euclidean", "cosine"] = "cosine",
    n_trees: int = 50,
    search_budget: int | None = None,
    delta: float = 0.001,
    diversify_prob: float = 0.0,
    ef_budget: int | None = None,
    m: int = 16,
    ef_construction: int = 200,
    ef_search: int = 100,
    n_list: int | None = None,
    n_probe: int | None = None,
)

Wrapper function for parameters for bootstrapped meta cell generation

This function generates parameters for the bootstrapped meta cell generation based on hdWGCNA, see Morabito, et al., Cell Rep. Methods, 2023.

Attributes:

Name Type Description
max_shared int

Maximum number of allowed shared neighbours for the meta cell to be considered.

target_no_metacells int

Target number of meta-cells to generate.

max_iter int

Maximum number of iterations for the algorithm.

k int

Number of neighbours.

knn_method Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']

Which method to use for the approximate nearest neighbour search. "nndescent" hands back the graph the NN-Descent built, with no index and no query pass. Rows the descent left short are re-queried exactly.

ann_dist Literal['euclidean', 'cosine']

Which distance metric to use for the approximate nearest neighbour search.

n_trees int

Annoy param: number of trees to generate for Annoy.

search_budget int | None

Annoy param: optional search budget per tree for Annoy. If not provided, it will default to n_tree * k * 20.

delta float

NNDescent param: early termination criterium for NNDescent.

diversify_prob float

NNDescent param: diversification probability. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

ef_budget int | None

NNDescent param: optional query budget. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

m int

HNSW param: number of connections between layers for HNSW.

ef_construction int

HNSW param: size of dynamic candidate list during construction.

ef_search int

HNSW param: size of candidate list (higher = better recall, slower).

n_list int | None

IVF param: number of clusters/centroids to generate. None generates sqrt(n) lists.

n_probe int | None

IVF param: number of clusters/centroids to query. None queries sqrt(n_lists) clusters.

KnnDefaults dataclass

KnnDefaults(
    *,
    k: int = 15,
    knn_method: Literal[
        "kmknn",
        "hnsw",
        "annoy",
        "nndescent",
        "ivf",
        "exhaustive",
    ] = "kmknn",
    ann_dist: Literal["euclidean", "cosine"] = "euclidean",
    n_trees: int = 50,
    search_budget: int | None = None,
    delta: float = 0.001,
    diversify_prob: float = 0.0,
    ef_budget: int | None = None,
    m: int = 16,
    ef_construction: int = 200,
    ef_search: int = 100,
    n_list: int | None = None,
    n_probe: int | None = None,
)

Helper function to generate kNN defaults

This function generates various sensible default parameters for all of the different approximate nearest neighbours that are available within this package.

Attributes:

Name Type Description
k int

Number of neighbours.

knn_method Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']

Which method to use for the approximate nearest neighbour search. "nndescent" hands back the graph the NN-Descent built, with no index and no query pass. Rows the descent left short are re-queried exactly.

ann_dist Literal['euclidean', 'cosine']

Which distance metric to use for the approximate nearest neighbour search.

n_trees int

Annoy param: number of trees to generate for Annoy.

search_budget int | None

Annoy param: optional search budget per tree for Annoy. If not provided, it will default to n_tree * k * 20.

delta float

NNDescent param: early termination criterium for NNDescent.

diversify_prob float

NNDescent param: diversification probability. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

ef_budget int | None

NNDescent param: optional query budget. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

m int

HNSW param: number of connections between layers for HNSW.

ef_construction int

HNSW param: size of dynamic candidate list during construction.

ef_search int

HNSW param: size of candidate list (higher = better recall, slower).

n_list int | None

IVF param: number of clusters/centroids to generate. None generates sqrt(n) lists.

n_probe int | None

IVF param: number of clusters/centroids to query. None queries sqrt(n_lists) clusters.

Metacells2DacParams dataclass

Metacells2DacParams(
    *,
    min_target_pile_size: int = 8000,
    max_target_pile_size: int = 24000,
    target_metacells_in_pile: int = 100,
    target_pile_size: int | None = None,
    quick_and_dirty: bool = False,
    max_parallel_piles: int = 1,
    groups_similarity_method: Literal[
        "abs_pearson", "pearson"
    ] = "abs_pearson",
    rare_gene_modules: bool = True,
    rare_max_gene_cell_fraction: float = 0.001,
    rare_max_genes: int = 500,
    rare_min_genes_of_modules: int = 4,
    rare_min_cells_of_modules: int = 12,
    rare_genes_similarity_method: Literal[
        "repeated_pearson",
        "repeated_abs_pearson",
        "pearson",
        "abs_pearson",
    ] = "repeated_pearson",
    rare_genes_cluster_method: Literal[
        "ward", "complete", "average", "weighted"
    ] = "ward",
)

Wrapper function for the MetaCells2 divide and conquer parameters

Attributes:

Name Type Description
min_target_pile_size int

Lower clamp on the derived pile size.

max_target_pile_size int

Upper clamp on the derived pile size.

target_metacells_in_pile int

Meta cells wanted per pile, used to derive the pile size.

target_pile_size int | None

Fixed pile size. None derives it from the data and clamps it to [min_target_pile_size, max_target_pile_size].

quick_and_dirty bool

Stop after the final phase instead of regrouping the outliers.

max_parallel_piles int

Piles computed concurrently. Each pile holds two dense pile_size x pile_size matrices, so this trades memory for speed.

groups_similarity_method Literal['abs_pearson', 'pearson']

Similarity used when grouping meta cells into piles.

rare_gene_modules bool

Detect rare gene modules first and pile their cells separately.

rare_max_gene_cell_fraction float

Largest fraction of cells a gene may be expressed in to be a rare gene candidate.

rare_max_genes int

Most rare gene candidates kept.

rare_min_genes_of_modules int

Fewest genes in a rare gene module.

rare_min_cells_of_modules int

Fewest cells in a rare gene module.

rare_genes_similarity_method Literal['repeated_pearson', 'repeated_abs_pearson', 'pearson', 'abs_pearson']

Gene-gene similarity of the rare candidates.

rare_genes_cluster_method Literal['ward', 'complete', 'average', 'weighted']

Linkage for the hierarchical clustering of the rare candidates.

Metacells2Params dataclass

Metacells2Params(
    *,
    target_metacell_size: int = 48,
    min_metacell_size: int = 12,
    target_metacell_umis: float = 160000.0,
    similarity_method: Literal[
        "abs_pearson", "pearson"
    ] = "abs_pearson",
    log_data: bool = True,
    value_regularisation: float = 0.14285714285714285,
    min_genes: int = 100,
    min_gene_total: int = 50,
    min_gene_top3: int = 4,
    min_gene_relative_variance: float = 0.1,
    downsample_min_samples: int = 750,
    knn_k_override: int | None = None,
    min_knn_k: int = 30,
    min_gene_fold_factor: float = 3.0,
    max_cell_fraction: float = 0.25,
    gap_skip_cells: int = 1,
    min_robust_size_factor: float = 0.5,
    min_convincing_gene_fold_factor: float = 3.0,
)

Wrapper function for the MetaCells2 per-pile parameters

Attributes:

Name Type Description
target_metacell_size int

Target number of cells per meta cell.

min_metacell_size int

Candidate meta cells below this size are dissolved into outliers.

target_metacell_umis float

Target total UMIs per meta cell. Drives the number of seeds and the size of the kNN graph.

similarity_method Literal['abs_pearson', 'pearson']

Cell-cell similarity on the selected genes.

log_data bool

Correlate log2(x + value_regularisation) instead of x.

value_regularisation float

Constant added before the optional log transform.

min_genes int

Floor on the number of selected genes per pile. The relative variance threshold is relaxed until it is met.

min_gene_total int

Minimum total UMIs (downsampled) for a gene to be selected.

min_gene_top3 int

Minimum third-highest UMI count of a gene to be selected.

min_gene_relative_variance float

Minimum windowed relative variance for a gene to be selected.

downsample_min_samples int

Floor for the per-pile downsampling target.

knn_k_override int | None

Fixed k for the balanced kNN graph. None derives it from target_metacell_umis and the library sizes.

min_knn_k int

Floor on the derived k.

min_gene_fold_factor float

Minimum log2 fold gap within a candidate meta cell for a gene to mark cells as deviant.

max_cell_fraction float

Upper bound on the fraction of cells marked as deviants.

gap_skip_cells int

Cells skipped over when measuring a gap.

min_robust_size_factor float

Multiplier on the target size (and UMIs) above which a meta cell is kept unconditionally.

min_convincing_gene_fold_factor float

Minimum log2 fold of any gene for a meta cell below the robust size to be kept anyway.

SeacellsParams dataclass

SeacellsParams(
    *,
    n_sea_cells: int,
    max_fw_iters: int = 50,
    convergence_epsilon: float = 0.001,
    max_iter: int = 100,
    min_iter: int = 10,
    greedy_threshold: int = 20000,
    graph_building: str = "union",
    pruning: bool = True,
    pruning_threshold: float = 1e-07,
    n_landmarks: int | None = None,
    k: int = 25,
    knn_method: Literal[
        "kmknn",
        "hnsw",
        "annoy",
        "nndescent",
        "ivf",
        "exhaustive",
    ] = "kmknn",
    ann_dist: Literal["euclidean", "cosine"] = "euclidean",
    n_trees: int = 50,
    search_budget: int | None = None,
    delta: float = 0.001,
    diversify_prob: float = 0.0,
    ef_budget: int | None = None,
    m: int = 16,
    ef_construction: int = 200,
    ef_search: int = 100,
    n_list: int | None = None,
    n_probe: int | None = None,
)

Wrapper function for the SEACells parameters

Attributes:

Name Type Description
n_sea_cells int

Number of SEA cells to detect.

max_fw_iters int

Maximum iterations for the Franke-Wolfe algorithm.

convergence_epsilon float

Convergence threshold. Algorithm stops when RSS change < epsilon * RSS(0).

max_iter int

Maximum iterations to run SEACells for.

min_iter int

Minimum iterations to run SEACells for.

greedy_threshold int

Maximum number of cells before defaulting to rapid random selection of archetypes.

graph_building str

Graph building method.

pruning bool

Shall tiny values be pruned during Franke-Wolfe updates.

pruning_threshold float

If pruning = True values below which threshold shall be pruned.

n_landmarks int | None

If provided, it will use the Nystroem extension during the archetype finding. Useful for larger data sets.

k int

Number of neighbours.

knn_method Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']

Which method to use for the approximate nearest neighbour search. "nndescent" hands back the graph the NN-Descent built, with no index and no query pass. Rows the descent left short are re-queried exactly.

ann_dist Literal['euclidean', 'cosine']

Which distance metric to use for the approximate nearest neighbour search.

n_trees int

Annoy param: number of trees to generate for Annoy.

search_budget int | None

Annoy param: optional search budget per tree for Annoy. If not provided, it will default to n_tree * k * 20.

delta float

NNDescent param: early termination criterium for NNDescent.

diversify_prob float

NNDescent param: diversification probability. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

ef_budget int | None

NNDescent param: optional query budget. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

m int

HNSW param: number of connections between layers for HNSW.

ef_construction int

HNSW param: size of dynamic candidate list during construction.

ef_search int

HNSW param: size of candidate list (higher = better recall, slower).

n_list int | None

IVF param: number of clusters/centroids to generate. None generates sqrt(n) lists.

n_probe int | None

IVF param: number of clusters/centroids to query. None queries sqrt(n_lists) clusters.

SupercellParams dataclass

SupercellParams(
    *,
    walk_length: int = 3,
    graining_factor: float = 20.0,
    use_kernel: bool = True,
    k_ith: int | None = None,
    max_support: int | None = None,
    k: int = 5,
    knn_method: Literal[
        "kmknn",
        "hnsw",
        "annoy",
        "nndescent",
        "ivf",
        "exhaustive",
    ] = "kmknn",
    ann_dist: Literal["euclidean", "cosine"] = "cosine",
    n_trees: int = 50,
    search_budget: int | None = None,
    delta: float = 0.001,
    diversify_prob: float = 0.0,
    ef_budget: int | None = None,
    m: int = 16,
    ef_construction: int = 200,
    ef_search: int = 100,
    n_list: int | None = None,
    n_probe: int | None = None,
)

Wrapper function for parameters for SuperCell generation

Attributes:

Name Type Description
walk_length int

Walk length for the Walktrap algorithm.

graining_factor float

Graining level of data (proportion of number of single cells in the initial dataset to the number of metacells in the final dataset). (One meta cell per 20 cells.)

use_kernel bool

Shall a kernel function akin to MAGIC be applied akin to the approach in SuperCell2, see Hérault, et al., bioRxiv, 2026 and van Dijk, et al., Cell, 2018.

k_ith int | None

The k-ith neighbour to use for the kernel.

max_support int | None

Caps each cell's walk-probability vector to its top entries by mass, bounding memory at ~max_support * n_cells on large data. Makes the result an approximation. None (default) keeps the walks exact.

k int

Number of neighbours.

knn_method Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']

Which method to use for the approximate nearest neighbour search. "nndescent" hands back the graph the NN-Descent built, with no index and no query pass. Rows the descent left short are re-queried exactly.

ann_dist Literal['euclidean', 'cosine']

Which distance metric to use for the approximate nearest neighbour search.

n_trees int

Annoy param: number of trees to generate for Annoy.

search_budget int | None

Annoy param: optional search budget per tree for Annoy. If not provided, it will default to n_tree * k * 20.

delta float

NNDescent param: early termination criterium for NNDescent.

diversify_prob float

NNDescent param: diversification probability. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

ef_budget int | None

NNDescent param: optional query budget. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

m int

HNSW param: number of connections between layers for HNSW.

ef_construction int

HNSW param: size of dynamic candidate list during construction.

ef_search int

HNSW param: size of candidate list (higher = better recall, slower).

n_list int | None

IVF param: number of clusters/centroids to generate. None generates sqrt(n) lists.

n_probe int | None

IVF param: number of clusters/centroids to query. None queries sqrt(n_lists) clusters.

Trajectories

Parameter bundles for the single cell suite.

One frozen dataclass per parameter bundle, flat as Rust sees them: ScrubletParams(no_pcs=10, k=0) rather than nested blocks. Field names match the keys the Rust structs deserialise; each bundle checks its ranges in __post_init__. ScenicParams sits in bixverse.params._scenic.

BranchSelectionParams dataclass

BranchSelectionParams(
    *,
    q: float = 0.01,
    eps: float = 0.01,
    resolution: int = 500,
)

Wrapper function for the branch cell selection parameters

Parameters controlling which cells run_gene_trends() assigns to each branch. The threshold on a fate's probability is an expanding quantile over the pseudotime-sorted cells, made monotone with a cumulative maximum, so a fate's bar can only rise as differentiation proceeds. The defaults are the reference ones.

Attributes:

Name Type Description
q float

Upper-tail quantile of the fate probability used as the threshold.

eps float

Slack subtracted from the threshold before the comparison.

resolution int

Number of pseudotime buckets, capped at the cell count.

GeneTrendsParams dataclass

GeneTrendsParams(
    *,
    resolution: int = 500,
    weighting: Literal[
        "hard_mask", "fate_probability"
    ] = "hard_mask",
    length_scale: float = 1.0,
    sigma: float = 1.0,
    jitter: float = 1e-06,
    max_jitter_retries: int = 3,
    chunk_size: int = 2048,
)

Wrapper function for gene trend parameters

Parameters controlling the landmark Gaussian process that run_gene_trends() fits per branch. The kernel is a Matern-5/2 one and the prediction grid doubles as the landmark set. The defaults come from the reference and are prior- dominated. Palantir's pseudotime is min-max scaled to [0, 1], so a length_scale of 1.0 spans the entire domain and a sigma of 1.0 sits at roughly the signal scale of log-normalised expression. The posterior will flatten genuine transient structure and resolve almost any gene into a smooth monotone or single-peaked curve. That is a presentation choice, not inference. Shorten length_scale before believing a bump.

Attributes:

Name Type Description
resolution int

Grid points per branch. Kept at the default even when a branch holds fewer cells, as the reference does.

weighting Literal['hard_mask', 'fate_probability']

With "hard_mask" every selected cell enters its branch's fit with equal weight, which is what the reference does. With "fate_probability" every cell enters every fit weighted by its fate probability, which is more defensible: a cell at 0.6 is not a member.

length_scale float

Matern-5/2 length scale.

sigma float

Noise standard deviation.

jitter float

Added to the landmark covariance diagonal before the Cholesky.

max_jitter_retries int

Times the jitter is raised and the Cholesky retried before giving up.

chunk_size int

Training points held at once when accumulating the cross- covariance.

PalantirParams dataclass

PalantirParams(
    *,
    n_dcs: int = 10,
    n_eigs: int | None = None,
    knn: int = 30,
    num_waypoints: int = 1200,
    scale_components: bool = True,
    use_early_cell_as_start: bool = True,
    max_iterations: int = 25,
    branch_prob_threshold: float = 0.01,
    lanczos_basis_size: int | None = None,
    lanczos_max_restarts: int = 64,
    lanczos_tol: float = 1e-08,
    k: int = 15,
    knn_method: Literal[
        "kmknn",
        "hnsw",
        "annoy",
        "nndescent",
        "ivf",
        "exhaustive",
    ] = "kmknn",
    ann_dist: Literal["euclidean", "cosine"] = "euclidean",
    n_trees: int = 50,
    search_budget: int | None = None,
    delta: float = 0.001,
    diversify_prob: float = 0.0,
    ef_budget: int | None = None,
    m: int = 16,
    ef_construction: int = 200,
    ef_search: int = 100,
    n_list: int | None = None,
    n_probe: int | None = None,
)

Wrapper function for Palantir parameters

Parameters controlling the Palantir trajectory inference. The kNN graph you hand to run_palantir() feeds the diffusion kernel. The geodesics are measured over a second kNN graph that Palantir builds internally on the multiscale space, and knn is what controls that one. It is a different knob from k in the kNN parameter block, which sizes the backend index. Palantir overrides k and ann_dist for its internal search, so only knn_method and the backend tuning parameters have an effect.

Attributes:

Name Type Description
n_dcs int

Diffusion components to extract before the multiscale scaling.

n_eigs int | None

Eigenvectors to retain, not components: the trivial leading eigenvector is counted here and then dropped, so 3 leaves two multiscale components. If None, the count is picked from the largest eigengap, as the reference does.

knn int

Neighbours for the geodesic graph over the multiscale space, in the reference's self-inclusive convention.

num_waypoints int

Target waypoint count for the max-min sampler.

scale_components bool

Min-max scale each multiscale component to [0, 1] before any distance is taken.

use_early_cell_as_start bool

Use the provided early cell directly rather than snapping it to the nearest diffusion-map boundary cell.

max_iterations int

Iteration cap for the pseudotime refinement.

branch_prob_threshold float

Fate probabilities below this are zeroed.

lanczos_basis_size int | None

Krylov basis vectors held at once during the diffusion- map eigendecomposition. If None, derived from the requested component count.

lanczos_max_restarts int

Maximum restart cycles for the Lanczos solver.

lanczos_tol float

Relative residual tolerance for the Lanczos solver.

k int

Number of neighbours.

knn_method Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']

Which method to use for the approximate nearest neighbour search. "nndescent" hands back the graph the NN-Descent built, with no index and no query pass. Rows the descent left short are re-queried exactly.

ann_dist Literal['euclidean', 'cosine']

Which distance metric to use for the approximate nearest neighbour search.

n_trees int

Annoy param: number of trees to generate for Annoy.

search_budget int | None

Annoy param: optional search budget per tree for Annoy. If not provided, it will default to n_tree * k * 20.

delta float

NNDescent param: early termination criterium for NNDescent.

diversify_prob float

NNDescent param: diversification probability. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

ef_budget int | None

NNDescent param: optional query budget. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

m int

HNSW param: number of connections between layers for HNSW.

ef_construction int

HNSW param: size of dynamic candidate list during construction.

ef_search int

HNSW param: size of candidate list (higher = better recall, slower).

n_list int | None

IVF param: number of clusters/centroids to generate. None generates sqrt(n) lists.

n_probe int | None

IVF param: number of clusters/centroids to query. None queries sqrt(n_lists) clusters.

Cell trees

Parameter bundles for the single cell suite.

One frozen dataclass per parameter bundle, flat as Rust sees them: ScrubletParams(no_pcs=10, k=0) rather than nested blocks. Field names match the keys the Rust structs deserialise; each bundle checks its ranges in __post_init__. ScenicParams sits in bixverse.params._scenic.

BonsaiParams dataclass

BonsaiParams(
    *,
    variance_rule: Literal[
        "marginalise",
        "posterior_mean",
        "max_posterior",
        "fixed",
    ] = "marginalise",
    fixed_variance: float | None = None,
    variance_bins: int = 161,
    variance_min: float = 0.001,
    variance_max: float = 50.0,
    min_signal_to_noise: float = 1.0,
    start: Literal["linkage", "greedy_merge"] = "linkage",
    spr_search: Literal[
        "approximate", "exact"
    ] = "approximate",
    nni_search: Literal[
        "approximate", "exact"
    ] = "approximate",
    seed: int = 42,
    reroot: bool = True,
    layout: Literal[
        "equal_angle", "equal_daylight", "dendrogram"
    ] = "equal_angle",
    hyperbolic: bool = False,
)

Wrapper function for Bonsai parameters

Parameters for bonsai(). Sanity turns the raw counts into posterior log fold changes with error bars, Bonsai builds a tree over the cells from those, and the tree is laid out in 2D for plotting. The Sanity defaults come from sanity-sc-rs, the search defaults from bonsai-rs.

Attributes:

Name Type Description
variance_rule Literal['marginalise', 'posterior_mean', 'max_posterior', 'fixed']

How Sanity treats each gene's variance in log fold change. "marginalise" integrates over the variance grid, "posterior_mean" and "max_posterior" collapse it to one value first (cheaper, less accurate error bars), and "fixed" uses fixed_variance for every gene.

fixed_variance float | None

The variance for variance_rule = "fixed". Ignored otherwise.

variance_bins int

Bins in the log-spaced variance grid.

variance_min float

Smallest variance on the grid.

variance_max float

Largest variance on the grid.

min_signal_to_noise float

Genes whose signal-to-noise ratio falls below this are left out of the tree.

start Literal['linkage', 'greedy_merge']

Initial topology. "linkage" is a Ward linkage over a neighbour graph: faster and a better tree on real data. "greedy_merge" is the paper's star merge, kept for comparisons with the published method.

spr_search Literal['approximate', 'exact']

Subtree pruning and regrafting. "approximate" stays within a few nats of "exact" on bonsai-rs's benchmarks at up to twice the speed.

nni_search Literal['approximate', 'exact']

Nearest-neighbour interchange. "approximate" found the same tree as "exact" on every bonsai-rs benchmark, and faster.

seed int

Seed for the linkage, SPR and NNI searches.

reroot bool

Reroot the finished tree for display. Changes the drawing, not the likelihood.

layout Literal['equal_angle', 'equal_daylight', 'dendrogram']

2D layout. "equal_daylight" refines equal angle but falls back to it above 2,048 nodes, so it only matters for small trees. Can be changed later with relayout_bonsai().

hyperbolic bool

Project the layout onto the hyperbolic disk.

Gene sets and regulons

Parameter bundles for the single cell suite.

One frozen dataclass per parameter bundle, flat as Rust sees them: ScrubletParams(no_pcs=10, k=0) rather than nested blocks. Field names match the keys the Rust structs deserialise; each bundle checks its ranges in __post_init__. ScenicParams sits in bixverse.params._scenic.

AucellParams dataclass

AucellParams(
    *,
    auc_type: Literal[
        "recovery", "wilcox", "ap"
    ] = "recovery",
    max_rank: float | None = None,
    standardise: bool = False,
)

Wrapper function for parameters for AUCell

The three statistics consume the same within-cell ranking, but weight it very differently. "wilcox" is a pure function of the gene set's rank sum, so a gene at rank 2 and one at rank 200 count for almost the same thing. "recovery" and "ap" are top-heavy. For SCENIC use "recovery", the default. "wilcox" is a bixverse addition and its flatter score does not separate into on/off populations, so it binarises badly. Ranking ties are averaged (midranks) rather than broken at random the way AUCell does it, which is why there is no need for SCENIC's trick of setting the cutoff to the 1st percentile of genes detected per cell. Undetected genes all collapse onto one rank well outside any sensible max_rank. Note the recovery AUC is normalised by max_rank * length(gene_set), matching pySCENIC and AUCell's normAUC = False. Modern AUCell divides by the attainable maximum instead, so absolute values differ by a per-gene-set constant. Cell ordering within a regulon is unaffected.

Attributes:

Name Type Description
auc_type Literal['recovery', 'wilcox', 'ap']

Which statistic to calculate. "wilcox" is the AUC derived from the Mann-Whitney U statistic over the full ranking, with the null at 0.5 for any gene set size. "recovery" is the recovery-curve AUC under a rank cutoff, i.e. the actual AUCell statistic of Aibar, et al. "ap" is average precision, the most top-heavy of the three, but its null tracks the gene set prevalence so raw values are not comparable across gene sets of different size unless standardise is on.

max_rank float | None

Rank cutoff for "recovery", counted from the top of the within- cell ranking. If None, resolves to the top 5% of the gene universe, following Aibar, et al. Ignored by the other two statistics.

standardise bool

Shall each gene set's scores be z-scored across the cells. This is what makes "ap" comparable across gene sets of different size.

CistargetParams dataclass

CistargetParams(
    *,
    auc_threshold: float = 0.05,
    nes_threshold: float = 3.0,
    max_rank: int = 5000,
    n_mean: int = 100,
    rcc_method: Literal["approx", "icistarget"] = "approx",
    high_conf_cats: tuple[str, ...] = (
        "directAnnotation",
        "inferredBy_Orthology",
    ),
    low_conf_cats: tuple[str, ...] = (
        "inferredBy_MotifSimilarity",
        "inferredBy_MotifSimilarity_n_Orthology",
    ),
)

Wrapper function to CisTarget parameters

auc_threshold and max_rank are two different cutoffs and are easy to confuse. The first truncates the recovery curve used to score motif enrichment, the second sets how deep into the ranking the background curve (mean + 2 SD across all motifs) is built, and therefore where the leading edge cuts. RcisTarget uses maxRank = 5000 and nMean = 100; the defaults here follow it. auc_threshold follows pySCENIC at 5%, RcisTarget itself uses 3%.

Attributes:

Name Type Description
auc_threshold float

Numeric between 0 and 1. Proportion of genes to use for AUC threshold calculation. Default is 0.05 (5% of genes).

nes_threshold float

Normalised Enrichment Score threshold for significant motifs. Default is 3.0.

max_rank int

Depth of the recovery curves used to derive the background and the leading edge. Clamped to the number of genes in the ranking database. Default is 5000, the RcisTarget value.

n_mean int

Window for the rolling mean smoothing the background recovery curve. Only read when rcc_method = "approx". Default is 100, the RcisTarget value.

rcc_method Literal['approx', 'icistarget']

Method for recovery curve calculation. Either "approx" (approximate, faster) or "icistarget" (exact, slower).

high_conf_cats tuple[str, ...]

Annotation categories considered high confidence. Default includes direct annotations and orthology-based inferences.

low_conf_cats tuple[str, ...]

Annotation categories considered lower confidence. Default includes motif similarity-based inferences.

HotspotParams dataclass

HotspotParams(
    *,
    model: Literal["danb", "normal", "bernoulli"] = "danb",
    normalise: bool = True,
    weighted_graph: bool = False,
    neighborhood_factor: float = 3.0,
    k: int = 15,
    knn_method: Literal[
        "kmknn",
        "hnsw",
        "annoy",
        "nndescent",
        "ivf",
        "exhaustive",
    ] = "kmknn",
    ann_dist: Literal["euclidean", "cosine"] = "euclidean",
    n_trees: int = 50,
    search_budget: int | None = None,
    delta: float = 0.001,
    diversify_prob: float = 0.0,
    ef_budget: int | None = None,
    m: int = 16,
    ef_construction: int = 200,
    ef_search: int = 100,
    n_list: int | None = None,
    n_probe: int | None = None,
)

Wrapper function for parameters for HotSpot

weighted_graph controls how the kNN distances become edge weights. The default of False follows the reference implementation: the distances only decide who is a neighbour and every retained edge weighs one. Set it to True for the Gaussian kernel, whose width is the ceil(k / neighborhood_factor)-th neighbour distance.

Attributes:

Name Type Description
model Literal['danb', 'normal', 'bernoulli']

Model to use for modelling the GEX.

normalise bool

Shall the data be normalised.

weighted_graph bool

Shall the Gaussian kernel be applied to the neighbour distances.

neighborhood_factor float

Kernel width is the ceil(k / neighborhood_factor)-th neighbour distance. Only read when weighted_graph = True.

k int

Number of neighbours.

knn_method Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']

Which method to use for the approximate nearest neighbour search. "nndescent" hands back the graph the NN-Descent built, with no index and no query pass. Rows the descent left short are re-queried exactly.

ann_dist Literal['euclidean', 'cosine']

Which distance metric to use for the approximate nearest neighbour search.

n_trees int

Annoy param: number of trees to generate for Annoy.

search_budget int | None

Annoy param: optional search budget per tree for Annoy. If not provided, it will default to n_tree * k * 20.

delta float

NNDescent param: early termination criterium for NNDescent.

diversify_prob float

NNDescent param: diversification probability. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

ef_budget int | None

NNDescent param: optional query budget. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

m int

HNSW param: number of connections between layers for HNSW.

ef_construction int

HNSW param: size of dynamic candidate list during construction.

ef_search int

HNSW param: size of candidate list (higher = better recall, slower).

n_list int | None

IVF param: number of clusters/centroids to generate. None generates sqrt(n) lists.

n_probe int | None

IVF param: number of clusters/centroids to query. None queries sqrt(n_lists) clusters.

LmActivityParams dataclass

LmActivityParams(
    *,
    method: Literal["ulm", "mlm"] = "ulm",
    stat: Literal["t", "coef"] = "t",
    p_values: bool = False,
    tmin: int = 5,
)

Wrapper function to generate ULM / MLM activity parameters

Attributes:

Name Type Description
method Literal['ulm', 'mlm']

Univariate (one model per set) or multivariate (all sets in one model) linear model.

stat Literal['t', 'coef']

Return the t-value or the coefficient as the activity score.

p_values bool

Shall the two-sided p-values be computed.

tmin int

Minimum number of targets per source after removing targets absent from the data.

ScenicBinariseParams dataclass

ScenicBinariseParams(
    *,
    bw_adjust: float = 1.0,
    n_grid: int = 512,
    n_bins: int = 512,
)

Wrapper function for parameters for the SCENIC binarisation

Each regulon gets its own threshold. A two-component Gaussian mixture is fitted and compared against a single Gaussian by BIC; if the mixture wins, the threshold is the kernel density minimum between the two component means, otherwise it falls back to mean + 2 * sd. This follows pySCENIC. AUCell fits six candidates and then lets the density trough override all of them whenever one exists, so the two land in much the same place. Turn bw_adjust up if shallow wobbles in the density are being picked up as troughs. AUCell effectively runs at 2.

Attributes:

Name Type Description
bw_adjust float

Multiplier on the Silverman bandwidth of the kernel density estimate. Higher values smooth more.

n_grid int

Number of points at which the density is evaluated between the two component means.

n_bins int

Number of histogram bins used to approximate the density.

ScenicExtraTreesDefaults dataclass

ScenicExtraTreesDefaults(
    *,
    n_trees: int = 500,
    min_samples_leaf: int = 50,
    n_features_split: int = 0,
    n_thresholds: int = 1,
    max_depth: int = 8,
    subsample_frac: float | None = None,
)

Default parameters for the SCENIC ExtraTrees regression learner

Attributes:

Name Type Description
n_trees int

TODO

min_samples_leaf int

TODO

n_features_split int

TODO

n_thresholds int

TODO

max_depth int

TODO

subsample_frac float | None

TODO

ScenicGradientBoostingDefaults dataclass

ScenicGradientBoostingDefaults(
    *,
    n_trees_max: int = 1000,
    learning_rate: float = 0.01,
    max_depth: int = 3,
    min_samples_leaf: int = 50,
    early_stop_window: int = 25,
    subsample_rate: float = 0.9,
    n_features_split: int = 0,
)

Default parameters for the SCENIC GradientBoosting (GRNBoost2) regression learner

Attributes:

Name Type Description
n_trees_max int

TODO

learning_rate float

TODO

max_depth int

TODO

min_samples_leaf int

TODO

early_stop_window int

TODO

subsample_rate float

TODO

n_features_split int

TODO

ScenicParams dataclass

ScenicParams(
    *,
    min_counts: int = 50,
    min_cells: float = 0.03,
    learner_type: Literal[
        "randomforest", "extratrees", "grnboost2"
    ] = "randomforest",
    gene_batch_strategy: Literal[
        "correlated", "random"
    ] = "correlated",
    gene_batch_size: int | None = None,
    n_pcs: int = 50,
    n_subsample: int = 100000,
    learner_params: LearnerParams | None = None,
)

Constructor for SCENIC parameters.

Attributes:

Name Type Description
min_counts int

Minimum total counts a gene needs to be included.

min_cells float

Minimum proportion of cells, in (0, 1], that must express a gene for it to be considered.

learner_type Literal['randomforest', 'extratrees', 'grnboost2']

Regression learner to use.

gene_batch_strategy Literal['correlated', 'random']

Strategy for grouping target genes into batches. Only used for "randomforest" and "extratrees".

gene_batch_size int | None

Genes per batch. None picks it automatically. Ignored for "grnboost2".

n_pcs int

PCs for the correlated gene batch strategy.

n_subsample int

Cell subsampling threshold of the correlated strategy: at or above it, that many cells are drawn before the randomised SVD.

learner_params LearnerParams | None

The learner block, of the class learner_type names. None takes that class's defaults.

learner property

learner: LearnerParams

The resolved learner block.

ScenicRandomForestDefaults dataclass

ScenicRandomForestDefaults(
    *,
    n_trees: int = 250,
    min_samples_leaf: int = 50,
    n_features_split: int = 0,
    subsample_rate: float = 0.632,
    bootstrap: bool = False,
    max_depth: int = 8,
    subsample_frac: float | None = None,
)

Default parameters for the SCENIC RandomForest regression learner

Attributes:

Name Type Description
n_trees int

TODO

min_samples_leaf int

TODO

n_features_split int

TODO

subsample_rate float

TODO

bootstrap bool

TODO

max_depth int

TODO

subsample_frac float | None

TODO

VisionParams dataclass

VisionParams(
    *,
    n_perm: int = 500,
    n_cluster: int = 5,
    k: int = 15,
    knn_method: Literal[
        "kmknn",
        "hnsw",
        "annoy",
        "nndescent",
        "ivf",
        "exhaustive",
    ] = "kmknn",
    ann_dist: Literal["euclidean", "cosine"] = "euclidean",
    n_trees: int = 50,
    search_budget: int | None = None,
    delta: float = 0.001,
    diversify_prob: float = 0.0,
    ef_budget: int | None = None,
    m: int = 16,
    ef_construction: int = 200,
    ef_search: int = 100,
    n_list: int | None = None,
    n_probe: int | None = None,
)

Wrapper function for parameters for VISION with auto-correlation

Attributes:

Name Type Description
n_perm int

Number of random gene sets to generate per cluster.

n_cluster int

Number of clusters for the random gene set clustering generation.

k int

Number of neighbours.

knn_method Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']

Which method to use for the approximate nearest neighbour search. "nndescent" hands back the graph the NN-Descent built, with no index and no query pass. Rows the descent left short are re-queried exactly.

ann_dist Literal['euclidean', 'cosine']

Which distance metric to use for the approximate nearest neighbour search.

n_trees int

Annoy param: number of trees to generate for Annoy.

search_budget int | None

Annoy param: optional search budget per tree for Annoy. If not provided, it will default to n_tree * k * 20.

delta float

NNDescent param: early termination criterium for NNDescent.

diversify_prob float

NNDescent param: diversification probability. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

ef_budget int | None

NNDescent param: optional query budget. Only used where a query runs against an NN-Descent index, not for the graph of a self kNN.

m int

HNSW param: number of connections between layers for HNSW.

ef_construction int

HNSW param: size of dynamic candidate list during construction.

ef_search int

HNSW param: size of candidate list (higher = better recall, slower).

n_list int | None

IVF param: number of clusters/centroids to generate. None generates sqrt(n) lists.

n_probe int | None

IVF param: number of clusters/centroids to query. None queries sqrt(n_lists) clusters.

NMF

Parameter bundles for the single cell suite.

One frozen dataclass per parameter bundle, flat as Rust sees them: ScrubletParams(no_pcs=10, k=0) rather than nested blocks. Field names match the keys the Rust structs deserialise; each bundle checks its ranges in __post_init__. ScenicParams sits in bixverse.params._scenic.

NmfConsensusParams dataclass

NmfConsensusParams(
    *,
    consensus_target: Literal["h", "w"] = "h",
    n_neighbours: int = 0,
    density_threshold: float = 0.5,
    kmeans_n_init: int = 3,
)

Wrapper function for consensus NMF parameters

Controls the clustering step of consensus NMF: the components of every restart are pooled, outliers are dropped by local density, and the survivors are k-means clustered into k groups whose median becomes the consensus factor.

Attributes:

Name Type Description
consensus_target Literal['h', 'w']

"h" clusters the gene programmes (the spectra), which is what cNMF does and what you almost always want. "w" clusters in sample space instead, which on single cell data means cell space: it pools a dense (k * n_runs) x n_cells matrix and runs an exhaustive cosine search over it, so it gets expensive fast.

n_neighbours int

Neighbours used for the local density estimate. 0 picks ceiling(0.3 * n_runs) for you.

density_threshold float

Components whose mean cosine distance to their neighbours exceeds this are dropped as unstable. Cosine distance cannot exceed 2, so any value >= 2 disables the filter entirely.

kmeans_n_init int

Number of k-means restarts.

NmfHalsParams dataclass

NmfHalsParams(
    *,
    max_iter: int = 250,
    tol: float = 0.0001,
    eps: float = 1e-10,
    check_every: int = 10,
    nmf_init: Literal["nndsvd", "svd", "random"] = "nndsvd",
)

Wrapper function for NMF (HALS) parameters

Attributes:

Name Type Description
max_iter int

Maximum number of HALS iterations.

tol float

Convergence tolerance on the relative change in reconstruction loss.

eps float

Numerical floor for non-negativity / division safety.

check_every int

Convergence check interval in iterations.

nmf_init Literal['nndsvd', 'svd', 'random']

"nndsvd" and "svd" both map to deterministic NNDSVD initialisation; "random" uses random non-negative draws. For stabilised (multi-run) NMF this field is ignored and random init is always used.

Multi-modal

Parameter bundles for the single cell suite.

One frozen dataclass per parameter bundle, flat as Rust sees them: ScrubletParams(no_pcs=10, k=0) rather than nested blocks. Field names match the keys the Rust structs deserialise; each bundle checks its ranges in __post_init__. ScenicParams sits in bixverse.params._scenic.

DsbParams dataclass

DsbParams(
    *,
    denoise_counts: bool = True,
    use_isotype_controls: bool = True,
    pseudocount: float = 10.0,
    quantile_low: float | None = None,
    quantile_high: float | None = None,
)

Default parameters for DSB ADT normalisation

Attributes:

Name Type Description
denoise_counts bool

Run Step II (cell-to-cell technical noise removal).

use_isotype_controls bool

Include isotype controls in the noise matrix in Step II. Requires isotype_indices to be passed at call time.

pseudocount float

Pseudocount added before the log transform. The DSB paper recommends 10 with empty droplets and 1 without.

quantile_low float | None

Optional numeric in [0, 1). Lower quantile for per-protein output clipping. If None (and quantile_high is also None), no clipping is applied.

quantile_high float | None

Optional numeric in (0, 1]. Upper quantile for per-protein output clipping. If None (and quantile_low is also None), no clipping is applied.

KnnGraphDefaults dataclass

KnnGraphDefaults(
    *,
    knn_sym: Literal["snn", "umap", "knn"] = "snn",
    snn_similarity: Literal["jaccard", "rank"] = "jaccard",
    pruning: float = 0.0625,
    rescue: bool = True,
    local_connectivity: float = 1.0,
    mix_ratio: float = 1.0,
    binary: bool = False,
)

Helper function to generate the kNN graph defaults

Controls how a kNN is turned into the undirected, weighted graph that the clustering runs on. "snn" is the shared nearest neighbour graph of bluster/Seurat, "umap" the fuzzy simplicial set ScanPy builds (its obsp/connectivities) and "knn" the plain kNN union. Each method only reads its own parameters.

Attributes:

Name Type Description
knn_sym Literal['snn', 'umap', 'knn']

How to symmetrise the kNN into a graph. Clustering resolutions do not carry over between the methods: the "umap" and "knn" graphs only hold kNN pairs, the sNN graph also links cells that share neighbours and prunes weak edges. The same resolution can give more or fewer communities depending on the data, so retune it when switching.

snn_similarity Literal['jaccard', 'rank']

"snn" only. "jaccard" weighs an edge by the Jaccard index of the two (self-inclusive) neighbour sets. "rank" takes the shared neighbour with the lowest combined rank, so closer shared neighbours give heavier edges. Both are scaled to [0, 1].

pruning float

"snn" only. Edges below this weight are dropped. For the Jaccard weight a threshold p keeps pairs that share at least a fraction 2p / (1 + p) of their (self-inclusive) neighbourhoods, rounded up to whole cells, so the same value means the same thing at any k. The default asks for about 12%, i.e. 2 of 16 shared cells at k = 15, in line with Seurat's 1/15. Avoid a threshold that equals one of the discrete weights exactly, or float rounding decides whether the edge survives.

rescue bool

"snn" only. Reconnect the small components that pruning cuts off via their strongest sNN edge, so they do not turn up as tiny clusters.

local_connectivity float

"umap" only. Number of nearest neighbours assumed to be fully connected, as in umap-learn.

mix_ratio float

"umap" only. 1 is the fuzzy union of the directed kNN memberships, 0 the fuzzy intersection (umap-learn's set_op_mix_ratio).

binary bool

"knn" only. If True, every edge weighs 1. Otherwise mutual neighbours weigh 2 and one-sided ones 1.

Ligand-receptor

Parameter bundles for the single cell suite.

One frozen dataclass per parameter bundle, flat as Rust sees them: ScrubletParams(no_pcs=10, k=0) rather than nested blocks. Field names match the keys the Rust structs deserialise; each bundle checks its ranges in __post_init__. ScenicParams sits in bixverse.params._scenic.

CellphonedbParams dataclass

CellphonedbParams(
    *,
    n_perm: int = 1000,
    threshold: float = 0.1,
    seed: int = 42,
    perm_batch: int | None = None,
)

Parameters for the CellPhoneDB analysis

Defaults match CellPhoneDB v5: 1000 permutations and a 10% expression threshold.

Attributes:

Name Type Description
n_perm int

Number of cluster label permutations for the p-values.

threshold float

Both partners need a fraction of expressing cells strictly above this value in their cluster.

seed int

Seed for the permutations.

perm_batch int | None

Permutations that share one pass over the gene data. None uses the Rust default (16).

LigandTargetParams dataclass

LigandTargetParams(
    *,
    lr_sig_hub: float = 0.0,
    gr_hub: float = 0.0,
    ltf_cutoff: float = 0.99,
    damping_factor: float = 0.5,
    tol: float = 1e-12,
    max_iter: int = 1000,
    topology_correction: bool = False,
    secondary_targets: bool = False,
)

Parameters for ligand to target influence computation

Attributes:

Name Type Description
lr_sig_hub float

Numeric in [0, 1]. Hub correction strength for the ligand- receptor / signalling layer. 0 disables correction.

gr_hub float

Numeric in [0, 1]. Hub correction strength for the gene regulatory layer. 0 disables correction.

ltf_cutoff float

Numeric in [0, 1]. Quantile cutoff applied to the intermediate ligand-to-TF matrix.

damping_factor float

Numeric in [0, 1]. PageRank-style damping factor.

tol float

Numeric > 0. Convergence tolerance (L1 change) for the propagation step. With ltf_cutoff > 0 the output is only stable once the propagation has converged well below the score gaps around the quantile, so keep this tight.

max_iter int

Integer >= 1. Maximum iterations for the propagation step.

topology_correction bool

Apply topology correction.

secondary_targets bool

Run a second round through targets.

DIALOGUE

Parameter bundles for the single cell suite.

One frozen dataclass per parameter bundle, flat as Rust sees them: ScrubletParams(no_pcs=10, k=0) rather than nested blocks. Field names match the keys the Rust structs deserialise; each bundle checks its ranges in __post_init__. ScenicParams sits in bixverse.params._scenic.

DialogueHlmParams dataclass

DialogueHlmParams(
    *,
    min_cells_per_sample: int = 2,
    use_tme_qc: bool = True,
    use_cell_quality: bool = True,
    satterthwaite: bool = True,
)

Wrapper function for the DIALOGUE mixed model parameters

Stage two of DIALOGUE: for every ordered pair of cell types and every candidate gene, a random-intercept mixed model over samples asking whether a cell's own programme score tracks the partner cell type's expression of that gene in the same sample.

Attributes:

Name Type Description
min_cells_per_sample int

Minimum cells a sample must contribute, in both cell types of a pair, before it takes part in that pair's models.

use_tme_qc bool

Include the partner cell type's mean quality in that sample as a fixed effect. Upstream's tme.qc.

use_cell_quality bool

Include the responding cell's own quality as a fixed effect. Upstream's cellQ.

satterthwaite bool

Compute Satterthwaite denominator degrees of freedom, as lmerTest does.

DialoguePmdParams dataclass

DialoguePmdParams(
    *,
    k: int = 2,
    n_permutations: int = 100,
    extra_sparse: bool = False,
    abn_c: int = 15,
    p_anova: float = 0.05,
    centre: bool = True,
    cap: float = 0.01,
    spatial: bool = False,
    n_genes: int = 200,
    min_ci: float = 0.05,
    averaging: Literal["median", "mean"] = "median",
    mcp_assignment_p: float = 0.1,
    seed: int = 1234,
)

Wrapper function for the DIALOGUE decomposition parameters

Stage one of DIALOGUE: the penalised matrix decomposition that turns the per- cell-type features into multicellular programmes, and the provisional gene signatures that come off it.

Attributes:

Name Type Description
k int

Number of multicellular programmes to extract. Must be at least 1.

n_permutations int

Permutations backing the empirical p-value per programme. Must be at least 2.

extra_sparse bool

Tune the L1 bound by permutation instead of fixing it at sqrt(p_1) / 2. Costs ten more fits per permutation.

abn_c int

Minimum cells a sample must contribute, within a cell type, before it counts towards the feature-level ANOVA.

p_anova float

BH-adjusted ANOVA cutoff for keeping a feature. Must be in (0, 1].

centre bool

Centre and scale the sample-level feature matrix, then winsorise it.

cap float

Winsorising tail fraction applied to each column. Must be in [0, 0.5).

spatial bool

Spatial data: skip the ANOVA feature filter entirely. Niches are small, so a feature need not vary across them to be real.

n_genes int

Genes taken per programme per direction when building a signature.

min_ci float

Minimum absolute correlation for a gene to enter a signature. Must be in [0, 1].

averaging Literal['median', 'mean']

How cell-level features are collapsed per sample.

mcp_assignment_p float

Empirical p below which a cell type pair counts as connected when deciding which cell types a programme spans. Must be in (0, 1].

seed int

Seed for the permutation null.

DialogueRefineParams dataclass

DialogueRefineParams(
    *,
    support_p: float = 0.1,
    min_support_fraction: float = 0.3333333333333333,
    min_stratum: int = 5,
    early_stop_cor: float = 0.95,
    permissive_p: float = 0.001,
    strict_p: float = 0.05,
)

Wrapper function for the DIALOGUE refinement parameters

Stage three of DIALOGUE: the cross-partner meta-analysis that decides which genes survive, and the non-negative refit of the programme scores onto them.

Attributes:

Name Type Description
support_p float

Adjusted p below which one partner counts as supporting a gene. Must be in (0, 1].

min_support_fraction float

Minimum supporting fraction for a stratum to enter the staged fit. Must be in [0, 1].

min_stratum int

Minimum genes in a stratum before it is worth fitting.

early_stop_cor float

Correlation between the original score and the running fit at which the staged fit stops early. Must be in (0, 1].

permissive_p float

Fisher-combined p for the permissive gene list, where a gene is carried by partner support rather than by a positive coefficient. Must be in (0, 1].

strict_p float

Fisher-combined p for the strict gene list, which also demands that every partner supports the gene. Must be in (0, 1].