FlashS
Spatially variable gene detection via frequency-domain kernel testing.
FlashS detects spatially variable genes (SVGs) in spatial transcriptomics data. It reformulates multi-scale Gaussian kernel testing in the frequency domain, where expression sparsity accelerates computation rather than complicating it.
Why FlashS
SVG detection methods face a fundamental trade-off: expressive kernels (Gaussian, Matérn) can detect arbitrary spatial patterns — gradients, hotspots, domain boundaries — but require O(n²) distance or covariance matrices. Scalable alternatives gain speed by restricting what they can find: low-rank periodic projections, fixed polynomial bases, or nearest-neighbor approximations.
FlashS resolves this by moving the test into the frequency domain. By Bochner's theorem, Gaussian kernel evaluations decompose into inner products over Random Fourier Features, eliminating the need for any n × n matrix. Three consequences follow directly:
- Expression sparsity helps rather than hurts. Projections touch only non-zero entries. The 80–95% zeros typical of spatial transcriptomics make computation faster, not slower.
- Multiple spatial scales are captured in one pass. Tissue-wide gradients and cell-neighborhood patterns correspond to different frequency bands, all evaluated simultaneously without separate model fits.
- The Gaussian kernel becomes practical at any scale. Its universal approximation capacity — the ability to detect any spatially structured pattern — is no longer gated by quadratic cost.
A three-part test (binary presence, rank intensity, raw count) handles zero-inflation by decomposing spatial signal into complementary channels, and a kurtosis-corrected null distribution provides calibrated p-values without permutation.
Installation
pip install flashs
With AnnData support:
pip install "flashs[io]"
Quick start
# Scanpy-style: results stored in adata.var
import flashs
flashs.tl.svg(adata)
sig = adata.var.query("flashs_qvalue < 0.05")
# Standalone
from flashs import FlashS
result = FlashS().fit_test(coords, expression_matrix)
result.to_dataframe()
See the quickstart notebook for a complete walkthrough.
Benchmark
On the Open Problems SVG benchmark (50 datasets across 9 spatial transcriptomics platforms), FlashS achieves a mean Kendall τ of 0.935, exceeding the next-best method (SPARK-X, τ = 0.886) by Δτ = 0.049.
On the Allen Brain MERFISH atlas (3.94 million cells, 550 genes), FlashS completes in 12.6 minutes using 21.5 GB memory while maintaining near-nominal false-positive rates under permutation.
The benchmark snapshot and method implementations are available in the Open Problems SVG fork at tag flashs-benchmark-v1.
API
flashs.tl.svg(adata) — Scanpy-style entry point. Stores p-values, q-values, effect sizes, and per-channel statistics in adata.var.
FlashS().fit_test(coords, X) — Standalone interface returning a FlashSResult with .significant_genes(), .to_dataframe(), and .get_spatial_embedding().
Method
FlashS approximates multi-scale Gaussian kernels via Random Fourier Features, projects each gene's expression onto the spectral space through sparse sketching, and combines evidence across scales and test channels via the Cauchy combination rule. Analytic p-values are computed from a kurtosis-corrected scaled chi-squared null without permutation.
See docs/methods.md for the full mathematical formulation.
Citation
@article{yang2026flashs,
title = {Frequency-domain kernels enable atlas-scale detection of
spatially variable genes},
author = {Yang, Chen and Zhang, Xianyang and Chen, Jun},
year = {2026},
journal = {bioRxiv},
url = {https://github.com/cafferychen777/FlashS}
}
License
MIT
Metadata
Release files for flashs 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flashs-0.2.1.tar.gz | 31.4 kB | Without provenance | Details for flashs-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flashs-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for flashs-0.2.1-py3-none-any.whl |
Total release size: 63.7 kB
Release files / flashs-0.2.1.tar.gz
| Download URL | flashs-0.2.1.tar.gz |
|---|---|
| Size | 31.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5a74795ab39d755e618493629bd110719a5e2a1c7bcfda54904c3c3a2810b4fa
|
|
BLAKE2b-256 checksum How to use checksums |
c72d273b1214718773e2d2c9dee4a891254f655158819bf25c24cf068c351286
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / flashs-0.2.1-py3-none-any.whl
| Download URL | flashs-0.2.1-py3-none-any.whl |
|---|---|
| Size | 32.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
825969cfbff10daa3c710dd29df27be3f4f16f6b78bc49591f90a307b2a66007
|
|
BLAKE2b-256 checksum How to use checksums |
4f383ab8260cb80d89c5f540e8f067c3ff8456d8cf2160768389f04d25acad81
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Security for flashs 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.