Skip to content

Commit d319a74

Browse files
committed
tutorial_docs
1 parent c3f70e2 commit d319a74

21 files changed

Lines changed: 4388 additions & 56 deletions
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# troutpy
2+
3+
[![Tests][badge-tests]][tests]
4+
[![Documentation][badge-docs]][documentation]
5+
6+
[badge-tests]: https://img.shields.io/github/actions/workflow/status/theislab/troutpy/test.yaml?branch=main
7+
[badge-docs]: https://img.shields.io/readthedocs/troutpy
8+
9+
Package for the analysis of transcripts outside segmented cells in python
10+
11+
![alt text](images/logo_fish.png)
12+
13+
## Getting started
14+
15+
Please refer to the [documentation][],
16+
in particular, the [API documentation][].
17+
18+
## Installation
19+
20+
You neeed to have Python 3.10 or newer installed on your system.
21+
If you don't have Python installed, we recommend installing [Mambaforge][].
22+
23+
There are several alternative options to install troutpy:
24+
25+
<!--
26+
1) Install the latest release of `troutpy` from [PyPI][]:
27+
28+
```bash
29+
pip install troutpy
30+
```
31+
-->
32+
33+
1. Install the latest development version:
34+
35+
```bash
36+
pip install git+https://github.com/theislab/troutpy.git@main
37+
```
38+
39+
## Usage
40+
41+
Please have a look at the [Usage documentation](https://troutpy.readthedocs.io/en/latest/) and the [tutorials](https://troutpy.readthedocs.io/en/latest/).
42+
43+
```python
44+
import troutpy as tp
45+
```
46+
47+
## Release notes
48+
49+
See the [changelog][].
50+
51+
## Contact
52+
53+
For questions and help requests, you can reach out in the [scverse discourse][].
54+
If you found a bug, please use the [issue tracker][].
55+
56+
## Citation
57+
58+
> t.b.a
59+
60+
[mambaforge]: https://github.com/conda-forge/miniforge#mambaforge
61+
[scverse discourse]: https://discourse.scverse.org/
62+
[issue tracker]: https://github.com/theislab/troutpy/issues
63+
[tests]: https://github.com/theislab/troutpy/actions/workflows/test.yml
64+
[documentation]: https://troutpy.readthedocs.io
65+
[changelog]: https://troutpy.readthedocs.io/en/latest/changelog.html
66+
[api documentation]: https://troutpy.readthedocs.io/en/latest/api.html
67+
[pypi]: https://pypi.org/project/troutpy
68+
[images/logo_fish.png]: images/logo_fish.png

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[badge-tests]: https://img.shields.io/github/actions/workflow/status/theislab/troutpy/test.yaml?branch=main
77
[badge-docs]: https://img.shields.io/readthedocs/troutpy
88

9-
Package for the analysis of transcripts outside segmented cells in python
9+
Package for the analysis of unassigned RNA during segmentation in image-based spatial transcriptomics, in python.
1010

1111
![alt text](images/logo_fish.png)
1212

@@ -22,13 +22,11 @@ If you don't have Python installed, we recommend installing [Mambaforge][].
2222

2323
There are several alternative options to install troutpy:
2424

25-
<!--
2625
1) Install the latest release of `troutpy` from [PyPI][]:
2726

2827
```bash
2928
pip install troutpy
3029
```
31-
-->
3230

3331
1. Install the latest development version:
3432

@@ -44,6 +42,9 @@ Please have a look at the [Usage documentation](https://troutpy.readthedocs.io/e
4442
import troutpy as tp
4543
```
4644

45+
## Reproducibility
46+
Code, notebooks, and instructions to reproduce the results from the paper are available at the [reproducibility repository](https://github.com/theislab/troutpy_reproducibility). This repository also include diverse tutorials and compementary functions that are not core to Troutpy, but are required to reproduce the figures from Marco Salas et al. 2025.
47+
4748
## Release notes
4849

4950
See the [changelog][].
Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
# Contributing guide
2+
3+
Scanpy provides extensive [developer documentation][scanpy developer guide], most of which applies to this project, too.
4+
This document will not reproduce the entire content from there.
5+
Instead, it aims at summarizing the most important information to get you started on contributing.
6+
7+
We assume that you are already familiar with git and with making pull requests on GitHub.
8+
If not, please refer to the [scanpy developer guide][].
9+
10+
[scanpy developer guide]: https://scanpy.readthedocs.io/en/latest/dev/index.html
11+
12+
## Installing dev dependencies
13+
14+
In addition to the packages needed to _use_ this package,
15+
you need additional python packages to [run tests](#writing-tests) and [build the documentation](#docs-building).
16+
17+
:::::{tabs}
18+
::::{group-tab} Hatch
19+
The easiest way is to get familiar with [hatch environments][], with which these tasks are simply:
20+
21+
```bash
22+
hatch test # defined in the table [tool.hatch.envs.hatch-test] in pyproject.toml
23+
hatch run docs:build # defined in the table [tool.hatch.envs.docs]
24+
```
25+
26+
::::
27+
28+
::::{group-tab} Pip
29+
If you prefer managing environments manually, you can use `pip`:
30+
31+
```bash
32+
cd troutpy
33+
python3 -m venv .venv
34+
source .venv/bin/activate
35+
pip install -e ".[dev,test,doc]"
36+
```
37+
38+
::::
39+
:::::
40+
41+
[hatch environments]: https://hatch.pypa.io/latest/tutorials/environment/basic-usage/
42+
43+
## Code-style
44+
45+
This package uses [pre-commit][] to enforce consistent code-styles.
46+
On every commit, pre-commit checks will either automatically fix issues with the code, or raise an error message.
47+
48+
To enable pre-commit locally, simply run
49+
50+
```bash
51+
pre-commit install
52+
```
53+
54+
in the root of the repository.
55+
Pre-commit will automatically download all dependencies when it is run for the first time.
56+
57+
Alternatively, you can rely on the [pre-commit.ci][] service enabled on GitHub.
58+
If you didn't run `pre-commit` before pushing changes to GitHub it will automatically commit fixes to your pull request, or show an error message.
59+
60+
If pre-commit.ci added a commit on a branch you still have been working on locally, simply use
61+
62+
```bash
63+
git pull --rebase
64+
```
65+
66+
to integrate the changes into yours.
67+
While the [pre-commit.ci][] is useful, we strongly encourage installing and running pre-commit locally first to understand its usage.
68+
69+
Finally, most editors have an _autoformat on save_ feature.
70+
Consider enabling this option for [ruff][ruff-editors] and [prettier][prettier-editors].
71+
72+
[pre-commit]: https://pre-commit.com/
73+
[pre-commit.ci]: https://pre-commit.ci/
74+
[ruff-editors]: https://docs.astral.sh/ruff/integrations/
75+
76+
[prettier-editors]: https://prettier.io/docs/en/editors.html
77+
78+
(writing-tests)=
79+
80+
## Writing tests
81+
82+
This package uses [pytest][] for automated testing.
83+
Please write {doc}`scanpy:dev/testing` for every function added to the package.
84+
85+
Most IDEs integrate with pytest and provide a GUI to run tests.
86+
Just point yours to one of the environments returned by
87+
88+
```bash
89+
hatch env create hatch-test # create test environments for all supported versions
90+
hatch env find hatch-test # list all possible test environment paths
91+
```
92+
93+
Alternatively, you can run all tests from the command line by executing
94+
95+
:::::{tabs}
96+
::::{group-tab} Hatch
97+
98+
```bash
99+
hatch test # test with the highest supported Python version
100+
# or
101+
hatch test --all # test with all supported Python versions
102+
```
103+
104+
::::
105+
106+
::::{group-tab} Pip
107+
108+
```bash
109+
source .venv/bin/activate
110+
pytest
111+
```
112+
113+
::::
114+
:::::
115+
116+
in the root of the repository.
117+
118+
[pytest]: https://docs.pytest.org/
119+
120+
### Continuous integration
121+
122+
Continuous integration will automatically run the tests on all pull requests and test
123+
against the minimum and maximum supported Python version.
124+
125+
Additionally, there's a CI job that tests against pre-releases of all dependencies (if there are any).
126+
The purpose of this check is to detect incompatibilities of new package versions early on and
127+
gives you time to fix the issue or reach out to the developers of the dependency before the package is released to a wider audience.
128+
129+
## Publishing a release
130+
131+
### Updating the version number
132+
133+
Before making a release, you need to update the version number in the `pyproject.toml` file.
134+
Please adhere to [Semantic Versioning][semver], in brief
135+
136+
> Given a version number MAJOR.MINOR.PATCH, increment the:
137+
>
138+
> 1. MAJOR version when you make incompatible API changes,
139+
> 2. MINOR version when you add functionality in a backwards compatible manner, and
140+
> 3. PATCH version when you make backwards compatible bug fixes.
141+
>
142+
> Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
143+
144+
Once you are done, commit and push your changes and navigate to the "Releases" page of this project on GitHub.
145+
Specify `vX.X.X` as a tag name and create a release.
146+
For more information, see [managing GitHub releases][].
147+
This will automatically create a git tag and trigger a Github workflow that creates a release on [PyPI][].
148+
149+
[semver]: https://semver.org/
150+
[managing GitHub releases]: https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository
151+
[pypi]: https://pypi.org/
152+
153+
## Writing documentation
154+
155+
Please write documentation for new or changed features and use-cases.
156+
This project uses [sphinx][] with the following features:
157+
158+
- The [myst][] extension allows to write documentation in markdown/Markedly Structured Text
159+
- [Numpy-style docstrings][numpydoc] (through the [napoloen][numpydoc-napoleon] extension).
160+
- Jupyter notebooks as tutorials through [myst-nb][] (See [Tutorials with myst-nb](#tutorials-with-myst-nb-and-jupyter-notebooks))
161+
- [sphinx-autodoc-typehints][], to automatically reference annotated input and output types
162+
- Citations (like {cite:p}`Virshup_2023`) can be included with [sphinxcontrib-bibtex](https://sphinxcontrib-bibtex.readthedocs.io/)
163+
164+
See scanpy’s {doc}`scanpy:dev/documentation` for more information on how to write your own.
165+
166+
[sphinx]: https://www.sphinx-doc.org/en/master/
167+
[myst]: https://myst-parser.readthedocs.io/en/latest/intro.html
168+
[myst-nb]: https://myst-nb.readthedocs.io/en/latest/
169+
[numpydoc-napoleon]: https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html
170+
[numpydoc]: https://numpydoc.readthedocs.io/en/latest/format.html
171+
[sphinx-autodoc-typehints]: https://github.com/tox-dev/sphinx-autodoc-typehints
172+
173+
### Tutorials with myst-nb and jupyter notebooks
174+
175+
The documentation is set-up to render jupyter notebooks stored in the `docs/notebooks` directory using [myst-nb][].
176+
Currently, only notebooks in `.ipynb` format are supported that will be included with both their input and output cells.
177+
It is your responsibility to update and re-run the notebook whenever necessary.
178+
179+
If you are interested in automatically running notebooks as part of the continuous integration,
180+
please check out [this feature request][issue-render-notebooks] in the `cookiecutter-scverse` repository.
181+
182+
[issue-render-notebooks]: https://github.com/scverse/cookiecutter-scverse/issues/40
183+
184+
#### Hints
185+
186+
- If you refer to objects from other packages, please add an entry to `intersphinx_mapping` in `docs/conf.py`.
187+
Only if you do so can sphinx automatically create a link to the external documentation.
188+
- If building the documentation fails because of a missing link that is outside your control,
189+
you can add an entry to the `nitpick_ignore` list in `docs/conf.py`
190+
191+
(docs-building)=
192+
193+
#### Building the docs locally
194+
195+
:::::{tabs}
196+
::::{group-tab} Hatch
197+
198+
```bash
199+
hatch run docs:build
200+
hatch run docs:open
201+
```
202+
203+
::::
204+
205+
::::{group-tab} Pip
206+
207+
```bash
208+
source .venv/bin/activate
209+
cd docs
210+
make html
211+
(xdg-)open _build/html/index.html
212+
```
213+
214+
::::
215+
:::::

docs/.ipynb_checkpoints/index-checkpoint.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Plotting <api/plotting.md>
1212
1313
```
1414
```{toctree}
15-
:maxdepth: 1
15+
:maxdepth: 2
1616
:caption: Tutorials
17-
notebooks/0_format_Xenium_sdata
17+
notebooks/Basic_tutorial
1818
1919
```
2020

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
@article{Virshup_2023,
2+
doi = {10.1038/s41587-023-01733-8},
3+
url = {https://doi.org/10.1038%2Fs41587-023-01733-8},
4+
year = 2025,
5+
month = {apr},
6+
publisher = {Springer Science and Business Media {LLC}},
7+
author = {Isaac Virshup and Danila Bredikhin and Lukas Heumos and Giovanni Palla and Gregor Sturm and Adam Gayoso and Ilia Kats and Mikaela Koutrouli and Philipp Angerer and Volker Bergen and Pierre Boyeau and Maren Büttner and Gokcen Eraslan and David Fischer and Max Frank and Justin Hong and Michal Klein and Marius Lange and Romain Lopez and Mohammad Lotfollahi and Malte D. Luecken and Fidel Ramirez and Jeffrey Regier and Sergei Rybakov and Anna C. Schaar and Valeh Valiollah Pour Amiri and Philipp Weiler and Galen Xing and Bonnie Berger and Dana Pe'er and Aviv Regev and Sarah A. Teichmann and Francesca Finotello and F. Alexander Wolf and Nir Yosef and Oliver Stegle and Fabian J. Theis and},
8+
title = {The scverse project provides a computational ecosystem for single-cell omics data analysis},
9+
journal = {Nature Biotechnology}
10+
}
11+
12+
@article{muller2025sainsc,
13+
title={Sainsc: A Computational Tool for Segmentation-Free Analysis of In Situ Capture Data},
14+
author={M{\"u}ller-B{\"o}tticher, Niklas and Tiesmeyer, Sebastian and Eils, Roland and Ishaque, Naveed},
15+
journal={Small Methods},
16+
volume={9},
17+
number={5},
18+
pages={2401123},
19+
year={2025},
20+
publisher={Wiley Online Library}
21+
}
22+
23+
@article{moinfar2024unsupervised,
24+
title={Unsupervised deep disentangled representation of single-cell omics},
25+
author={Moinfar, Amir Ali and Theis, Fabian J},
26+
journal={bioRxiv},
27+
pages={2024--11},
28+
year={2024},
29+
publisher={Cold Spring Harbor Laboratory}
30+
}
31+
32+
@article{blampey2024sopa,
33+
title={Sopa: a technology-invariant pipeline for analyses of image-based spatial omics},
34+
author={Blampey, Quentin and Mulder, Kevin and Gardet, Margaux and Christodoulidis, Stergios and Dutertre, Charles-Antoine and Andr{\'e}, Fabrice and Ginhoux, Florent and Courn{\`e}de, Paul-Henry},
35+
journal={Nature Communications},
36+
volume={15},
37+
number={1},
38+
pages={4981},
39+
year={2024},
40+
publisher={Nature Publishing Group UK London}
41+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# References
2+
3+
```{bibliography}
4+
:cited:
5+
```

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Plotting <api/plotting.md>
1212
1313
```
1414
```{toctree}
15-
:maxdepth: 1
15+
:maxdepth: 2
1616
:caption: Tutorials
17-
notebooks/0_format_Xenium_sdata
17+
notebooks/Basic_tutorial
1818
1919
```
2020

0 commit comments

Comments
 (0)