download_if_needed
URL to download from.
Local destination path.
check_server
Base URL of the inference server (e.g.
http://localhost:8080).HTTP request timeout in seconds.
GET /ping.
display_slide_info
Path to the whole-slide image file.
Maximum
(width, height) of the returned thumbnail.display_rna_summary
Path to a tab-separated RNA-seq counts file.
read_gene_mapping
Path to the CSV or TSV file.
Column containing gene symbols (e.g.
"gene_name").Column containing gene identifiers (e.g.
"gene_id").Column delimiter. Inferred from file extension when
None (.tsv → tab, otherwise comma).When
True, strips version suffixes from the id_column (e.g. ENSG00000119888.12 → ENSG00000119888).load_zarr_output
Path to the Zarr store directory.
outputs, coords, metadata, and
optionally gene_names (M-Optimus predictions), thumbnail,
tissue_mask, and tissue_ratios.
See https://docs.bioptimus.com/guides/get-started/visualizing-results
convert_spot_to_coord
tissue_positions table (spot centres in full-resolution pixels) into the (x, y) top-left tile positions that Inference expects via its coordinates argument. Two conversions are applied:
- Resolution scaling. Spot pixels are at the slide’s native
resolution (native_mpp), but the model reads tiles at tile_mpp, so centres are scaled by
native_mpp / tile_mpp. - Centre → top-left. The model always reads a fixed
tile_px x tile_pxwindow, so the top-left is the scaled centre minus half the tile size (tile_px // 2). Anchoring on the tile size (rather than the spot’s own footprint) keeps the model’s window centred on each spot regardless of the spot/bin size.
Path to a 10x
tissue_positions CSV with spot centres in full-resolution pixels.Microns-per-pixel of the slide’s full resolution (read from the WSI reader, e.g.
reader.mpp).Tile edge in pixels the model reads (e.g.
224).Microns-per-pixel the model expects (e.g.
0.5).Column holding the spot centre x in full-resolution pixels.
Column holding the spot centre y in full-resolution pixels.
(coordinates, spots) where coordinates is a list of
(x, y) top-left, slide-origin pixel pairs at the tile resolution
(ready to pass as Inference(..., coordinates=...)), and spots is
the loaded table augmented with integer tile_x/tile_y columns
(row-aligned with coordinates) for downstream benchmark alignment.
Example:
load_spot_size_um
(width, height) in microns from metadata.
Reads a platform metadata.json (10x-style) and converts the spot footprint to microns. Informational only — the model reads a fixed tile window regardless of spot size — but useful to report the spot footprint against the model’s field of view.
Path to a
metadata.json with tile_shape ({"width", "height"}) or a scalar spot_diameter in full-resolution pixels.Microns-per-pixel of the slide’s full resolution.
(width_um, height_um).
plot_slide_and_mask
Path to the whole-slide image file.
Path to the tissue mask image (PNG).
Binarization threshold for the mask.
Matplotlib figure size
(width, height).plot_pca_scatter
Tile embeddings array of shape
(n_tiles, dim).Number of PCA components to compute.
Plot title.
Matplotlib colormap name.
Figure size
(width, height).Scatter point size.
(scores, pca) tuple — the transformed array and the fitted
PCA object.
plot_spatial_pca
PCA-transformed array of shape
(n_tiles, n_components).Tile coordinates of shape
(n_tiles, 2).Indices of PCs to plot (0-indexed).
Prefix prepended to each subplot title.
Figure size
(width, height).plot_nearest_neighbor_tiles
Tile embeddings array of shape
(n_tiles, dim).Tile coordinates array of shape
(n_tiles, 2).Path to the WSI file for reading tile images.
Specific tile indices to use as queries. If None,
n_queries tiles are sampled from distinct PCA regions.Number of query tiles (used when query_indices is None).
Number of nearest neighbors to show per query.
Tile width/height in pixels at the target resolution.
Microns per pixel for tile extraction.
Random seed for reproducible query selection.
Figure size per tile in inches.
plot_gene_overlay
Per-tile expression values of shape
(n_tiles,).Tile coordinates of shape
(n_tiles, 2).Path to the whole-slide image file.
Gene symbol for the title.
Custom plot title (overrides gene_name).
Matplotlib colormap name.
Heatmap overlay opacity.
Colormap minimum.
Colormap maximum.
Existing axes to draw on. Creates a new figure when
None.Figure size when creating a new figure.
Maximum
(width, height) of the slide thumbnail.plot_gene_overlay_comparison
Predictions array for condition A, shape
(n_tiles, n_genes).Tile coordinates for condition A.
Predictions array for condition B.
Tile coordinates for condition B.
Column index of the gene to plot.
Path to the whole-slide image file.
Gene symbol for the title.
Display label for condition A.
Display label for condition B.
Slide identifier shown in the title.
Matplotlib colormap name.
Heatmap overlay opacity.
Figure size
(width, height).Maximum
(width, height) of the slide thumbnail.plot_gene_panel_overlay
Predictions array of shape
(n_tiles, n_genes).Tile coordinates of shape
(n_tiles, 2).List of gene identifiers matching prediction columns.
Mapping of gene symbol → identifier to visualize.
Path to the whole-slide image file.
Number of columns in the subplot grid.
Size
(width, height) per subplot.Matplotlib colormap name.
Heatmap overlay opacity.
Maximum
(width, height) of the slide thumbnail.plot_top_gene_tiles
Predictions array of shape
(n_tiles, n_genes).Tile coordinates of shape
(n_tiles, 2).Column index of the gene to plot.
Path to the whole-slide image file.
Gene symbol for the plot title.
Number of highest-expression tiles to show.
Number of lowest-expression tiles to show.
Tile width/height in pixels.
Microns per pixel for tile extraction.
Figure size per tile in inches.
plot_spatial_gene
Per-tile expression values of shape
(n_tiles,).Tile coordinates of shape
(n_tiles, 2).Gene symbol for the title.
Custom plot title (overrides gene_name).
Matplotlib colormap name.
Colormap minimum.
Colormap maximum.
Existing axes to draw on. Creates a new figure when
None.Figure size when creating a new figure.
plot_gene_comparison
Predictions array for condition A, shape
(n_tiles, n_genes).Tile coordinates for condition A.
Predictions array for condition B.
Tile coordinates for condition B.
Column index of the gene to plot.
Gene symbol for the title.
Display label for condition A.
Display label for condition B.
Slide identifier shown in the title.
Matplotlib colormap name.
Figure size
(width, height).plot_gene_panel
Predictions array of shape
(n_tiles, n_genes).Tile coordinates of shape
(n_tiles, 2).List of gene identifiers matching prediction columns.
Mapping of gene symbol → identifier to visualize.
Number of columns in the subplot grid.
Size
(width, height) per subplot.Matplotlib colormap name.

