init repo + ReadMe
Browse files
README.md
CHANGED
|
@@ -1,3 +1,103 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
tags:
|
| 6 |
+
- spatial-transcriptomics
|
| 7 |
+
- cell-cell-communication
|
| 8 |
---
|
| 9 |
+
|
| 10 |
+
# InterScale
|
| 11 |
+
|
| 12 |
+
This repository contains the Python package to load and use pretrained InterScale models for spatial transcriptomics data. InterScale is a graph-transformer framework that jointly models local (cell-neighborhood) and global (tissue-level) cellular interactions from spatial omics data.
|
| 13 |
+
|
| 14 |
+
## Installation
|
| 15 |
+
|
| 16 |
+
You need Python 3.10 or newer installed on your system.
|
| 17 |
+
If you don't have Python installed, we recommend installing [uv][].
|
| 18 |
+
|
| 19 |
+
### Default installation
|
| 20 |
+
|
| 21 |
+
Install the latest release of `interscale` from [PyPI][]:
|
| 22 |
+
|
| 23 |
+
```bash
|
| 24 |
+
pip install interscale
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
### Latest development version
|
| 28 |
+
|
| 29 |
+
To install the latest development version directly from GitHub:
|
| 30 |
+
|
| 31 |
+
```bash
|
| 32 |
+
pip install git+https://github.com/theislab/interscale.git@main
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
InterScale builds graphs from spatial coordinates using [Squidpy][] and loads them as PyTorch Geometric objects using [Geome][].
|
| 36 |
+
|
| 37 |
+
## How to use
|
| 38 |
+
|
| 39 |
+
InterScale combines a Graph Convolutional Network (local component) with a Transformer encoder (global component, masked to attend only within each cell's local neighborhood) to produce a **local embedding** (short-range, cell-neighborhood signal) and a **global embedding** (tissue-level, long-range signal) for every cell.
|
| 40 |
+
|
| 41 |
+
### Pre-trained models
|
| 42 |
+
|
| 43 |
+
The following models are available from the InterScale Hugging Face repository. Use the value in the `model_name` column with `interscale.load_config_and_model(model_name=...)`. <!-- CONFIRM: actual loading API -->
|
| 44 |
+
|
| 45 |
+
| `model_name` | Training corpus | Platform | Architecture | Notes |
|
| 46 |
+
| --- | --- | --- | ---: | --- |
|
| 47 |
+
| `xenium_5k_human_ovarian_adenocarcinoma` | Fresh-frozen human ovarian adenocarcinoma, ~1.16M cells, Xenium Prime 5K Human Pan Tissue and Pathways Panel ([10x Genomics, 2024](https://www.10xgenomics.com/datasets/xenium-prime-fresh-frozen-human-ovary), CC BY 4.0) | [config]() | Radius-based spatial graph (image-based data); trained via masked-node self-supervised learning |
|
| 48 |
+
|
| 49 |
+
Here's a basic example: <!-- CONFIRM: function/argument names below follow scConcept's API as a template — adjust to InterScale's actual package interface. -->
|
| 50 |
+
|
| 51 |
+
```python
|
| 52 |
+
from interscale import InterScale
|
| 53 |
+
import scanpy as sc
|
| 54 |
+
import squidpy as sq
|
| 55 |
+
|
| 56 |
+
# Load your spatial transcriptomics data
|
| 57 |
+
adata = sc.read_h5ad("your_data.h5ad")
|
| 58 |
+
|
| 59 |
+
# Normalize and log-transform (InterScale performs best with max normalized values of 4)
|
| 60 |
+
sc.pp.normalize_total(adata)
|
| 61 |
+
sc.pp.log1p(adata)
|
| 62 |
+
|
| 63 |
+
# Build the spatial neighborhood graph
|
| 64 |
+
# Use a radius-based graph for image-based data (e.g. Xenium, MERFISH, IMC),
|
| 65 |
+
# or a hexagonal grid-based graph for sequencing-based data (e.g. Visium)
|
| 66 |
+
sq.gr.spatial_neighbors(adata, coord_type="generic", radius=<INSERT RADIUS>)
|
| 67 |
+
|
| 68 |
+
# Initialize InterScale and load a pretrained model
|
| 69 |
+
model = InterScale(cache_dir="./cache/")
|
| 70 |
+
model.load_config_and_model(model_name="<INSERT MODEL NAME>")
|
| 71 |
+
|
| 72 |
+
# Extract local and global embeddings
|
| 73 |
+
result = model.extract_embeddings(adata=adata)
|
| 74 |
+
adata.obsm["X_interscale_local"] = result["local_emb"]
|
| 75 |
+
adata.obsm["X_interscale_global"] = result["global_emb"]
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
### Multi-scale downstream analysis
|
| 79 |
+
|
| 80 |
+
InterScale provides functions for analysis at three scales, using the attention matrix and the learned embeddings:
|
| 81 |
+
|
| 82 |
+
- **Tissue / graph level** — CLS-token attention, for condition or graph-label prediction
|
| 83 |
+
- **Cell level** — normalized attention scores between sender and receiver cells, for interaction strength
|
| 84 |
+
- **Gene level** — ranking of gene contributions from local and global embedding loadings, for scale-specific driver genes
|
| 85 |
+
|
| 86 |
+
## Troubleshooting
|
| 87 |
+
|
| 88 |
+
If you encounter an error when loading a pre-trained model, try the following:
|
| 89 |
+
|
| 90 |
+
1. Remove the repository and clone the most recent version
|
| 91 |
+
2. Remove the cache directory (`cache/` by default)
|
| 92 |
+
3. Run again
|
| 93 |
+
|
| 94 |
+
This will force a fresh download of the pre-trained model and should resolve most loading issues.
|
| 95 |
+
|
| 96 |
+
## Citation
|
| 97 |
+
|
| 98 |
+
> Drummer, F., Jiménez, S., Di Marco, F., Schaar, A.C., Pentimalli, T.M., Beckman, J.L., Rajewsky, N. and Theis, F.J., 2026. InterScale reveals multi-scale cellular interaction programs in spatial transcriptomics. bioRxiv. doi: https://doi.org/10.64898/2026.05.07.723456
|
| 99 |
+
|
| 100 |
+
[uv]: https://github.com/astral-sh/uv
|
| 101 |
+
[Squidpy]: https://github.com/scverse/squidpy
|
| 102 |
+
[Geome]: https://github.com/theislab/geome
|
| 103 |
+
[pypi]: https://pypi.org/project/interscale
|