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 gsMapkeeps resolving to gsMap 1.x.One compute backend. PyTorch and JAX must use compatible runtimes; pick exactly one of the
cpu,cuda126,cuda128,cuda130ortpuextras (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 |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
Run name |
|
|
ST input |
|
|
Data type |
2D only |
|
Reference resources |
|
|
Expression layer |
|
|
Cell annotation |
|
|
Homolog mapping |
|
|
One trait |
|
|
Several traits |
|
|
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 spatial2Dwith one--h5ad-pathper section.Registered 3D sections:
--dataset-type spatial3Dwith 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 spatial3Dwith 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.