CLI reference¶
Generated from the current gsMap.cli application; do not edit by hand.
gsmap¶
gsMap: genetically informed spatial mapping of cells for complex traits
Option |
Description |
|---|---|
|
Show version and exit |
|
Show this message and exit. |
gsmap quick-mode¶
Run the complete gsMap pipeline with all steps.
This command runs the gsMap analysis pipeline including:
Data loading and preprocessing (Find Latent)
Gene expression analysis (Latent to Gene)
GWAS integration (Spatial LDSC)
Cauchy Combination Test
Result generation (Report)
Requires pre-generated SNP-gene weight matrix and LD weights.
Option |
Description |
|---|---|
|
Path to the working directory [required] |
|
Name of the project [required] |
|
Type of dataset: scRNA, spatial2D (XY), or spatial3D (XYZ sections or a single thick-tissue volume) [default: spatial2D] |
|
Space-separated list of h5ad file paths. Sample names are derived from file names without suffix. |
|
YAML file with sample names and h5ad paths |
|
Each row is a h5ad file path, sample name is the file name without suffix |
|
Expression data layer in h5ad layers, e.g., ‘count’, ‘counts’; use ‘X’ for adata.X [default: X] |
|
Minimum positive-expression genes before HVG, training, graph and inference [default: 20; x>=0] |
|
Optional minimum total raw counts for front-end cell QC [x>=0] |
|
Rows per bounded expression QC/read block [default: 8192; x>=1] |
|
Spatial key in adata.obsm [default: spatial] |
|
Name of the annotation in adata.obs to use |
|
Path to homologous gene conversion file |
|
Species-symbol column in the homolog file (for example MOUSE_GENE_SYM) |
|
Key for spatial niche embedding in obsm |
|
Key for cell identity embedding in obsm [default: emb_cell] |
|
Opt in to annotation module-score QC (not sequencing-quality QC). Computes DEGs and module scores; disabled by default. [default: no-high-quality-cell-qc] |
|
Number of external neighbors for corrected LGCN graphs [default: 10; 1<=x<=50] |
|
Spatial graph mode: symmetric_knn (default), radius, weighted_radius, sectionwise_2d, section_aware_3d, no_graph, or revision-only legacy_bug/legacy_symmetric [default: symmetric_knn] |
|
Physical radius for radius graph modes [x>=0.0] |
|
Gaussian sigma for weighted-radius edges [x>=0.0] |
|
Multiplier converting the stored z coordinate to the physical XY units for section_aware_3d graphs [default: 1.0; x>=0.0] |
|
Target number of focal spots per section-aligned inference chunk. Physical sections remain intact, all spots are retained, and section-aware chunks include graph halos. [default: 250000; x>=1] |
|
Tune the cell embeddings based on the provided annotation [default: single-stage] |
|
Number of cells used for training [default: 100000; 1000<=x<=1000000] |
|
Expression QC contract: counts requires finite nonnegative values; noncounts permits finite signed values with external embeddings, counts distinct nonzero features for min_genes, and requires –no-expression-fraction. [default: counts] |
|
k1: Number of spatial neighbors in it’s own slice for spatial dataset [default: 301; 10<=x<=5000] |
|
k3: Number of homogeneous neighbors per cell (for spatial) or KNN neighbors (for scRNA-seq) [default: 21; 1<=x<=200] |
|
Minimum similarity threshold for cell embedding. [default: 0.0; 0.0<=x<=1.0] |
|
Minimum similarity threshold for spatial domain embedding. [default: 0.6; 0.0<=x<=1.0] |
|
How niche similarity is used: soft_priority ranks passing neighbors first and fills remaining slots; hard_niche_filter reproduces the historical rule by assigning zero marker-score weight below the niche threshold. [default: soft_priority] |
|
Skip expression fraction filtering |
|
Number of spatial neighbors to find on each adjacent slice for 3D data [default: 200; 10<=x<=2000] |
|
Adjacent sections on each side (default 2). Set 0 to disable cross-section homogeneous matching while retaining XYZ distances. Automatically 0 for a single spatial3D volume. Does not disable an explicit section-aware embedding graph. [default: 2; 0<=x<=100] |
|
How cross-section candidates are chosen: by ordinal input order (legacy) or by a measured physical z-distance window. [default: ordinal] |
|
Maximum absolute physical z distance for physical-window section selection. Required when cross_slice_selection_mode=physical_window. [x>=0.0] |
|
Physical units per registered z-coordinate unit. For example, use 4 for the E11.5 z_correction coordinates to express the window in micrometres. [default: 1.0; x>=0.0] |
|
Strategy for computing marker scores across slices in spatial3D datasets. ‘global_pool’: Select the top K most similar neighbors globally across all slices combined. ‘per_slice_pool’: Select a fixed number of neighbors (K) from each slice independently, then compute a single weighted average score from all selected neighbors. ‘hierarchical_pool’: Compute an independent marker score for each slice using its top K neighbors, then take the average of these per-slice scores. [default: hierarchical_pool] |
|
Only find neighbors within high quality cells (requires High_quality column in obs) [default: no-high-quality-filter] |
|
Use GPU rather than CPU for spatial LDSC [default: use-gpu] |
|
Optional fast scratch directory. Concurrent spatial-LDSC processes stage and reuse one content-addressed, read-only marker cache per directory/node. If it does not fit, gsMap streams directly from project storage. |
|
Cells per marker-score batch; 0 selects automatically [default: 0; 0<=x<=1000] |
|
Threads used to materialize distinct rank rows for each cache window [default: 120; 1<=x<=128] |
|
Marker-score compute workers [default: 4; 1<=x<=16] |
|
Marker-score and rank write workers [default: 2; 1<=x<=50] |
|
Maximum pending marker-score batches per compute worker [default: 1; 1<=x<=10] |
|
Writer-input queue capacity [default: 20; 10<=x<=500] |
|
Number of visible GPUs for spatial LDSC on this node. Cells are split between GPUs; each GPU processes all traits. Requires –use-gpu. [default: 1; x>=1] |
|
Share each LD-score chunk across GWAS traits. Required for multiple GPUs. [default: ldsc-share-ld] |
|
Regression backend: auto uses fused moments for two baseline annotations plus intercept, otherwise JAX. jax disables this fast path. [default: auto] |
|
Traits per regression group in shared-LD mode; all requested traits are processed, regardless of this group size. [default: 4; 1<=x<=16] |
|
Reader/preparation workers. Shared-LD mode uses at most four readers for NumPy/memmap markers and one for shared file handles; non-shared mode uses this for sparse-transform or marker-preparation workers. [default: 10; x>=1] |
|
Concurrent GWAS file preparation in shared-LD mode (bounded prefetch). Use fewer workers to reduce temporary memory; at most 16 files are in flight. [default: 16; 1<=x<=16] |
|
Requested CPU compute threads for the automatic moment backend, capped by available cores and thread limits; regression workers in non-shared mode. Does not select the number of GPUs. [default: 10; x>=1] |
|
Spots per spatial-LDSC compute chunk. Omit to select automatically for the execution device; an explicit value overrides both CPU and GPU defaults. [default: (auto: CPU=400, GPU=100); x>=1] |
|
Name of the trait for GWAS analysis |
|
Path to GWAS summary statistics file |
|
Path to sumstats config file |
|
Directory containing the weights files (w_ld) |
|
List of additional baseline h5ad paths |
|
Maximum chi-square value |
|
0-based range [start, end) of cell indices to process |
|
Filter processing to a specific sample |
|
Number of jackknife blocks [default: 200; x>=2] |
|
Path to the SNP-gene weight matrix (H5AD format) |
|
Path to a pre-computed SNP × Cell LD score h5ad file (obs=SNPs, var=cells). When provided, skips on-the-fly LD score computation from the SNP-gene weight matrix. additional_baseline_h5ad_path_list must also be provided to supply all baseline annotations. |
|
Path to marker score feather file |
|
Path to marker score h5ad file |
|
Format of marker scores |
|
List of annotations in adata.obs to use |
|
Automatically export a SpatialVista H5AD for spatial3D reports; ignored for spatial2D and scRNA [default: export-spatialvista] |
|
Optional deterministic sampling limit for the SpatialVista H5AD; default exports all result spots, independently of HTML sampling [x>=1] |
|
Number of spots to downsample for PCC calculation if n_spots > this value [default: 20000; 1000<=x<=100000] |
|
Maximum representative spots used to calculate and display each report UMAP. Valid precomputed UMAP coordinates are sampled to the same limit. [default: 50000; 1000<=x<=500000] |
|
Maximum representative spots rendered in the browser’s 3D view. Larger datasets use deterministic annotation-aware sampling. [default: 200000; 1000<=x<=2000000] |
|
Maximum representative spots per sample in the browser’s 2D view. Larger samples use deterministic annotation-aware sampling. [default: 300000; 10000<=x<=500000] |
|
Number of top correlated genes per trait for expression/GSS diagnostic plots and Manhattan highlights [default: 10; 1<=x<=500] |
|
Plot origin for spatial plots (‘upper’ or ‘lower’). ‘upper’ will flip the y-axis (standard for images). [default: upper] |
|
Step to start execution from (find_latent, latent2gene, spatial_ldsc, cauchy, report) [default: find_latent] |
|
Step to stop execution at (inclusive) |
|
Show this message and exit. |
gsmap find-latent¶
Find latent representations of each spot using Graph Neural Networks.
This step:
Loads spatial transcriptomics data
Builds neighborhood graphs
Learns latent representations using GNN
Saves the model and embeddings
Option |
Description |
|---|---|
|
Path to the working directory [required] |
|
Name of the project [required] |
|
spatial2D (XY) or spatial3D (XYZ sections or a thick-tissue volume) [default: spatial2D] |
|
Space-separated list of h5ad file paths. Sample names are derived from file names without suffix. |
|
YAML file with sample names and h5ad paths |
|
Each row is a h5ad file path, sample name is the file name without suffix |
|
Gene expression raw counts data layer in h5ad layers, e.g., ‘count’, ‘counts’. Other wise use ‘X’ for adata.X [default: X] |
|
Minimum positive-expression genes before HVG, training, graph and inference [default: 20; x>=0] |
|
Optional minimum total raw counts for front-end cell QC [x>=0] |
|
Rows per bounded expression QC/read block [default: 8192; x>=1] |
|
Spatial key in adata.obsm storing spatial coordinates [default: spatial] |
|
Annotation of cell type in adata.obs to use |
|
Path to homologous gene conversion file |
|
Species-symbol column in the homolog file (for example MOUSE_GENE_SYM) |
|
Key for spatial niche embedding in obsm [default: emb_niche] |
|
Key for cell identity embedding in obsm [default: emb_cell] |
|
Opt in to annotation module-score QC (not sequencing-quality QC). Computes DEGs and module scores; disabled by default. [default: no-high-quality-cell-qc] |
|
Number of top variable features to retain [default: 2000; 100<=x<=10000] |
|
Number of external neighbors for corrected LGCN graphs [default: 10; 1<=x<=50] |
|
Spatial graph mode: symmetric_knn (default), radius, weighted_radius, sectionwise_2d, section_aware_3d, no_graph, or revision-only legacy_bug/legacy_symmetric [default: symmetric_knn] |
|
Physical radius for radius graph modes [x>=0.0] |
|
Gaussian sigma for weighted-radius edges [x>=0.0] |
|
Multiplier converting the stored z coordinate to the physical XY units for section_aware_3d graphs [default: 1.0; x>=0.0] |
|
Graph convolution depth for LGCN [default: 3; 1<=x<=10] |
|
Target number of focal spots per section-aligned inference chunk. Physical sections remain intact, all spots are retained, and section-aware chunks include graph halos. [default: 250000; x>=1] |
|
Units in the first hidden layer [default: 128; 32<=x<=512] |
|
Size of the latent embedding layer [default: 32; 8<=x<=128] |
|
Enable transformer module |
|
Dimensionality of transformer modules [default: 30; 10<=x<=100] |
|
Hidden units for global mean feature extractor [default: 128; 32<=x<=512] |
|
Number of transformer modules [default: 16; 4<=x<=64] |
|
Number of attention heads in transformer [default: 4; 1<=x<=16] |
|
Number of transformer encoder layers [default: 2; 1<=x<=8] |
|
Distribution type for loss calculation [default: nb] |
|
Batch size for training [default: 1024; 32<=x<=4096] |
|
Maximum number of training iterations [default: 100; 10<=x<=1000] |
|
Early stopping patience [default: 10; 1<=x<=50] |
|
Random seed for training and sampling [default: 2024; x>=0] |
|
Tune the cell embeddings based on the provided annotation [default: single-stage] |
|
Down-sample cells used by the training loss; spatial features are still propagated on each complete section graph [default: do-sampling] |
|
Number of cells used for training [default: 100000; 1000<=x<=1000000] |
|
Show this message and exit. |
gsmap latent-to-gene¶
Estimate gene marker scores for each spot using latent representations.
This step:
Loads latent representations
Estimates gene marker scores
Performs spatial smoothing
Saves marker scores for LDSC
Option |
Description |
|---|---|
|
Path to the working directory [required] |
|
Name of the project [required] |
|
Type of dataset: scRNA, spatial2D (XY), or spatial3D (XYZ sections or a single thick-tissue volume) [default: spatial2D] |
|
Space-separated list of h5ad file paths. Sample names are derived from file names without suffix. |
|
YAML file with sample names and h5ad paths |
|
Each row is a h5ad file path, sample name is the file name without suffix |
|
Cell type annotation in adata.obs to use. This would constrain finding homogeneous spots within each cell type |
|
Expression data layer in h5ad layers, e.g., ‘count’, ‘counts’; use ‘X’ for adata.X [default: X] |
|
Expression QC contract: counts requires finite nonnegative values; noncounts permits finite signed values with external embeddings, counts distinct nonzero features for min_genes, and requires –no-expression-fraction. [default: counts] |
|
Key for spatial niche embedding in obsm |
|
Key for cell identity embedding in obsm [default: emb_cell] |
|
Spatial key in adata.obsm [default: spatial] |
|
k1: Number of spatial neighbors in it’s own slice for spatial dataset [default: 301; 10<=x<=5000] |
|
k3: Number of homogeneous neighbors per cell (for spatial) or KNN neighbors (for scRNA-seq) [default: 21; 1<=x<=200] |
|
Minimum similarity threshold for cell embedding. [default: 0.0; 0.0<=x<=1.0] |
|
Minimum similarity threshold for spatial domain embedding. [default: 0.6; 0.0<=x<=1.0] |
|
How niche similarity is used: soft_priority ranks passing neighbors first and fills remaining slots; hard_niche_filter reproduces the historical rule by assigning zero marker-score weight below the niche threshold. [default: soft_priority] |
|
Skip expression fraction filtering |
|
Number of spatial neighbors to find on each adjacent slice for 3D data [default: 200; 10<=x<=2000] |
|
Adjacent sections on each side (default 2). Set 0 to disable cross-section homogeneous matching while retaining XYZ distances. Automatically 0 for a single spatial3D volume. Does not disable an explicit section-aware embedding graph. [default: 2; 0<=x<=100] |
|
How cross-section candidates are chosen: by ordinal input order (legacy) or by a measured physical z-distance window. [default: ordinal] |
|
Maximum absolute physical z distance for physical-window section selection. Required when cross_slice_selection_mode=physical_window. [x>=0.0] |
|
Physical units per registered z-coordinate unit. For example, use 4 for the E11.5 z_correction coordinates to express the window in micrometres. [default: 1.0; x>=0.0] |
|
Strategy for computing marker scores across slices in spatial3D datasets. ‘global_pool’: Select the top K most similar neighbors globally across all slices combined. ‘per_slice_pool’: Select a fixed number of neighbors (K) from each slice independently, then compute a single weighted average score from all selected neighbors. ‘hierarchical_pool’: Compute an independent marker score for each slice using its top K neighbors, then take the average of these per-slice scores. [default: hierarchical_pool] |
|
Only find neighbors within high quality cells (requires High_quality column in obs) [default: no-high-quality-filter] |
|
Use GPU for JAX computations (requires sufficient GPU memory) [default: use-gpu] |
|
Optional fast scratch directory for memory-mapped files. A file is staged only when the full logical memmap plus safety headroom fits; otherwise gsMap uses the project storage directly. |
|
Cells per marker-score batch; 0 selects automatically [default: 0; 0<=x<=1000] |
|
Threads used to materialize distinct rank rows for each cache window [default: 120; 1<=x<=128] |
|
Marker-score compute workers [default: 4; 1<=x<=16] |
|
Marker-score and rank write workers [default: 2; 1<=x<=50] |
|
Maximum pending marker-score batches per compute worker [default: 1; 1<=x<=10] |
|
Writer-input queue capacity [default: 20; 10<=x<=500] |
|
Show this message and exit. |
gsmap spatial-ldsc¶
Run spatial LDSC analysis for genetic association.
This step:
Loads LD scores and GWAS summary statistics
Performs spatial LDSC regression
Computes enrichment statistics
Saves results for downstream analysis
Option |
Description |
|---|---|
|
Path to the working directory [required] |
|
Name of the project [required] |
|
Use GPU rather than CPU for spatial LDSC [default: use-gpu] |
|
Number of visible GPUs for spatial LDSC on this node. Cells are split between GPUs; each GPU processes all traits. Requires –use-gpu. [default: 1; x>=1] |
|
Share each LD-score chunk across GWAS traits. Required for multiple GPUs. [default: ldsc-share-ld] |
|
Regression backend: auto uses fused moments for two baseline annotations plus intercept, otherwise JAX. jax disables this fast path. [default: auto] |
|
Traits per regression group in shared-LD mode; all requested traits are processed, regardless of this group size. [default: 4; 1<=x<=16] |
|
Optional fast scratch directory. Concurrent spatial-LDSC processes stage and reuse one content-addressed, read-only marker cache per directory/node. If it does not fit, gsMap streams directly from project storage. |
|
Reader/preparation workers. Shared-LD mode uses at most four readers for NumPy/memmap markers and one for shared file handles; non-shared mode uses this for sparse-transform or marker-preparation workers. [default: 10; x>=1] |
|
Concurrent GWAS file preparation in shared-LD mode (bounded prefetch). Use fewer workers to reduce temporary memory; at most 16 files are in flight. [default: 16; 1<=x<=16] |
|
Requested CPU compute threads for the automatic moment backend, capped by available cores and thread limits; regression workers in non-shared mode. Does not select the number of GPUs. [default: 10; x>=1] |
|
Spots per spatial-LDSC compute chunk. Omit to select automatically for the execution device; an explicit value overrides both CPU and GPU defaults. [default: (auto: CPU=400, GPU=100); x>=1] |
|
Name of the trait for GWAS analysis |
|
Path to GWAS summary statistics file |
|
Path to sumstats config file |
|
Directory containing the weights files (w_ld) |
|
List of additional baseline h5ad paths |
|
Maximum chi-square value |
|
0-based range [start, end) of cell indices to process |
|
Filter processing to a specific sample |
|
Number of jackknife blocks [default: 200; x>=2] |
|
Path to the SNP-gene weight matrix (H5AD format) |
|
Path to a pre-computed SNP × Cell LD score h5ad file (obs=SNPs, var=cells). When provided, skips on-the-fly LD score computation from the SNP-gene weight matrix. additional_baseline_h5ad_path_list must also be provided to supply all baseline annotations. |
|
Path to marker score feather file |
|
Path to marker score h5ad file |
|
Format of marker scores |
|
Show this message and exit. |
gsmap cauchy-combination¶
Run Cauchy combination test to combine spatial LDSC results across spots.
This step:
Loads spatial LDSC results for a trait
Removes outliers
Performs Cauchy combination test for each annotation
Computes Fisher’s exact test for enrichment
Option |
Description |
|---|---|
|
Path to the working directory [required] |
|
Name of the project [required] |
|
Name of the trait for GWAS analysis |
|
Path to GWAS summary statistics file |
|
Path to sumstats config file |
|
Name of the annotation in adata.obs to use |
|
List of annotations in adata.obs to use |
|
Show this message and exit. |
gsmap ldscore-weight-matrix¶
Compute LD score weight matrices for features.
This command runs the LDScorePipeline to:
Load genotypes (PLINK)
Load feature mappings (BED/Dict) or Annotations
Compute LD-based weights between SNPs and Features
Save results as AnnData (.h5ad)
Option |
Description |
|---|---|
|
Reference panel prefix template (e.g., ‘data/1000G.{chr}’) [required] |
|
Directory containing per-chromosome HM3 SNP lists (e.g., hm.{chr}.snp). Typically set to ‘<ldscore_data_dir>/hapmap3_snps’. [required] |
|
Output directory. If None, uses {workdir}/{project_name}/generate_ldscore |
|
Prefix for output files [default: ld_score_weights] |
|
Path to omics H5AD file |
|
Mapping type: ‘bed’ or ‘dict’ [default: bed] |
|
Path to mapping file |
|
Template for annotation files (e.g., ‘baseline.{chr}.annot.gz’) |
|
bp window for mapping (e.g. TSS window) [default: 0] |
|
Strategy: ‘score’, ‘tss’, ‘center’, ‘allow_repeat’ [default: score] |
|
LD window size [default: 1.0] |
|
LD unit: ‘SNP’, ‘KB’, ‘CM’ [default: CM] |
|
Restrict the broad reference set to biallelic single-nucleotide A/C/G/T variants before decoding the BED payload. [default: snps-only] |
|
Minimum minor-allele count for the broad reference SNP set. Variants are retained when MAC is strictly greater than this value; the default therefore implements MAC > 5. [default: 5; x>=0] |
|
Optional minimum MAF filter for the broad reference SNP set. Disabled by default because MAC > 5 is the default QC rule. [0.0<=x<=0.5] |
|
Exclude extended-MHC SNPs from HM3 regression targets and the HM3-only weight-LD universe. MHC variants remain in the broad reference SNP set used in annotation LD-score sums. [default: exclude-mhc-from-regression] |
|
GRCh38 extended-MHC start coordinate (inclusive) [default: 28510120] |
|
GRCh38 extended-MHC end coordinate (inclusive) [default: 33480577] |
|
Chromosomes to process. ‘all’ uses 1-22 autosomes, or provide a comma-separated list of chromosomes (e.g., ‘1,2,3’) [default: all] |
|
Batch size for HM3 SNPs [default: 50] |
|
Whether to calculate w_ld [default: no-calculate-w-ld] |
|
Directory for w_ld outputs |
|
Show this message and exit. |
gsmap format-sumstats¶
Format GWAS summary statistics for gsMap or COJO.
This command:
Filters SNPs based on INFO, MAF, and P-value
Converts SNP positions to RSID (if dbsnp is provided)
Saves formatted summary statistics
Option |
Description |
|---|---|
|
Path to gwas summary data [required] |
|
Path to save the formatted gwas data [required] |
|
Name of snp column |
|
Name of effect allele column |
|
Name of none-effect allele column |
|
Name of info column |
|
Name of gwas beta column. |
|
Name of gwas standar error of beta column |
|
Name of p-value column |
|
Name of A1 ferquency column |
|
Name of sample size column |
|
Name of gwas Z-statistics column |
|
Name of gwas OR column |
|
Name of standar error of OR column |
|
Name of SNP chromosome column [default: Chr] |
|
Name of SNP positions column [default: Pos] |
|
Path to reference dnsnp file |
|
Chunk size for loading dbsnp file [default: 1000000] |
|
Format of output data [default: gsMap] |
|
Minimum INFO score. [default: 0.9] |
|
Minimum MAF. [default: 0.01] |
|
Keep SNP chromosome and position columns in the output data [default: no-keep-chr-pos] |
|
Show this message and exit. |
gsmap report-view¶
Launch a local web server to view the gsMap report.
This command starts a simple HTTP server to serve the report files, which is necessary for proper loading of JavaScript modules.
Example: gsmap report-view /path/to/project/gsmap_web_report gsmap report-view /path/to/project/gsmap_web_report –port 9000
Option |
Description |
|---|---|
|
Path to gsmap_web_report directory containing index.html [required] |
|
Port to serve the report on [default: 8080] |
|
Don’t automatically open browser |
|
Show this message and exit. |