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 |
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. |
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 |
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. |
n_probe |
int | None
|
IVF param: number of clusters/centroids to query. |
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. |
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 |
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. |
n_probe |
int | None
|
IVF param: number of clusters/centroids to query. |
mean_center |
bool
|
Shall the data be mean centred |
normalise_variance |
bool
|
Shall the data have normalised variance |
clr |
bool
|
Shall the CLR-type |
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 |
svd_solver |
Literal['auto', 'covariance', 'randomised', 'exact']
|
Which solver to use. |
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 |
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']
|
|
e_means_epochs |
float | None
|
e-means only. Passes over the data; |
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 |
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 |
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 |
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 |
k_means_algorithm |
Literal['emeans', 'lloyd']
|
|
e_means_epochs |
float | None
|
e-means only. Passes over the data; |
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']
|
|
loess_span |
float
|
The span parameter for the loess function that is used to
standardise the variance for |
num_bin |
int
|
Number of bins for the |
bin_method |
Literal['equal_width', 'equal_freq']
|
The binning method. |
mean_filter |
bool
|
Shall genes below |
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 |
float
|
Minimum window width, only used with |
min_window_count |
int
|
Minimum number of genes per window, only used with
|
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. |
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 |
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 |
n_probe |
int | None
|
IVF param: number of clusters to query. If |
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 |
snn_similarity |
Literal['jaccard', 'rank']
|
|
pruning |
float
|
|
rescue |
bool
|
|
local_connectivity |
float
|
|
mix_ratio |
float
|
|
binary |
bool
|
|
k |
int
|
Number of neighbours. |
knn_method |
Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']
|
Which method to use for the approximate nearest neighbour
search. |
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 |
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. |
n_probe |
int | None
|
IVF param: number of clusters/centroids to query. |
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 |
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 |
svd_solver |
Literal['auto', 'covariance', 'randomised', 'exact']
|
Which solver to use. |
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
|
|
s_nn |
int
|
|
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. |
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 |
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. |
n_probe |
int | None
|
IVF param: number of clusters/centroids to query. |
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
¶
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 |
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 |
sample_bias |
str | None
|
One of |
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
|
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. |
min_cells |
int
|
Minimum number of cells a gene must be detected in to be
retained. |
clip_min |
float | None
|
Lower residual clipping bound. |
clip_max |
float | None
|
Upper residual clipping bound. |
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. |
loess_span |
float
|
In case of |
clip_max |
float | None
|
The maximum clipping value (optional). |
n_bins |
int
|
The number of bins to use for the |
binning_strategy |
Literal['equal_width', 'equal_frequency']
|
Which binning strategy to use for |
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 |
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 |
float
|
Minimum window width, only used with |
min_window_count |
int
|
Minimum number of genes per window, only used with
|
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 |
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. |
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. |
clip_max |
float | None
|
Upper residual clipping bound. |
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 |
km_type |
Literal['emeans', 'standard', 'minibatch']
|
Which k-means to run for the coarsening: |
e_means_epochs |
float | None
|
|
k_means_iter |
int
|
Number of k-means iterations. Ignored by e-means. |
batch_size |
int
|
|
drift_threshold |
float
|
|
lr_alpha |
float
|
|
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 |
n_anchors |
int
|
Number of nearest centroids each cell links to in the cell-
mediated graph. Only used if |
centroid_k |
int
|
Neighbours per centroid in the exact centroid kNN. Only used if
|
knn_sym |
Literal['snn', 'umap', 'knn']
|
How to symmetrise the kNN into a graph. Clustering resolutions do
not carry over between the methods: the |
snn_similarity |
Literal['jaccard', 'rank']
|
|
pruning |
float
|
|
rescue |
bool
|
|
local_connectivity |
float
|
|
mix_ratio |
float
|
|
binary |
bool
|
|
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 |
beta |
float
|
Leiden only. Randomness of the refinement step. |
min_gain |
float
|
With a negative |
local_moving |
Literal['queue', 'coloured'] | None
|
|
node_order |
Literal['bfs', 'shuffle'] | None
|
Visit order of the queue, |
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 |
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. |
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 |
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. |
n_probe |
int | None
|
IVF param: number of clusters/centroids to query. |
mean_center |
bool
|
Shall the data be mean centred |
normalise_variance |
bool
|
Shall the data have normalised variance |
clr |
bool
|
Shall the CLR-type |
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 |
svd_solver |
Literal['auto', 'covariance', 'randomised', 'exact']
|
Which solver to use. |
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. |
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 |
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. |
n_probe |
int | None
|
IVF param: number of clusters/centroids to query. |
mean_center |
bool
|
Shall the data be mean centred |
normalise_variance |
bool
|
Shall the data have normalised variance |
clr |
bool
|
Shall the CLR-type |
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 |
svd_solver |
Literal['auto', 'covariance', 'randomised', 'exact']
|
Which solver to use. |
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. |
loess_span |
float
|
In case of |
clip_max |
float | None
|
The maximum clipping value (optional). |
n_bins |
int
|
The number of bins to use for the |
binning_strategy |
Literal['equal_width', 'equal_frequency']
|
Which binning strategy to use for |
no_pcs |
int
|
Number of PCs to consider. |
svd_solver |
Literal['randomised', 'auto', 'covariance', 'exact']
|
Which solver to use. |
k |
int
|
Number of neighbours. |
knn_method |
Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']
|
Which method to use for the approximate nearest neighbour
search. |
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 |
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. |
n_probe |
int | None
|
IVF param: number of clusters/centroids to query. |
km_type |
Literal['emeans', 'standard', 'minibatch']
|
The k-means of the fast clustering: |
e_means_epochs |
float | None
|
|
n_centroids |
int | None
|
The number of centroids to use. |
k_means_iter |
int
|
Number of maximum k-means iterations. Ignored by e-means. |
batch_size |
int
|
Max batch size, capped at |
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 |
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
|
init_beta |
float
|
Starting bulk contamination fraction. Set below |
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 |
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 |
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, |
umi_cutoff |
int | None
|
Barcodes with a library size strictly below this are empty.
Required for |
expected_cells |
int | None
|
Number of real cells expected in the run. Required for
|
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
|
manual_threshold |
float | None
|
Manual score threshold. If |
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. |
k |
int
|
Number of neighbours. |
knn_method |
Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']
|
Which method to use for the approximate nearest neighbour
search. |
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 |
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. |
n_probe |
int | None
|
IVF param: number of clusters/centroids to query. |
km_type |
Literal['emeans', 'standard', 'minibatch']
|
The k-means of the fast clustering: |
e_means_epochs |
float | None
|
|
n_centroids |
int | None
|
The number of centroids to use. |
k_means_iter |
int
|
Number of maximum k-means iterations. Ignored by e-means. |
batch_size |
int
|
Max batch size, capped at |
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 |
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. |
loess_span |
float
|
In case of |
clip_max |
float | None
|
The maximum clipping value (optional). |
n_bins |
int
|
The number of bins to use for the |
binning_strategy |
Literal['equal_width', 'equal_frequency']
|
Which binning strategy to use for |
no_pcs |
int
|
Number of PCs to consider. |
svd_solver |
Literal['randomised', 'auto', 'covariance', 'exact']
|
Which solver to use. |
k |
int
|
Number of neighbours. |
knn_method |
Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']
|
Which method to use for the approximate nearest neighbour
search. |
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 |
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. |
n_probe |
int | None
|
IVF param: number of clusters/centroids to query. |
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. |
filter |
bool
|
Run |
min_mean |
float
|
Drop features whose mean count across samples is below this.
Applied on top of |
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 |
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 |
k |
int
|
Number of neighbours. |
knn_method |
Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']
|
Which method to use for the approximate nearest neighbour
search. |
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 |
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. |
n_probe |
int | None
|
IVF param: number of clusters/centroids to query. |
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 |
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 |
kappa |
float
|
Threshold on NEBULA's |
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 |
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 |
iterations |
int
|
Integer >= 0. Number of smoothing iterations. |
tolerance |
float
|
Numeric > 0. Convergence tolerance for the smoothing. |
calibration |
Literal['none', 'column_z']
|
|
score_floor |
float
|
Numeric >= 0. Minimum score for a cell to get a call instead of null. |
purity_threshold |
float
|
Numeric in |
SymphonyMapParams
dataclass
¶
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. |
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 |
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. |
n_probe |
int | None
|
IVF param: number of clusters/centroids to query. |
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. |
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 |
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. |
n_probe |
int | None
|
IVF param: number of clusters/centroids to query. |
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. |
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
|
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 |
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. |
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 |
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. |
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 |
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. |
n_probe |
int | None
|
IVF param: number of clusters/centroids to query. |
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 ~ |
k |
int
|
Number of neighbours. |
knn_method |
Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']
|
Which method to use for the approximate nearest neighbour
search. |
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 |
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. |
n_probe |
int | None
|
IVF param: number of clusters/centroids to query. |
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
¶
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 |
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 |
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 |
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 |
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. |
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 |
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. |
n_probe |
int | None
|
IVF param: number of clusters/centroids to query. |
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.
|
fixed_variance |
float | None
|
The variance for |
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. |
spr_search |
Literal['approximate', 'exact']
|
Subtree pruning and regrafting. |
nni_search |
Literal['approximate', 'exact']
|
Nearest-neighbour interchange. |
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. |
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. |
max_rank |
float | None
|
Rank cutoff for |
standardise |
bool
|
Shall each gene set's scores be z-scored across the cells. This
is what makes |
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 |
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 |
k |
int
|
Number of neighbours. |
knn_method |
Literal['kmknn', 'hnsw', 'annoy', 'nndescent', 'ivf', 'exhaustive']
|
Which method to use for the approximate nearest neighbour
search. |
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 |
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. |
n_probe |
int | None
|
IVF param: number of clusters/centroids to query. |
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
¶
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 |
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 |
gene_batch_size |
int | None
|
Genes per batch. |
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 |
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. |
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 |
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. |
n_probe |
int | None
|
IVF param: number of clusters/centroids to query. |
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']
|
|
n_neighbours |
int
|
Neighbours used for the local density estimate. |
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 |
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']
|
|
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 |
pseudocount |
float
|
Pseudocount added before the log transform. The DSB paper
recommends |
quantile_low |
float | None
|
Optional numeric in |
quantile_high |
float | None
|
Optional numeric in |
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 |
snn_similarity |
Literal['jaccard', 'rank']
|
|
pruning |
float
|
|
rescue |
bool
|
|
local_connectivity |
float
|
|
mix_ratio |
float
|
|
binary |
bool
|
|
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. |
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 |
gr_hub |
float
|
Numeric in |
ltf_cutoff |
float
|
Numeric in |
damping_factor |
float
|
Numeric in |
tol |
float
|
Numeric > 0. Convergence tolerance (L1 change) for the propagation
step. With |
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 |
use_cell_quality |
bool
|
Include the responding cell's own quality as a fixed
effect. Upstream's |
satterthwaite |
bool
|
Compute Satterthwaite denominator degrees of freedom, as
|
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
|
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 |
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 |
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 |
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
|
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 |
min_support_fraction |
float
|
Minimum supporting fraction for a stratum to enter the
staged fit. Must be in |
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 |
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 |
strict_p |
float
|
Fisher-combined p for the strict gene list, which also demands
that every partner supports the gene. Must be in |