Upgrading to gsMap 2.0

gsMap 2.0 is a major release. It adds 3D spatial transcriptomics support and replaces the command-line interface, the reference resources and the output layout of gsMap 1.x. gsMap 1.x analyses are not affected: install "gsMap<2" to keep using them.

Requirements

  • Python 3.12 or later. On Python 3.10 and 3.11, pip install gsMap keeps resolving to gsMap 1.x.

  • One compute backend. PyTorch and JAX must use compatible runtimes; pick exactly one of the cpu, cuda126, cuda128, cuda130 or tpu extras (Installation).

Commands

Commands use hyphenated names. Run gsmap COMMAND --help or see CLI reference. Each step can also be run from Python with the configuration class of the same name from gsMap.config.

gsMap 1.x

gsMap 2.x CLI

gsMap 2.x Python API

gsmap quick_mode

gsmap quick-mode

run_quick_mode(QuickModeConfig(...))

gsmap run_find_latent_representations

gsmap find-latent

run_find_latent_representation(FindLatentRepresentationsConfig(...))

gsmap run_latent_to_gene

gsmap latent-to-gene

run_latent_to_gene(LatentToGeneConfig(...))

gsmap run_generate_ldscore

gsmap ldscore-weight-matrix, once per LD reference (see below)

LDScorePipeline(LDScoreConfig(...)).run()

gsmap run_spatial_ldsc

gsmap spatial-ldsc

run_spatial_ldsc_jax(SpatialLDSCConfig(...))

gsmap run_cauchy_combination

gsmap cauchy-combination

run_Cauchy_combination(CauchyCombinationConfig(...))

gsmap run_report

gsmap quick-mode --start-step report; view with gsmap report-view

run_quick_mode(QuickModeConfig(..., start_step="report"))

gsmap format_sumstats

gsmap format-sumstats

gwas_format(FormatSumstatsConfig(...))

gsmap create_slice_mean

not needed: pass all sections to one run (Multiple sections)

not needed

The Python functions are imported from:

from gsMap.cauchy_combination_test import run_Cauchy_combination
from gsMap.find_latent import run_find_latent_representation
from gsMap.format_sumstats import gwas_format
from gsMap.latent2gene import run_latent_to_gene
from gsMap.ldscore.pipeline import LDScorePipeline
from gsMap.pipeline import run_quick_mode
from gsMap.spatial_ldsc.spatial_ldsc_jax import run_spatial_ldsc_jax

To run part of the pipeline, use gsmap quick-mode --start-step STEP --stop-step STEP with the steps find_latent, latent2gene, spatial_ldsc, cauchy and report.

Common quick-mode options

Purpose

gsMap 1.x

gsMap 2.x

Output directory

--workdir

--workdir

Run name

--sample_name

--project-name

ST input

--hdf5_path (one file)

--h5ad-path (repeatable), --h5ad-list-file or --h5ad-yaml

Data type

2D only

--dataset-type spatial2D, spatial3D or scRNA

Reference resources

--gsMap_resource_dir

--w-ld-dir and --snp-gene-weight-adata-path

Expression layer

--data_layer

--data-layer

Cell annotation

--annotation

--annotation

Homolog mapping

--homolog_file

--homolog-file, with --species naming the species-symbol column

One trait

--trait_name, --sumstats_file

--trait-name, --sumstats-file

Several traits

--sumstats_config_file

--sumstats-config-file

Embedding and neighbor-selection options were redesigned for the dual-embedding model. Start from the defaults and see Customization Guide before tuning them.

Reference resources

gsMap 1.x computed LD scores for every sample with run_generate_ldscore. gsMap 2.x instead reads a precomputed SNP-by-gene weight matrix (--snp-gene-weight-adata-path) and matching LD regression weights (--w-ld-dir), and combines them with gene specificity scores during spatial-ldsc.

  • Download the GRCh38 1000 Genomes high-coverage references (several ancestries) from Downloads.

  • To use another LD panel or gene annotation, build the matrix once with gsmap ldscore-weight-matrix (Compute custom LD-weight matrices).

Multiple sections

gsMap 1.x analyzed sections one at a time and could share gene ranks across sections with create_slice_mean. gsMap 2.x analyzes all sections in one run:

  • Separate 2D sections: --dataset-type spatial2D with one --h5ad-path per section.

  • Registered 3D sections: --dataset-type spatial3D with XYZ coordinates and the H5AD files listed in anatomical order along Z. Cross-section matching of homogeneous cells is controlled by --n-adjacent-slices.

  • One thick-tissue volume: --dataset-type spatial3D with a single XYZ H5AD file.

See Key Concepts for the coordinate requirements.

Python API

from gsMap.config import DatasetType, QuickModeConfig
from gsMap.pipeline import run_quick_mode

config = QuickModeConfig(
    workdir="results",
    project_name="my-project",
    dataset_type=DatasetType.SPATIAL_2D,
    h5ad_path=["data/section.h5ad"],
    w_ld_dir="resources/1000g-hc-grch38-v50-eur/w_ld",
    snp_gene_weight_adata_path="resources/1000g-hc-grch38-v50-eur/snp_gene_weights.h5ad",
    annotation="cell_type",
    trait_name="IQ",
    sumstats_file="gwas/IQ.sumstats.gz",
)
run_quick_mode(config)

Outputs

Results are written to {workdir}/{project_name}/, with one folder per step and an interactive report in gsmap_web_report/. Start 2.x analyses in a new working directory. See Output Files Reference for the layout and file formats.