Skip to content

iscc.data.Visium

Visium(count_model='dm', batch_label=None, n_reads=None, spot_pitch=None, spot_radius=None, mu_counts=None, sigma_counts=None, field_lengthscale=None, field_sigma=None, edge_sigma=None, diffusion_sigma=None, sigma_batch=None, ambient_frac=None, kappa=None, nb_dispersion=None, n_spots_x=None, n_spots_y=None, seed=42)

Bases: Assay

Visium spatial assay: lays spots over the section, aggregates cells, applies a VisiumBatch.

Any hyper-parameter below can be overridden explicitly (None keeps the default, which is calibrated to a real 10x Visium section). Legacy aliases are accepted: n_reads maps onto mu_counts, and a spot grid requested via n_spots_x / n_spots_y derives spot_pitch from grid_side at run time. The number of spots (and cells per spot) follows from grid_side (passed to run) and the sampled cell_data, so there is no n_cells.

Parameters:

Name Type Description Default
count_model str

Final count-emission model: "dm" Dirichlet-multinomial (compositional per-spot capture, the Visium default) or "nb" negative-binomial (independent per-gene).

"dm"
batch_label str

Section/batch label; defaults to f"visium{seed}".

None
n_reads float

Legacy alias for mu_counts (mean per-spot library size).

None
spot_pitch float

Spot centre-to-centre spacing (coordinate units); sets spot density / number of spots. Overridden at run time if n_spots_x / n_spots_y are given.

2.0
spot_radius float

Spot capture radius: cells within this distance of a spot centre are pooled into it (~1-10 cells / spot).

1.0
mu_counts float

Mean per-spot library size (total UMIs / spot); ell_s ~ LogNormal(log mu_counts, sigma_counts^2) × capture_field.

20000.0
sigma_counts float

Per-spot library-size LogNormal sd (spot-to-spot depth variation).

0.45
field_lengthscale float

Spatial autocorrelation length of the capture-efficiency field (the squared-exponential GP length-scale, in coordinate units); larger -> smoother field -> higher Moran's I.

18.0
field_sigma float

Capture-field strength (log-space sd of the smooth positive field); 0 -> flat field (no spatial capture bias).

0.70
edge_sigma float

Tissue-boundary capture falloff: the very edge of the section is reduced by this fraction, the interior stays ~1. 0 disables; a value < 1 keeps efficiency positive.

0.30
diffusion_sigma float

Lateral mRNA-bleed Gaussian kernel sd, spreading each spot's expression into its neighbours before counting; 0 disables (no bleed).

0.0
sigma_batch float

Per-gene batch-factor LogNormal sd, shared across spots (Splatter batch.facScale).

0.10
ambient_frac float

Fraction of each spot's library drawn as ambient "soup" contamination.

0.05
kappa float

Dirichlet-multinomial concentration (only for count_model="dm"); large -> ~ multinomial, small -> lumpy proportions.

50.0
nb_dispersion float

Negative-binomial overdispersion phi (var = mu + phi*mu^2; only for count_model="nb").

0.30
n_spots_x int

Legacy alias: request a fixed spot-grid width. When both n_spots_x and n_spots_y are set, the pitch is derived as grid_side / max(n_spots_x, n_spots_y) at run time instead of using spot_pitch.

None
n_spots_y int

Legacy alias: request a fixed spot-grid height (see n_spots_x).

None
seed int

RNG seed. Fixes the technical signature (per-gene batch factor, spatial capture field, per-spot depth) and is reproducible.

42

Methods:

Name Description
run

Assay a 10x Visium spatial-transcriptomics section over the sampled cells.

run

run(cell_data, grid_side)

Assay a 10x Visium spatial-transcriptomics section over the sampled cells.

Lays out a grid_side x grid_side grid of spots, pools each spot's cells, applies lateral mRNA diffusion and a smooth spatial capture field, and draws per-spot UMI counts.

Parameters:

Name Type Description Default
cell_data dict

Per-cell ground-truth tables from the sampling stage; uses the expression table cell_exp and the spatial coordinates cell_crd.

required
grid_side int

Number of spots along each side of the (square) section.

required

Returns:

Type Description
Visium

self, with the spot-by-gene UMI matrix in spot_counts, spot coordinates in spot_coords, and the per-spot ground-truth/QC table in obs. Call to_anndata or write to export.

Technology presets

Platform Parameters Notes
10x Visium defaults (spot_pitch = 2, spot_radius = 1, mu_counts ≈ 20000) ~55 µm spots, ~1–10 cells / spot.
Visium HD smaller spot_pitch / spot_radius, lower mu_counts High-resolution (near-single-cell): many more, smaller spots.