Package for the analysis of unassigned RNA during segmentation in image-based spatial transcriptomics, in python.
Please refer to the documentation, in particular, the API documentation.
You need to have Python 3.10 or newer installed on your system. If you don't have Python installed, we recommend installing Miniforge.
There are several alternative options to install troutpy:
- Install the latest release of
troutpyfrom PyPI:
pip install troutpy- Install the latest development version:
pip install git+https://github.com/theislab/troutpy.git@mainSome functionality (spatial statistics, segmentation-free clustering, chord-diagram
plots, morphological metrics, factor analysis, vendor-format readers) requires
optional extras. Install everything with pip install "troutpy[all]", or pick
individual extras (spatial-stats, segmentation-free, chord, morphology,
factor-analysis, io, viz) as needed.
troutpy follows the scverse API conventions: preprocessing in tp.pp, analysis tools in
tp.tl and plotting in tp.pl, all operating on a SpatialData object.
import spatialdata as sd
import troutpy as tp
sdata = sd.read_zarr("data.zarr")
# classify unassigned transcripts into cell-like RNA and uRNA
tp.pp.segmentation_free_sainsc(sdata, binsize=5, celltype_key="leiden")
tp.pp.define_urna(sdata, method="sainsc")
# characterize uRNA per gene and infer its source cells
tp.tl.quantify_overexpression(sdata, codeword_key="control_probe")
tp.tl.extracellular_enrichment(sdata)
tp.tl.density_similarity(sdata)
tp.tl.urna_source_score(sdata, cell_type_col="leiden")See the basic tutorial for a complete, step-by-step walkthrough on a public Xenium mouse brain dataset.
Code, notebooks, and instructions to reproduce the results from the paper are available at the reproducibility repository. This repository also includes diverse tutorials and complementary functions that are not core to Troutpy, but are required to reproduce the figures from Marco Salas et al. 2025.
See the changelog.
For questions and help requests, you can reach out in the scverse discourse. If you found a bug, please use the issue tracker.
t.b.a
