API reference#

metalsinglecell mirrors the scanpy / squidpy namespaces: pp (preprocessing), tl (tools), gr (spatial graph). Import as:

import metalsinglecell as msc

Preprocessing — msc.pp#

calculate_qc_metrics

Per-cell/per-gene QC metrics (sc.pp.calculate_qc_metrics).

filter_cells

Filter cells (sc.pp.filter_cells); subsets adata in place.

filter_genes

Filter genes (sc.pp.filter_genes); subsets adata in place.

normalize_total

Normalize counts per cell (sc.pp.normalize_total).

log1p

log(1 + x) (sc.pp.log1p); records adata.uns['log1p'].

normalize_pearson_residuals

Analytic Pearson residuals (sc.experimental.pp.normalize_pearson_residuals).

highly_variable_genes

Highly variable genes (sc.pp.highly_variable_genes); writes adata.var columns.

scale

Z-score genes then clip (sc.pp.scale).

regress_out

Regress out covariates in adata.obs[keys] (sc.pp.regress_out).

pca

PCA (sc.pp.pca); writes obsm['X_pca'], varm['PCs'], uns['pca'].

neighbors

kNN graph (sc.pp.neighbors); writes obsp['distances']/['connectivities'], uns['neighbors'].

bbknn

Batch-balanced kNN (sc.external.pp.bbknn); writes obsp + uns['neighbors'].

harmony_integrate

Harmony batch integration (sc.external.pp.harmony_integrate); writes obsm[adjusted_basis].

scrublet

Doublet detection (sc.pp.scrublet); writes obs['doublet_score']/['predicted_doublet'].

Tools — msc.tl#

leiden

Leiden clustering (sc.tl.leiden); writes adata.obs[key_added] (categorical).

louvain

Louvain clustering (sc.tl.louvain); writes adata.obs[key_added] (categorical).

kmeans

k-means on an embedding; writes adata.obs[key_added] (categorical).

umap

UMAP embedding (sc.tl.umap); writes adata.obsm['X_umap'].

tsne

t-SNE (sc.tl.tsne); writes adata.obsm['X_tsne'].

diffmap

Diffusion map (sc.tl.diffmap); writes obsm['X_diffmap'] + uns['diffmap_evals'].

draw_graph

Force-directed layout (sc.tl.draw_graph); writes obsm[f'X_draw_graph_{layout}'].

embedding_density

Per-cell density in an embedding (sc.tl.embedding_density); writes obs[f'{basis}_density'].

rank_genes_groups

Marker genes per group (sc.tl.rank_genes_groups); writes scanpy-format adata.uns[key_added].

score_genes

Gene-set score (sc.tl.score_genes); writes adata.obs[score_name].

score_genes_cell_cycle

S/G2M scores + phase (sc.tl.score_genes_cell_cycle); writes obs['S_score'/'G2M_score'/'phase'].

Spatial graph — msc.gr#

spatial_neighbors

Spatial graph from coordinates (sq.gr.spatial_neighbors); writes obsp['spatial_*'].

spatial_autocorr

Moran's I / Geary's C per gene (sq.gr.spatial_autocorr); writes uns['moranI']/['gearyC'].

co_occurrence

Cluster co-occurrence vs distance (sq.gr.co_occurrence); writes uns[f'{cluster_key}_co_occurrence'].

ligrec

Ligand-receptor permutation test (sq.gr.ligrec); writes uns[key_added] (means/pvalues).

calculate_niche

Spatial niches from neighborhood composition (sq.gr.calculate_niche); writes obs[key_added].