Flash-S: Frequency-domain Linearized Adaptive Spatial Hypothesis testing via Sketching
Project description
FlashS
Frequency-domain Linearized Adaptive Spatial Hypothesis testing via Sketching
Ultra-fast spatially variable gene (SVG) detection for million-scale spatial transcriptomics.
Features
- SVG Detection: Per-gene complexity
O(nnz * D + nnz * log(nnz)); sparse projection isO(nnz * D) - Multi-kernel Cauchy combination: Binary, rank, and direct tests across multiple bandwidth scales
- Scalability: Handles million-scale cells on standard hardware (3.94M cells in 12.6 min, <22 GB RAM)
- Memory Efficient: O(D) per gene, no n x n or n x D matrix construction
Installation
git clone https://github.com/cafferychen777/FlashS.git
cd FlashS
pip install -e .
Optional extras:
# AnnData I/O
pip install -e ".[io]"
# Full stack (AnnData + visualization)
pip install -e ".[full]"
# Development (testing)
pip install -e ".[dev]"
Quick Start
import numpy as np
from scipy import sparse
from flashs import FlashS
# Simulated data
rng = np.random.default_rng(0)
n_cells, n_genes = 2000, 500
coords = rng.normal(size=(n_cells, 2))
X = sparse.random(n_cells, n_genes, density=0.03, random_state=0, format="csc")
# Fit + test
result = FlashS().fit(coords).test(X)
# Results
print(f"P-values shape: {result.pvalues.shape}")
print(f"Significant genes (q < 0.05): {result.significant_genes(q_threshold=0.05)}")
print(f"Effect sizes: {result.effect_size[:5]}")
With AnnData
from flashs.io import run_flashs
# Requires: pip install -e ".[io]"
result = run_flashs(adata, spatial_key="spatial")
# Results are stored in adata.var and adata.uns
See examples/quickstart.ipynb for a complete walkthrough.
Method Overview
- RFF Mapping: Transform coordinates to frequency domain via multi-scale Gaussian kernels
- Sparse Sketching: Compute test statistics using only non-zero entries in a single fused pass
- Three-Part Test: Binary (presence), rank (intensity order), and direct (raw value) spatial tests
- Multi-Kernel Cauchy Combination: Combine per-scale p-values across all test types
- Analytic P-values: Satterthwaite chi-squared approximation under null
See docs/methods.md for full mathematical details.
Benchmark Reproduction
FlashS achieves state-of-the-art accuracy on the Open Problems SVG benchmark (mean Kendall tau = 0.936 across 50 datasets).
See benchmarks/README.md for instructions on reproducing results.
Project Structure
FlashS/
├── flashs/ # Main package
│ ├── core/ # Core algorithms (RFF, sketching, p-values, bandwidth)
│ ├── model/ # SVG model (FlashS, FlashSResult)
│ ├── preprocessing/ # Normalization utilities
│ └── io/ # AnnData integration
├── tests/ # Unit and integration tests
├── examples/ # Quickstart notebook
├── benchmarks/ # Benchmark reproduction scripts
├── open_problems/ # Open Problems benchmark entry
└── docs/ # Methods documentation
Citation
If you use FlashS in your research, please cite:
@article{yang2026flashs,
title={Frequency-domain sparse kernel testing enables scalable
spatially variable gene discovery with controlled inference
at atlas scale},
author={Yang, Chen and Zhang, Xianyang and Chen, Jun},
year={2026},
journal={Manuscript submitted},
url={https://github.com/cafferychen777/FlashS}
}
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flashs-0.1.1.tar.gz.
File metadata
- Download URL: flashs-0.1.1.tar.gz
- Upload date:
- Size: 31.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2bed70a30fc1876b8f9ae8ab898afc3c054fcd3110e7c1f5b2829d3bb019ede4
|
|
| MD5 |
bfed1a6647eb76c9045163a67c6b1d92
|
|
| BLAKE2b-256 |
3345161f82a3dc652550ba66df93ae89770d0f26b4fe7062ba9a4d5848ce5e38
|
File details
Details for the file flashs-0.1.1-py3-none-any.whl.
File metadata
- Download URL: flashs-0.1.1-py3-none-any.whl
- Upload date:
- Size: 33.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22232739745c426c5e4374d559099cc4589ffe0c913128767159d27bfe6ff442
|
|
| MD5 |
09fbbc286163619bb595c01e141871d2
|
|
| BLAKE2b-256 |
eac333805d9cd64df2bb07156db6dbe3cab2da47d7d933c87f0bb436eb20985b
|