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

{sample_name}_add_latent.h5ad

H5AD file with added latent embeddings for each sample

training_adata.h5ad

Combined training data used for model training

LGCN_model/gsMap_LGCN_.pt

Trained PyTorch model weights

find_latent_metadata.yaml

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

concatenated_latent_adata.h5ad

Combined H5AD with all samples

ranks.dat

Memory-mapped gene expression ranks (n_spots × n_genes, float16)

ranks.meta.json

Metadata for ranks array (shape, dtype)

marker_scores.dat

Memory-mapped marker scores (n_spots × n_genes, float16)

marker_scores.meta.json

Metadata for marker scores array

marker_scores.obs_indices.dat

Marker-row to source-H5AD observation mapping (int64)

mean_frac.parquet

Mean expression fraction per gene

metadata.yaml

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

gsMap_homo_neighbor_count

Number of valid homogeneous neighbors found for the spot

gsMap_homo_cell_sims_median

Median cell embedding similarity between the spot and its homogeneous neighbors

gsMap_homo_niche_sims_median

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

{project_name}_{trait_name}.csv.gz

Compressed CSV with per-spot LDSC results

CSV Columns

Column

Type

Description

spot

string

Spot identifier ({barcode}|{sample_name})

beta

float

Heritability enrichment coefficient

se

float

Standard error of beta

z

float

Z-score (beta / se)

p

float

P-value (one-tailed)

neg_log10_p

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

{project_name}_{trait}.{annotation}.cauchy.csv

Aggregated Cauchy test results across all samples

{project_name}_{trait}.{annotation}.sample_cauchy.csv

Per-sample Cauchy test results

{project_name}_combined_ldsc.parquet

Combined LDSC results in Parquet format

Aggregated Cauchy CSV Columns

Column

Type

Description

trait

string

Trait name

annotation_name

string

Annotation column name

annotation

string

Annotation value (e.g., “Layer1”, “WM”)

p_cauchy

float

Cauchy combination p-value

p_median

float

Median p-value across spots

top_95_quantile

float

95th percentile of -log10(p)

sig_spots

int

Number of significant spots (p < 0.05 after correction)

total_spots

int

Total spots in this annotation

Sample Cauchy CSV

Same columns as above, plus:

Column

Type

Description

sample_name

string

Sample identifier


Report Data

Directory: report_data/

This directory contains processed data files for downstream analysis and visualization.

Core Files

File

Description

spot_metadata.csv

Combined spatial LDSC results with -log10(p) values for each trait, plus spot coordinates and annotations

gene_list.csv

List of genes used in the analysis

cauchy_results.csv

Combined Cauchy results for all traits and annotations

Subdirectories

Directory

Description

gss_stats/

Gene-trait correlation statistics

manhattan_data/

Manhattan plot data per trait

spatial_3d/

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

spot

string

Spot identifier

sx

float

2D x-coordinate (pixels)

sy

float

2D y-coordinate (pixels)

3d_x

float

3D x-coordinate (spatial3D only)

3d_y

float

3D y-coordinate (spatial3D only)

3d_z

float

3D z-coordinate (spatial3D only)

sample_name

string

Sample identifier

{trait_name}

float

-log10(p-value) for each trait

{annotation}

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

gene

string

Gene symbol

PCC

float

Pearson correlation coefficient between GSS and trait association

trait

string

Trait name

Annotation

string

Annotation (cell type/region) with the highest median GSS for that gene

Median_GSS

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

spatial_3d.h5ad

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