Output Files Reference¶
This guide provides a comprehensive reference for all output files generated by gsMap. Understanding these files is essential for interpreting results and performing downstream analyses.
Output Directory Structure¶
After running gsMap, the output is organized under {workdir}/{project_name}/ with the following structure:
{project_name}/
├── find_latent_representations/ # Step 1: Latent embeddings
├── latent_to_gene/ # Step 2: Gene specificity scores
├── spatial_ldsc/ # Step 3: Spatial LDSC results
├── cauchy_combination/ # Step 4: Region-level statistics
├── report_data/ # Processed data for analysis
├── gsmap_web_report/ # Interactive web report
├── {project_name}.spatialvista.h5ad # SpatialVista viewer input (spatial3D only)
└── logs/ # Per-run diagnostic logs and manifests
Note
For spatial3D datasets, 3D data and lazy browser payloads are generated in report_data/spatial_3d/ and gsmap_web_report/js_data/spatial_3d/. Single-file thick-tissue reports omit section-style 2D maps and spatial gene plots, but keep UMAP, enrichment, GWAS and gene statistics. spatial_contract.json records computation geometry to prevent incompatible output reuse.
Execution Logs¶
Logs are saved automatically under {workdir}/{project_name}/logs/.
Start with logs/latest/ to inspect the most recent log for each step:
logs/
├── latest/
│ ├── quick_mode.log # Whole pipeline
│ ├── 01_find_latent.log
│ ├── 02_latent_to_gene.log
│ ├── 03_spatial_ldsc.log
│ ├── 03_spatial_ldsc/
│ │ └── {trait}.log # One trait's LDSC log
│ ├── 04_cauchy_combination.log
│ ├── 05_report.log
│ └── run_manifest.json # Latest run's settings and status
└── {run_id}/ # Logs and manifest retained for each run
Only steps that ran have log files. The terminal shows progress and key messages; files also include debug details and full error tracebacks.
CLI and Python runs record timings, settings and sampled peak host memory in
run_manifest.json. RSS includes resident file mappings; Linux PSS accounts
for shared pages. These measure RAM, not GPU VRAM, and can miss brief peaks.
LDSC throughput is reported in cell-traits/s. The final value includes output
writing; multi-GPU totals also include worker setup and merge.
For errors, open the numbered step log or 03_spatial_ldsc/{trait}.log.
The adjacent .manifest.json records that invocation’s settings and status.
Earlier runs remain in their own folders; latest/ can include steps from
different runs.
Step 1: Latent Representations¶
Directory: find_latent_representations/
This directory contains the trained neural network model and the latent embeddings for each sample.
Files¶
File |
Description |
|---|---|
|
H5AD file with added latent embeddings for each sample |
|
Combined training data used for model training |
|
Trained PyTorch model weights |
|
Configuration and training metadata |
Latent H5AD Structure¶
Each {sample_name}_add_latent.h5ad file contains the original data plus:
adata.obsm['emb_cell']: Cell identity embedding (32-dimensional by default)adata.obsm['emb_niche']: Spatial niche embedding (32-dimensional by default)
Metadata YAML¶
The find_latent_metadata.yaml contains:
config:
# Input configuration parameters
model_info:
model_path: ...
n_parameters: 2052647
input_size: [2000, 6000]
hidden_size: 128
embedding_size: 32
training_info:
n_cells_used: 47329
n_genes_used: 2000
n_common_genes: 33525
outputs:
latent_files:
sample1: /path/to/sample1_add_latent.h5ad
...
annotation_info:
annotation_key: layer_guess
n_classes: 7
label_names: [Layer1, Layer2, ...]
Step 2: Latent to Gene (GSS)¶
Directory: latent_to_gene/
This directory contains the gene specificity scores (GSS) computed for each spot.
Files¶
File |
Description |
|---|---|
|
Combined H5AD with all samples |
|
Memory-mapped gene expression ranks (n_spots × n_genes, float16) |
|
Metadata for ranks array (shape, dtype) |
|
Memory-mapped marker scores (n_spots × n_genes, float16) |
|
Metadata for marker scores array |
|
Marker-row to source-H5AD observation mapping (int64) |
|
Mean expression fraction per gene |
|
Configuration and output paths |
Check GSS¶
If you want to check the GSS values, gsMap provides the load_marker_scores_memmap_format Python API, which returns an AnnData object with all spot and gene metadata:
from gsMap.spatial_ldsc.io import load_marker_scores_memmap_format
from gsMap.config import QuickModeConfig
from pathlib import Path
# Run the Visium coronal tutorial first; use the same resources and output paths.
config = QuickModeConfig(
workdir=Path("results"),
project_name="visium-coronal",
dataset_type="spatial2D",
annotation="domain",
spatial_key="spatial",
trait_name="IQ",
sumstats_file=Path("example_data/example-traits/IQ.sumstats.gz"),
)
# Load marker scores as AnnData
gss_adata = load_marker_scores_memmap_format(config)
# Access marker scores as a matrix (spots × genes)
print(gss_adata.X.shape) # (n_spots, n_genes)
# Access spot metadata
print(gss_adata.obs.head())
# Access gene names
print(gss_adata.var_names[:10])
The loader aligns scores, spot IDs, annotations and spatial coordinates, so each
row refers to the same spot. Keep the marker-score files, observation mapping
and concatenated_latent_adata.h5ad together; use this API instead of reading the
raw .dat file directly.
Check Homogeneous Spots¶
The concatenated_latent_adata.h5ad file contains three QC metrics in adata.obs that help assess the quality of homogeneous neighbor identification for each spot:
Column |
Description |
|---|---|
|
Number of valid homogeneous neighbors found for the spot |
|
Median cell embedding similarity between the spot and its homogeneous neighbors |
|
Median niche embedding similarity (only present when dual embeddings are used) |
These metrics can be used to identify spots with poor homogeneous neighbor coverage:
import scanpy as sc
# Load the concatenated latent adata
adata = sc.read_h5ad(
"results/visium-coronal/latent_to_gene/concatenated_latent_adata.h5ad"
)
# Check median cell similarity distribution
print(adata.obs["gsMap_homo_cell_sims_median"].describe())
Step 3: Spatial LDSC¶
Directory: spatial_ldsc/
This directory contains the cell-level trait association results from stratified LD score regression.
Files¶
File |
Description |
|---|---|
|
Compressed CSV with per-spot LDSC results |
CSV Columns¶
Column |
Type |
Description |
|---|---|---|
|
string |
Spot identifier ( |
|
float |
Heritability enrichment coefficient |
|
float |
Standard error of beta |
|
float |
Z-score (beta / se) |
|
float |
P-value (one-tailed) |
|
float |
-log10(p-value) for visualization |
Example¶
spot,beta,se,z,p,neg_log10_p
AAACAACGAATAGTTC-1|Cortex_151507,9.28e-09,3.58e-09,2.593,0.00476,2.323
AAACAAGTATCTCCCA-1|Cortex_151507,2.91e-09,1.89e-09,1.535,0.0624,1.205
Step 4: Cauchy Combination¶
Directory: cauchy_combination/
This directory contains region-level and sample-level aggregated statistics.
Files¶
File |
Description |
|---|---|
|
Aggregated Cauchy test results across all samples |
|
Per-sample Cauchy test results |
|
Combined LDSC results in Parquet format |
Aggregated Cauchy CSV Columns¶
Column |
Type |
Description |
|---|---|---|
|
string |
Trait name |
|
string |
Annotation column name |
|
string |
Annotation value (e.g., “Layer1”, “WM”) |
|
float |
Cauchy combination p-value |
|
float |
Median p-value across spots |
|
float |
95th percentile of -log10(p) |
|
int |
Number of significant spots (p < 0.05 after correction) |
|
int |
Total spots in this annotation |
Sample Cauchy CSV¶
Same columns as above, plus:
Column |
Type |
Description |
|---|---|---|
|
string |
Sample identifier |
Report Data¶
Directory: report_data/
This directory contains processed data files for downstream analysis and visualization.
Core Files¶
File |
Description |
|---|---|
|
Combined spatial LDSC results with -log10(p) values for each trait, plus spot coordinates and annotations |
|
List of genes used in the analysis |
|
Combined Cauchy results for all traits and annotations |
Subdirectories¶
Directory |
Description |
|---|---|
|
Gene-trait correlation statistics |
|
Manhattan plot data per trait |
|
3D spatial data (spatial3D only) |
spot_metadata.csv¶
This is the primary file for downstream analysis, containing all spot-level information.
Columns:
Column |
Type |
Description |
|---|---|---|
|
string |
Spot identifier |
|
float |
2D x-coordinate (pixels) |
|
float |
2D y-coordinate (pixels) |
|
float |
3D x-coordinate (spatial3D only) |
|
float |
3D y-coordinate (spatial3D only) |
|
float |
3D z-coordinate (spatial3D only) |
|
string |
Sample identifier |
|
float |
-log10(p-value) for each trait |
|
string |
Annotation values |
Example:
spot,sx,sy,3d_x,3d_y,3d_z,sample_name,Height,IQ,layer_guess
AAACAACGAATAGTTC-1|Cortex_151507,3276,2514,3276,2514,0.0,Cortex_151507,2.323,1.151,Layer1
AAACAAGTATCTCCCA-1|Cortex_151507,9178,8520,9178,8520,0.0,Cortex_151507,1.205,5.047,Layer3
gene_list.csv¶
Simple list of genes used in the analysis:
gene
MOBP
SPP1
MAG
...
gss_stats/gene_trait_correlation_{trait}.csv¶
Gene-trait correlation statistics for identifying putative causal genes.
Columns:
Column |
Type |
Description |
|---|---|---|
|
string |
Gene symbol |
|
float |
Pearson correlation coefficient between GSS and trait association |
|
string |
Trait name |
|
string |
Annotation (cell type/region) with the highest median GSS for that gene |
|
float |
Median gene specificity score in that annotation |
Example:
gene,PCC,trait,Annotation,Median_GSS
MOBP,0.226,Height,WM,7.969
SPP1,0.225,Height,WM,6.848
MAG,0.225,Height,WM,6.688
manhattan_data/{trait}_manhattan.csv¶
Data for generating Manhattan plots in the reports.
spatial_3d/ (spatial3D only)¶
File |
Description |
|---|---|
|
H5AD file with 3D coordinates and trait values |
Web Report¶
Directory: gsmap_web_report/
This directory contains a self-contained interactive web report.
Structure¶
gsmap_web_report/
├── index.html # Main report entry point
├── report_meta.json # Report configuration
├── js_lib/ # JavaScript libraries (styles are inlined in index.html)
│ ├── alpine.min.js
│ └── plotly.min.js
├── js_data/ # Data files for visualization
│ ├── sample_index.js
│ ├── report_meta.js
│ ├── cauchy_results.js
│ ├── umap_data.js
│ ├── manhattan_{trait}.js
│ ├── gss_stats/
│ │ └── gene_trait_correlation_{trait}.js
│ └── sample_{sample_name}_spatial.js
├── gene_diagnostic_plots/ # Gene expression diagnostic plots
│ └── {gene}_{sample_name}.png
└── spatial_3d/ # 3D visualizations (spatial3D only)
├── spatial_3d_trait_{trait}.html
└── spatial_3d_anno_{annotation}.html
report_meta.json¶
Contains comprehensive metadata about the analysis:
{
"workdir": "/path/to/workdir",
"project_name": "my_project",
"dataset_type": "spatial3D",
"traits": ["Height", "IQ"],
"samples": ["sample1", "sample2"],
"annotations": ["layer_guess"],
"is_3d": true,
"has_3d_widget": true,
"umap_info": {
"has_niche": true,
"cell_emb_key": "emb_cell",
"niche_emb_key": "emb_niche"
}
}
Viewing the Report¶
SpatialVista H5AD¶
For spatial3D datasets, report generation automatically saves
{project_name}.spatialvista.h5ad beside gsmap_web_report/. It contains:
obsm["spatial"]: 3D coordinates.obs: section IDs, annotations and trait −log10(P) values.uns["gsmap"]: metadata for automatic detection and the Query Traits view.
Expression and marker matrices are not duplicated. All result spots are included,
independently of HTML display sampling. Use spatialvista_max_spots /
--spatialvista-max-spots to limit this export, or export_spatialvista=False /
--no-export-spatialvista to disable it. No SpatialVista file is generated for
spatial2D or scRNA datasets.
Install SpatialVista and open the file:
spatialvista --input results/e11-ordinal/e11-ordinal.spatialvista.h5ad
Both the gsMap report-view command and the SpatialVista command are printed at report completion and saved in the report log.
Option 1: Local Viewing¶
Copy the complete gsmap_web_report/ directory to your machine, including all
relative assets. Use the report viewer below for consistent lazy-payload loading;
opening an isolated HTML file is not sufficient.
Option 2: Web Server (Remote)¶
For remote servers, use the built-in report viewer:
# Start a web server on port 8080
gsmap report-view results/visium-coronal/gsmap_web_report --port 8080 --no-browser
Then access the report at http://your-server:8080 or set up SSH port forwarding:
# On your local machine
ssh -L 8080:localhost:8080 user@remote-server
Demonstration¶
Open gsMap Report preview on any tutorial page to explore an online report: Cases on 10x Visium 2D Data, Mouse Embryo 2D (Quick Mode), CS8 human gastrulation or Mouse embryo E11.5.
See Also¶
Key Concepts: Understanding the gsMap pipeline
2D Tutorial: Step-by-step 2D analysis guide
3D Tutorial: Step-by-step 3D analysis guide
CLI Reference: Complete command-line reference