Skip to main content

Flash-S: Frequency-domain Linearized Adaptive Spatial Hypothesis testing via Sketching

Project description

FlashS

Tests PyPI License: MIT Python

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flashs-0.2.1.tar.gz (31.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flashs-0.2.1-py3-none-any.whl (32.4 kB view details)

Uploaded Python 3

File details

Details for the file flashs-0.2.1.tar.gz.

File metadata

  • Download URL: flashs-0.2.1.tar.gz
  • Upload date:
  • Size: 31.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for flashs-0.2.1.tar.gz
Algorithm Hash digest
SHA256 5a74795ab39d755e618493629bd110719a5e2a1c7bcfda54904c3c3a2810b4fa
MD5 7a268cb94e7b8b76447c7b421ddeb19c
BLAKE2b-256 c72d273b1214718773e2d2c9dee4a891254f655158819bf25c24cf068c351286

See more details on using hashes here.

File details

Details for the file flashs-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: flashs-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 32.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for flashs-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 825969cfbff10daa3c710dd29df27be3f4f16f6b78bc49591f90a307b2a66007
MD5 b5a3cb2e690a284c4534c1ba93234461
BLAKE2b-256 4f383ab8260cb80d89c5f540e8f067c3ff8456d8cf2160768389f04d25acad81

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page