Skip to content

Soldatov-Lab/gHotspot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ghotspotsc

GPU-accelerated drop-in extension for Hotspot, a tool for identifying informative genes (and gene modules) in single-cell datasets.

ghotspotsc replaces the CPU-intensive steps in Hotspot with batched CuPy sparse-matrix operations, yielding orders-of-magnitude speedups on NVIDIA GPUs while preserving numerical equivalence.

Installation

pip install ghotspotsc[cuda12]

Requirements

  • Python >= 3.9
  • hotspotsc (the original Hotspot package)
  • GPU functions require:
    • NVIDIA GPU with CUDA 12.x
    • cupy-cuda12x
    • cuml (for compute_module_scores and module_pca)

Usage

ghotspotsc is designed to be a drop-in accelerator. Use gHotspot — a subclass of hotspot.Hotspot — to get GPU-accelerated versions of all heavy compute methods:

import ghotspot

# 0. Create knn graph with rapids_singlecell for fast GPU knn
import rapids_singlecell as rsc
rsc.pp.neighbors(adata, n_neighbors=30)
# or use sc.pp.neighbors

# 1. Build the gHotspot object (subclass of hotspot.Hotspot)
ghs = ghotspot.gHotspot(
    adata,
    layer_key="counts",
    model="danb",          # or "bernoulli"
    distances_obsp_key="distances",
    umi_counts_obs_key="total_counts"
)

# if precalculated kNN, n_neighbors be `pp.neighbors` n_neighbors-1
ghs.create_knn_graph(weighted_graph=False, n_neighbors=29)

# 2. GPU-accelerated feature selection
results = ghs.compute_autocorrelations()

# 3. GPU-accelerated pairwise local correlations
sig_genes = results.loc[results.FDR < 0.05].index
local_correlation_z = ghs.compute_local_correlations(sig_genes)

# 4. Module detection (GPU-assisted)
modules = ghs.create_modules()

# 5. Module scores (GPU + cuML PCA)
scores = ghs.calculate_module_scores()

# 6. Cross-dataset projection
projected = ghs.project_module_scores(adata_target)

All returned objects (results, lcz, modules, scores) have the same schema as the original Hotspot CPU functions, so downstream plotting and analysis code requires no changes.

API Overview

Method Overrides Speed-up typical
ghs.compute_autocorrelations() Hotspot.compute_autocorrelations() 10–50×
ghs.compute_local_correlations() Hotspot.compute_local_correlations() 50–200×
ghs.create_modules() Hotspot.create_modules() 2–5× (Z-score extraction)
ghs.calculate_module_scores() Hotspot.calculate_module_scores() 10–30×

Additional instance methods for cross-dataset projection and downstream analysis are also provided (project_module_scores, test_module_activity, module_pca, module_activity_fraction, module_correlation_preservation).

License

MIT — same as the original Hotspot package.

About

GPU-accelerated Hotspot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages