GitHub
Back to all tutorials

Spatial analysis

Spatial Analysis - MERFISH

This tutorial shows how to load a Vizgen MERSCOPE MERFISH 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 Vizgen MERFISH Mouse Brain Receptor Map dataset. Open the Vizgen page, fill out the access form, then follow the Google Drive link provided by Vizgen to download the data files for one sample.

Open the Vizgen MERFISH Mouse Brain Receptor Map page

The dataset page describes nine mouse brain slices and provides per-sample downloads. For this tutorial, choose one sample folder such as S1R1, download it from Google Drive, and keep the CSV file names unchanged.

1. Prepare the MERFISH folder

CellPilot accepts a standard Vizgen/MERSCOPE output folder directly. The selected folder must contain the cell-by-gene count matrix and cell metadata file.

cell_by_gene.csv
cell_metadata.csv
cell_categories.csv
cell_numeric_categories.csv

cell_by_gene.csv and cell_metadata.csv are required. CellPilot uses cell_by_gene.csv for expression counts and cell_metadata.csv for spatial coordinates such as center_x and center_y. The cell_categories.csv and cell_numeric_categories.csv files are optional; when present, CellPilot can use them for precomputed clusters and UMAP coordinates.

2. Load the MERFISH dataset

  1. Open CellPilot.
  2. In the Data Type menu, choose Spatial analysis - MERFISH.
  3. Choose Single sample.
  4. Click Browse and select the folder containing the Vizgen CSV files.
  5. Wait for CellPilot to parse the counts matrix and spatial coordinates.

CellPilot converts the MERFISH cell-by-gene CSV into a MatrixMarket-style dataset internally, filters out Blank* control columns, and keeps the spatial coordinates aligned to the loaded cells.

3. Inspect spatial clusters and marker genes

Use the spatial view to inspect where cell clusters appear across the 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 Slc17a7
Violin plot Slc17a7
Dotplot Slc17a7 Gad1 Mbp
Change color to green black red

MERFISH measures a targeted gene panel, so only genes present in the downloaded panel can be plotted directly.

4. Adjust analysis parameters

CellPilot can rerun core RNA-style analysis steps on the MERFISH cell-by-gene 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. Impute unmeasured genes with a reference

If you have a matched or biologically relevant scRNA-seq reference, CellPilot can impute genes that were not included in the MERFISH panel. Load the MERFISH dataset first, then choose the gene imputation option and select your scRNA-seq reference file.

Impute Pcp4 expression
Impute Reln expression
Impute Vip expression

CellPilot uses SpaGE-style reference mapping to predict the requested gene expression on the spatial tissue view.

6. 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

7. 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

8. 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 cortex
Find markers for the selected spatial region