3D Pipeline Tutorial#
This tutorial demonstrates how to use InterSCellar for 3D spatial omics analysis.
Step 1: Cell Neighbor Detection & Graph Construction#
First, detect cell neighbors in 3D space:
import interscellar
neighbors_3d, adata, conn = interscellar.find_cell_neighbors_3d(
ome_zarr_path="data/segmentation.zarr",
metadata_csv_path="data/cell_metadata.csv",
max_distance_um=0.5,
voxel_size_um=(0.56, 0.28, 0.28),
n_jobs=4
)
Parameters#
ome_zarr_path: Path to OME-Zarr file containing 3D segmentationmetadata_csv_path: Path to CSV file with cell metadatamax_distance_um: Maximum distance in micrometers for neighbor detectionvoxel_size_um: Tuple of (z, y, x) voxel sizes in micrometersn_jobs: Number of parallel jobs
Step 2: Interscellar & Cell-Onl Volume Computation#
After detecting neighbors, compute the interscellar volumes:
volumes_3d, adata, conn = interscellar.compute_interscellar_volumes_3d(
ome_zarr_path="data/segmentation.zarr",
neighbor_pairs_csv="results/neighbors_3d.csv",
neighbor_db_path="/results/neighbor_graph.db",
voxel_size_um=(0.56, 0.28, 0.28),
max_distance_um=3.0,
intracellular_threshold_um=1.0,
n_jobs=4
)
Parameters#
ome_zarr_path: Path to OME-Zarr file containing 3D segmentationneighbor_pairs_csv: Path to CSV file with neighbor pairs from step 1neighbor_db_path: Path to database file with neighbor pairs from step 1voxel_size_um: Tuple of (z, y, x) voxel sizes in micrometersmax_distance_um: Maximum distance for volume computationintracellular_threshold_um: Threshold for intracellular volume classificationn_jobs: Number of parallel jobs
Output#
The function returns:
* volumes_3d: DataFrame with interscellar volume measurements
* adata: AnnData object with volume information
* conn: Database connection object
After computing interscellar volumes, you can compute cell-only volumes by subtracting the interscellar volumes from the original segmentation:
cellonly_3d = interscellar.compute_cell_only_volumes_3d(
ome_zarr_path="data/segmentation.zarr",
interscellar_volumes_zarr="results/interscellar_volumes.zarr"
)
Parameters#
ome_zarr_path: Path to original OME-Zarr file containing 3D segmentationinterscellar_volumes_zarr: Path to interscellar volumes zarr file from step 2
The output zarr file is automatically saved in the same directory as the interscellar_volumes_zarr.
Output#
The function returns:
* cellonly_3d: DataFrame with cell-only volume measurements