Flash-S: Frequency-domain Linearized Adaptive Spatial Hypothesis testing via Sketching
Project description
FlashS
Frequency-domain Linearized Adaptive Spatial Hypothesis testing via Sketching
Frequency-domain kernel testing for spatially variable gene (SVG) detection in sparse spatial transcriptomics.
Highlights
- Sparse-aware computation:
O(nnz · D)per gene withO(D)per-gene memory; no densen × nkernel matrix - Robust evidence aggregation: Binary, rank, and direct tests combined across adaptive kernel scales
- Atlas-scale practicality: Benchmarked on 3.94M cells in 12.6 min using 21.5 GB RAM
- AnnData-native workflow: Scanpy-style
tlAPI plus a standalone model interface
Installation
pip install flashs
Optional extras:
pip install "flashs[io]" # AnnData support
pip install "flashs[dev]" # Testing
Quick Start
Scanpy-style API (recommended)
import flashs
# adata: AnnData with spatial coordinates in adata.obsm["spatial"]
flashs.tl.svg(adata)
# Results stored in adata.var and adata.uns
sig = adata.var.query("flashs_qvalue < 0.05")
Standalone API
import numpy as np
from scipy import sparse
from flashs import FlashS
coords = np.random.randn(50000, 2)
X = sparse.random(50000, 1000, density=0.03, format="csc")
result = FlashS().fit_test(coords, X)
print(result.significant_genes())
print(result.to_dataframe().head())
Core API
AnnData workflow
flashs.tl.svg(adata, spatial_key="spatial", layer=None, genes=None, n_features=500, n_scales=7, min_expressed=5, key_added="flashs", copy=False, random_state=0)
This is the recommended entry point for Scanpy and scverse users. It stores per-gene results in adata.var and run metadata in adata.uns[key_added].
Key outputs in adata.var:
{key}_pvalue{key}_qvalue{key}_statistic{key}_effect_size{key}_pvalue_binary{key}_pvalue_rank{key}_n_expressed
Standalone workflow
FlashS(...).fit_test(coords, X, gene_names=None, return_projections=False) -> FlashSResult
Use the standalone interface when you work outside AnnData. The returned FlashSResult provides:
significant_genes(...)to extract discoveriesto_dataframe()to inspect ranked resultsget_spatial_embedding(...)to access projection-based embeddings whenreturn_projections=True
Method
FlashS approximates multi-scale spatial kernels with Random Fourier Features, computes sparse sketches from non-zero entries only, and evaluates binary, rank, and direct expression patterns across scales. Analytic p-value approximations and Cauchy combination avoid dense kernel operations while keeping inference tractable on large sparse datasets.
See docs/methods.md for full mathematical details.
Benchmarks
In our evaluation on the Open Problems SVG benchmark, FlashS achieved a mean Kendall tau of 0.935 across 50 datasets.
FlashS is intended for settings where informative gene ranking, calibrated inference, and sparse-data scalability all matter.
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={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.2.0.tar.gz.
File metadata
- Download URL: flashs-0.2.0.tar.gz
- Upload date:
- Size: 30.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9719ed301543c3732bda53a78783d8e628bbc401d9e9d90c48b3866de2ea0222
|
|
| MD5 |
e9801f3d3d27387e03fb1939beaa86bc
|
|
| BLAKE2b-256 |
85681822e47477f7f332ac2ff1c41c9d0763a0dbe48487f1d7eb9cf7649c5525
|
File details
Details for the file flashs-0.2.0-py3-none-any.whl.
File metadata
- Download URL: flashs-0.2.0-py3-none-any.whl
- Upload date:
- Size: 32.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3faf68ead7d3879d9e23be8d5042bf3d6a50f767644da020058e6d9304e1cbed
|
|
| MD5 |
9883dec32b4d8b16c09f14dc4223ed04
|
|
| BLAKE2b-256 |
283eedea05d443abc9eb99eee462c40ec302ef9307a5d4175c7e305b8fed7439
|