Spatial analysis
Spatial Analysis - CosMx
This tutorial shows how to load a Bruker/NanoString CosMx dataset in CellPilot, inspect spatial expression, explore marker genes, ask questions about selected tissue regions, and run spatial region analysis.
Input data
This walkthrough uses the CosMx Human Whole Transcriptome Colon Dataset from Bruker Spatial Biology. Open the dataset page and click Download Data to obtain the CosMx output files.
Open the Bruker Spatial Biology CosMx colon dataset page
The dataset demonstrates CosMx whole-transcriptome profiling of an FFPE sigmoid adenocarcinoma sample. After downloading, keep the exported CosMx file names unchanged.
1. Prepare the CosMx folder
CellPilot accepts a standard CosMx output folder directly. The selected folder must contain one expression matrix file and one metadata file with the expected CosMx suffixes.
*_exprMat_file.csv
*_metadata_file.csv
Gzipped versions are also supported, such as *_exprMat_file.csv.gz and *_metadata_file.csv.gz. CellPilot uses the expression matrix for gene counts and the metadata file for spatial coordinates, including columns such as fov, cell_ID, CenterX_global_px, and CenterY_global_px.
2. Load the CosMx dataset
- Open CellPilot.
- In the Data Type menu, choose Spatial analysis - CosMx.
- Choose Single sample.
- Click Browse and select the folder containing the CosMx CSV files.
- Wait for CellPilot to parse the expression matrix and spatial metadata.
For large CosMx expression files, CellPilot stream-parses the matrix and caches the converted files locally, so the first load can take longer than later loads. CellPilot filters out NegPrb* negative-control columns and keeps the spatial coordinates aligned using combined fov_cell_ID cell identifiers.
3. Inspect spatial clusters and marker genes
Use the spatial view to inspect where cell clusters appear across the colon tissue section. Then use chat commands to find markers, plot genes, and adjust the color scale.
Tell me about cluster 6
Find markers for cluster 6
Plot EPCAM
Violin plot EPCAM
Dotplot EPCAM KRT19 COL1A1
Change color to green black red
This demo dataset is whole transcriptome, so most protein-coding genes can be explored directly without imputation.
4. Adjust analysis parameters
CellPilot can rerun core RNA-style analysis steps on the CosMx expression matrix while keeping spatial coordinates available for tissue visualization.
Rerun the analysis by setting min gene = 20
Rerun umap with min dist = 0.4
Recluster the cells using resolution = 2.0
5. Select a region and ask about it
In the Spatial View, draw or select a tissue region that you want to inspect. CellPilot can summarize the selected area, report marker genes, and help interpret the likely cell type composition of that region.
What is this region?
What cell types are in the selected region?
Find markers for the selected spatial region
6. Run cell-cell interaction analysis
After selecting at least two spatial regions, CellPilot can run ligand-receptor style cell-cell communication analysis across the selected tissue areas.
Run cell-cell interaction analysis across selected regions
7. Run BANKSY spatial region analysis
CellPilot can identify tissue domains automatically with BANKSY region segmentation, which uses expression and spatial neighborhood structure. After regions are created, they can be viewed, renamed, and used for marker analysis.
Run BANKSY region segmentation
Show regions
What cell types are in region 1?
Rename region 1 to tumor
Find markers for the selected spatial region