rectanglepy 1.4.1__tar.gz → 1.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/.bumpversion.cfg +1 -1
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/.readthedocs.yaml +1 -1
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/CHANGELOG.md +10 -4
- rectanglepy-1.5.0/CLA.md +38 -0
- rectanglepy-1.5.0/LICENSE +28 -0
- rectanglepy-1.5.0/LICENSE-Commercial.md +61 -0
- rectanglepy-1.5.0/PKG-INFO +110 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/README.md +11 -6
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/docs/contributing.md +1 -1
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/pyproject.toml +3 -2
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/src/rectanglepy/__init__.py +2 -1
- rectanglepy-1.5.0/src/rectanglepy/parameters.py +11 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/src/rectanglepy/pp/create_signature.py +53 -12
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/src/rectanglepy/pp/rectangle_signature.py +2 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/src/rectanglepy/rectangle.py +8 -1
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/src/rectanglepy/tl/deconvolution.py +2 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/tests/test_pp.py +49 -0
- rectanglepy-1.4.1/LICENCE_COM +0 -203
- rectanglepy-1.4.1/LICENSE +0 -674
- rectanglepy-1.4.1/PKG-INFO +0 -778
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/.cruft.json +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/.editorconfig +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/.github/workflows/build.yaml +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/.github/workflows/release.yaml +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/.github/workflows/release_testpypi.yaml +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/.github/workflows/test.yaml +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/.gitignore +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/.pre-commit-config.yaml +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/docs/Makefile +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/docs/_static/.gitkeep +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/docs/_static/rec_logo.001.png +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/docs/_templates/.gitkeep +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/docs/_templates/autosummary/class.rst +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/docs/api.md +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/docs/changelog.md +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/docs/conf.py +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/docs/extensions/typed_returns.py +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/docs/index.md +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/docs/installation.md +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/docs/make.bat +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/docs/notebooks/example.ipynb +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/docs/references.bib +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/docs/references.md +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/docs/tutorials.md +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/src/rectanglepy/data/hao1_annotations_small.zip +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/src/rectanglepy/data/hao1_counts_small.zip +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/src/rectanglepy/data/small_fino_bulks.zip +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/src/rectanglepy/pp/__init__.py +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/src/rectanglepy/tl/__init__.py +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/tests/data/TIL10_signature.txt +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/tests/data/bulk_small.csv +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/tests/data/cell_annotations_small.txt +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/tests/data/quanTIseq_SimRNAseq_mixture_smaller.csv +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/tests/data/quanTIseq_SimRNAseq_read_fractions_small.txt +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/tests/data/sc_object_small.csv +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/tests/data/signature_hao1.csv +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/tests/test_rectangle.py +0 -0
- {rectanglepy-1.4.1 → rectanglepy-1.5.0}/tests/test_tl.py +0 -0
|
@@ -10,6 +10,12 @@ and this project adheres to [Semantic Versioning][].
|
|
|
10
10
|
|
|
11
11
|
## [Unreleased]
|
|
12
12
|
|
|
13
|
+
## [1.4.2] - 2026-05-24
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- Changed the open-source license from GPLv3 to BSD-3-Clause while retaining the commercial licensing option.
|
|
18
|
+
|
|
13
19
|
## [1.4.1] - 2026-04-23
|
|
14
20
|
|
|
15
21
|
### Changed
|
|
@@ -20,10 +26,10 @@ and this project adheres to [Semantic Versioning][].
|
|
|
20
26
|
|
|
21
27
|
### Changed
|
|
22
28
|
|
|
23
|
-
- **Licensing: Rectangle is
|
|
24
|
-
- Non-commercial use: GNU General Public
|
|
25
|
-
- Commercial use: A proprietary
|
|
26
|
-
- See
|
|
29
|
+
- **Licensing: Rectangle is available under a dual license.**
|
|
30
|
+
- Non-commercial use: GNU General Public License v3 (GPLv3).
|
|
31
|
+
- Commercial use: A proprietary license is available for companies wishing to use Rectangle in closed-source or proprietary applications. For enquiries, contact innovation-psb@uibk.ac.at.
|
|
32
|
+
- See the commercial license terms for details.
|
|
27
33
|
- Added Contributor License Agreement (CLA) for external contributions.
|
|
28
34
|
|
|
29
35
|
## [1.2.0] - 2026-01-31
|
rectanglepy-1.5.0/CLA.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Rectangle Contributor License Agreement (CLA)
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Rectangle is dual-licensed: BSD-3-Clause open source OR a proprietary Commercial license. This CLA ensures Contributions can be used under the BSD-3-Clause license and also re-licensed under the Commercial license.
|
|
6
|
+
|
|
7
|
+
## Definitions
|
|
8
|
+
|
|
9
|
+
- **Contribution**: Any work submitted for inclusion, including code, documentation, tests, examples, or other materials.
|
|
10
|
+
- **Contributor**: The individual or entity submitting a Contribution.
|
|
11
|
+
- **Project Owners**: Francesca Finotello and Bernhard Eder.
|
|
12
|
+
|
|
13
|
+
## Grant of rights
|
|
14
|
+
|
|
15
|
+
The Contributor grants the Project Owners a perpetual, worldwide, irrevocable, non-exclusive, transferable license to use, reproduce, modify, create derivative works of, publicly display, perform, sublicense, and distribute the Contribution:
|
|
16
|
+
|
|
17
|
+
- under the BSD-3-Clause license; and
|
|
18
|
+
- under one or more proprietary licenses at the Project Owners’ discretion.
|
|
19
|
+
|
|
20
|
+
## Copyright
|
|
21
|
+
|
|
22
|
+
The Contributor retains copyright in their Contribution.
|
|
23
|
+
|
|
24
|
+
## Disclaimer
|
|
25
|
+
|
|
26
|
+
Contributions are provided “AS IS,” without warranties or conditions of any kind.
|
|
27
|
+
|
|
28
|
+
## Compensation
|
|
29
|
+
|
|
30
|
+
No compensation is owed for Contributions unless separately agreed in writing.
|
|
31
|
+
|
|
32
|
+
## Governing law
|
|
33
|
+
|
|
34
|
+
This CLA is governed by the laws of Austria, excluding conflict of law rules.
|
|
35
|
+
|
|
36
|
+
## Acceptance
|
|
37
|
+
|
|
38
|
+
By submitting a Contribution, for example via pull request, you agree to this CLA.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, Francesca Finotello and Bernhard Eder
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the names of the copyright holders nor the names of contributors may
|
|
16
|
+
be used to endorse or promote products derived from this software without
|
|
17
|
+
specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
20
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
21
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES, INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
|
27
|
+
TORT, INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF
|
|
28
|
+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Rectangle – Commercial License Terms
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Francesca Finotello and Bernhard Eder
|
|
4
|
+
Contact: innovation-psb@uibk.ac.at
|
|
5
|
+
|
|
6
|
+
These Commercial License Terms apply only if the Licensors and Licensee have entered into a written commercial license agreement, order form, or other written agreement that expressly incorporates these terms. Otherwise, Rectangle is available under the BSD-3-Clause license in the `LICENSE` file.
|
|
7
|
+
|
|
8
|
+
## Dual licensing
|
|
9
|
+
|
|
10
|
+
- Rectangle is dual-licensed: BSD-3-Clause OR Commercial.
|
|
11
|
+
- If you use Rectangle under the BSD-3-Clause license, the terms in `LICENSE` apply.
|
|
12
|
+
- If you require different terms, such as warranties, indemnities, dedicated support, or redistribution without BSD notices, you must obtain a commercial license from the copyright holders.
|
|
13
|
+
|
|
14
|
+
## Grant of rights Commercial
|
|
15
|
+
|
|
16
|
+
Subject to full payment of the agreed license fee, the applicable written agreement or order form, and compliance with these terms, the Licensee is granted a non-exclusive, non-transferable, worldwide license to:
|
|
17
|
+
|
|
18
|
+
- use Rectangle internally and in products/services;
|
|
19
|
+
- modify and create derivative works; and
|
|
20
|
+
- distribute Rectangle, in source or binary form, as part of proprietary applications, without any obligation to disclose source code and without attribution requirements beyond what is agreed here.
|
|
21
|
+
|
|
22
|
+
## Term and scope
|
|
23
|
+
|
|
24
|
+
- Perpetual term unless otherwise stated in the order form.
|
|
25
|
+
- License is limited to the legal entity named in the order form.
|
|
26
|
+
- Sub-licensing, assignment, or transfer requires prior written consent of the Licensors.
|
|
27
|
+
|
|
28
|
+
## Attribution and notices
|
|
29
|
+
|
|
30
|
+
- No attribution is required unless otherwise agreed in the order form.
|
|
31
|
+
- The Licensee may not use the Licensors’ or contributors’ names or trademarks to endorse or promote products without prior written permission.
|
|
32
|
+
|
|
33
|
+
## Support and updates
|
|
34
|
+
|
|
35
|
+
- Support, maintenance, and updates are not included unless purchased separately under a support agreement.
|
|
36
|
+
|
|
37
|
+
## Compliance
|
|
38
|
+
|
|
39
|
+
- The Licensee is responsible for ensuring that distribution and use comply with applicable laws and third-party licenses.
|
|
40
|
+
- Anyone who has not entered into a separate commercial license agreement may use Rectangle only under the BSD-3-Clause license.
|
|
41
|
+
|
|
42
|
+
## Liability and warranty
|
|
43
|
+
|
|
44
|
+
- Rectangle is provided “AS IS.” The Licensors disclaim all warranties unless explicitly provided in a separate support agreement or SLA.
|
|
45
|
+
- To the extent permitted by law, Licensors’ aggregate liability is limited to the amount paid by the Licensee for the commercial license during the 12 months preceding the claim.
|
|
46
|
+
- Licensors are not liable for indirect, incidental, special, or consequential damages.
|
|
47
|
+
|
|
48
|
+
## Termination
|
|
49
|
+
|
|
50
|
+
- Licensors may terminate this license for material breach if not cured within 30 days of written notice.
|
|
51
|
+
- Upon termination, Licensee shall cease use and destroy copies within a reasonable time.
|
|
52
|
+
|
|
53
|
+
## Governing law and venue
|
|
54
|
+
|
|
55
|
+
- This Agreement is governed by the laws of Austria, excluding conflict of law rules.
|
|
56
|
+
- Exclusive jurisdiction and venue are the competent courts at the Licensors’ registered seat, to the extent legally permissible.
|
|
57
|
+
|
|
58
|
+
## Entire agreement and amendments
|
|
59
|
+
|
|
60
|
+
- This constitutes the entire agreement for commercial use.
|
|
61
|
+
- Amendments must be in writing and signed by both parties.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rectanglepy
|
|
3
|
+
Version: 1.5.0
|
|
4
|
+
Summary: Hierarchical deconvolution of bulk transcriptomics
|
|
5
|
+
Project-URL: Documentation, https://rectanglepy.readthedocs.io/
|
|
6
|
+
Project-URL: Source, https://github.com/ComputationalBiomedicineGroup/Rectangle
|
|
7
|
+
Project-URL: Home-page, https://github.com/ComputationalBiomedicineGroup/Rectangle
|
|
8
|
+
Author: Bernhard Eder
|
|
9
|
+
Maintainer-email: Bernhard Eder <Bernhard.Eder@student.uibk.ac.at>
|
|
10
|
+
License-Expression: BSD-3-Clause OR LicenseRef-Rectangle-Commercial
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
License-File: LICENSE-Commercial.md
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Requires-Dist: anndata<0.10.9,>=0.8.0
|
|
15
|
+
Requires-Dist: loguru
|
|
16
|
+
Requires-Dist: numpy<2.0.0,>=1.0.0
|
|
17
|
+
Requires-Dist: osqp>=1.0.5
|
|
18
|
+
Requires-Dist: pandas<3.0.0,>=2.0.0
|
|
19
|
+
Requires-Dist: pydeseq2==0.4.11
|
|
20
|
+
Requires-Dist: scipy==1.13.0
|
|
21
|
+
Requires-Dist: statsmodels>=0.14.1
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: bump2version; extra == 'dev'
|
|
24
|
+
Requires-Dist: pre-commit; extra == 'dev'
|
|
25
|
+
Requires-Dist: twine>=4.0.2; extra == 'dev'
|
|
26
|
+
Provides-Extra: doc
|
|
27
|
+
Requires-Dist: furo; extra == 'doc'
|
|
28
|
+
Requires-Dist: ipykernel; extra == 'doc'
|
|
29
|
+
Requires-Dist: ipython; extra == 'doc'
|
|
30
|
+
Requires-Dist: myst-nb; extra == 'doc'
|
|
31
|
+
Requires-Dist: sphinx; extra == 'doc'
|
|
32
|
+
Requires-Dist: sphinx-autodoc-typehints; extra == 'doc'
|
|
33
|
+
Requires-Dist: sphinx-book-theme; extra == 'doc'
|
|
34
|
+
Requires-Dist: sphinx-copybutton; extra == 'doc'
|
|
35
|
+
Requires-Dist: sphinxcontrib-bibtex; extra == 'doc'
|
|
36
|
+
Provides-Extra: test
|
|
37
|
+
Requires-Dist: pytest; extra == 'test'
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
|
|
40
|
+
# Rectangle
|
|
41
|
+
|
|
42
|
+
[![Tests][badge-tests]][link-tests]
|
|
43
|
+
[![Documentation][badge-docs]][link-docs]
|
|
44
|
+
|
|
45
|
+
[badge-tests]: https://img.shields.io/github/actions/workflow/status/ComputationalBiomedicineGroup/Rectangle/build.yaml?branch=main
|
|
46
|
+
[link-tests]: https://github.com/ComputationalBiomedicineGroup/Rectangle/actions/workflows/build.yaml
|
|
47
|
+
[badge-docs]: https://img.shields.io/readthedocs/rectanglepy
|
|
48
|
+
|
|
49
|
+
Rectangle is an open-source Python package for single-cell-informed cell-type deconvolution of bulk and spatial transcriptomic data, which is part of the [scverse ecosystem](https://scverse.org/packages/).
|
|
50
|
+
|
|
51
|
+
Rectangle presents a novel approach to second-generation deconvolution, characterized by hierarchical signature building for fine-grained cell-type deconvolution, estimation and correction of unknown cellular content, and efficient handling of large-scale single-cell data during signature matrix computation.
|
|
52
|
+
|
|
53
|
+
Rectangle was developed to overcome the current challenges in cell-type deconvolution, providing a robust and accurate methodology while ensuring a low computational profile.
|
|
54
|
+
|
|
55
|
+
## Getting started
|
|
56
|
+
|
|
57
|
+
Please refer to the [documentation][link-docs]. In particular, the
|
|
58
|
+
|
|
59
|
+
- [Tutorials][link-docs/tutorials] for a step-by-step guide on how to use Rectangle, and the
|
|
60
|
+
|
|
61
|
+
- [API documentation][link-api].
|
|
62
|
+
|
|
63
|
+
## Installation
|
|
64
|
+
|
|
65
|
+
You need Python 3.10–3.12 installed on your system.
|
|
66
|
+
|
|
67
|
+
How to install Rectangle:
|
|
68
|
+
|
|
69
|
+
Install the latest release of `Rectangle` from `PyPI` <https://pypi.org/project/rectanglepy/>:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install rectanglepy
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
Rectangle is dual-licensed: BSD-3-Clause OR Commercial.
|
|
78
|
+
|
|
79
|
+
### Open-source option: BSD-3-Clause
|
|
80
|
+
|
|
81
|
+
You may use, modify, and redistribute Rectangle, including in proprietary products, if you keep the copyright and license notices and do not use the authors’ names for endorsement.
|
|
82
|
+
|
|
83
|
+
See [LICENSE](LICENSE).
|
|
84
|
+
|
|
85
|
+
### Commercial option
|
|
86
|
+
|
|
87
|
+
For alternative terms, such as warranties, indemnities, dedicated support, SLAs, or redistribution without BSD notice requirements, contact innovation-psb@uibk.ac.at.
|
|
88
|
+
|
|
89
|
+
See [LICENSE-Commercial.md](LICENSE-Commercial.md).
|
|
90
|
+
|
|
91
|
+
## Release notes
|
|
92
|
+
|
|
93
|
+
See the [changelog][changelog].
|
|
94
|
+
|
|
95
|
+
## Contact
|
|
96
|
+
|
|
97
|
+
If you found a bug, please use the [issue tracker][issue-tracker].
|
|
98
|
+
|
|
99
|
+
For commercial licensing: **innovation-psb@uibk.ac.at**
|
|
100
|
+
|
|
101
|
+
## Citation
|
|
102
|
+
|
|
103
|
+
> If you use Rectangle in your project, please cite: (TBA)
|
|
104
|
+
|
|
105
|
+
[scverse-discourse]: https://discourse.scverse.org/
|
|
106
|
+
[issue-tracker]: https://github.com/ComputationalBiomedicineGroup/Rectangle/issues
|
|
107
|
+
[changelog]: https://rectanglepy.readthedocs.io/changelog.html
|
|
108
|
+
[link-docs]: https://Rectanglepy.readthedocs.io
|
|
109
|
+
[link-api]: https://rectanglepy.readthedocs.io/api.html
|
|
110
|
+
[link-docs/tutorials]: https://rectanglepy.readthedocs.io/notebooks/example.html
|
|
@@ -33,16 +33,21 @@ Install the latest release of `Rectangle` from `PyPI` <https://pypi.org/project/
|
|
|
33
33
|
pip install rectanglepy
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
##
|
|
36
|
+
## License
|
|
37
37
|
|
|
38
|
-
Rectangle is
|
|
38
|
+
Rectangle is dual-licensed: BSD-3-Clause OR Commercial.
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
→ Free to use, modify, and redistribute as long as modifications and redistributions are also under GPLv3.
|
|
40
|
+
### Open-source option: BSD-3-Clause
|
|
42
41
|
|
|
43
|
-
|
|
42
|
+
You may use, modify, and redistribute Rectangle, including in proprietary products, if you keep the copyright and license notices and do not use the authors’ names for endorsement.
|
|
44
43
|
|
|
45
|
-
|
|
44
|
+
See [LICENSE](LICENSE).
|
|
45
|
+
|
|
46
|
+
### Commercial option
|
|
47
|
+
|
|
48
|
+
For alternative terms, such as warranties, indemnities, dedicated support, SLAs, or redistribution without BSD notice requirements, contact innovation-psb@uibk.ac.at.
|
|
49
|
+
|
|
50
|
+
See [LICENSE-Commercial.md](LICENSE-Commercial.md).
|
|
46
51
|
|
|
47
52
|
## Release notes
|
|
48
53
|
|
|
@@ -4,7 +4,7 @@ We welcome contributions! The best way to contribute is by opening a pull reques
|
|
|
4
4
|
|
|
5
5
|
## Contributor License Agreement (CLA)
|
|
6
6
|
|
|
7
|
-
Rectangle uses a dual-licensing model (
|
|
7
|
+
Rectangle uses a dual-licensing model (BSD-3-Clause OR Commercial). By submitting a contribution (e.g., via pull request), you agree to the terms of our [Contributor License Agreement (CLA)](https://github.com/ComputationalBiomedicineGroup/Rectangle/blob/main/CLA.md). This ensures that contributions can be included in both the open-source and commercial versions of Rectangle.
|
|
8
8
|
|
|
9
9
|
## How to Contribute
|
|
10
10
|
|
|
@@ -4,11 +4,12 @@ requires = ["hatchling"]
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "rectanglepy"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.5.0"
|
|
8
8
|
description = "Hierarchical deconvolution of bulk transcriptomics"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
11
|
-
license =
|
|
11
|
+
license = "BSD-3-Clause OR LicenseRef-Rectangle-Commercial"
|
|
12
|
+
license-files = ["LICENSE", "LICENSE-Commercial.md"]
|
|
12
13
|
authors = [
|
|
13
14
|
{name = "Bernhard Eder"},
|
|
14
15
|
]
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
from importlib.metadata import version
|
|
2
2
|
|
|
3
3
|
from . import pp, tl
|
|
4
|
+
from .parameters import RectangleAdvancedParameters
|
|
4
5
|
from .rectangle import load_tutorial_data, rectangle
|
|
5
6
|
|
|
6
|
-
__all__ = ["pp", "tl", "load_tutorial_data", "rectangle"]
|
|
7
|
+
__all__ = ["pp", "tl", "RectangleAdvancedParameters", "load_tutorial_data", "rectangle"]
|
|
7
8
|
|
|
8
9
|
__version__ = version("rectanglepy")
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# SPDX-License-Identifier: BSD-3-Clause OR LicenseRef-Rectangle-Commercial
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass(frozen=True)
|
|
7
|
+
class RectangleAdvancedParameters:
|
|
8
|
+
"""Advanced parameters for Rectangle internals."""
|
|
9
|
+
|
|
10
|
+
number_of_bootstraps: int = 7
|
|
11
|
+
grid_search_split_size: int = 50
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# SPDX-License-Identifier: BSD-3-Clause OR LicenseRef-Rectangle-Commercial
|
|
2
|
+
|
|
1
3
|
import numpy as np
|
|
2
4
|
import pandas as pd
|
|
3
5
|
import scipy.sparse
|
|
@@ -11,6 +13,7 @@ from scipy.cluster.hierarchy import fcluster, linkage
|
|
|
11
13
|
from scipy.stats import pearsonr
|
|
12
14
|
from sklearn.metrics import silhouette_score
|
|
13
15
|
|
|
16
|
+
from rectanglepy.parameters import RectangleAdvancedParameters
|
|
14
17
|
from rectanglepy.tl.deconvolution import solve_qp
|
|
15
18
|
|
|
16
19
|
from .rectangle_signature import RectangleSignatureResult
|
|
@@ -127,11 +130,16 @@ def _filter_de_analysis_results(de_analysis_result, p, logfc):
|
|
|
127
130
|
|
|
128
131
|
|
|
129
132
|
def _run_deseq2(
|
|
130
|
-
countsig: pd.DataFrame,
|
|
133
|
+
countsig: pd.DataFrame,
|
|
134
|
+
sc_data,
|
|
135
|
+
annotations: pd.Series,
|
|
136
|
+
n_cpus: int = None,
|
|
137
|
+
gene_expression_threshold=0.5,
|
|
138
|
+
number_of_bootstraps: int = 7,
|
|
131
139
|
) -> dict[str | int, pd.DataFrame]:
|
|
132
140
|
results = {}
|
|
133
141
|
inference = DefaultInference(n_cpus=n_cpus)
|
|
134
|
-
bootstrapped_signature = _create_bootstrap_signature(countsig, sc_data, annotations)
|
|
142
|
+
bootstrapped_signature = _create_bootstrap_signature(countsig, sc_data, annotations, number_of_bootstraps)
|
|
135
143
|
np.random.seed(42)
|
|
136
144
|
for _i, cell_type in enumerate(countsig.columns):
|
|
137
145
|
bootstrapped_signature_copy = bootstrapped_signature.copy()
|
|
@@ -165,12 +173,11 @@ def _run_deseq2(
|
|
|
165
173
|
return results
|
|
166
174
|
|
|
167
175
|
|
|
168
|
-
def _create_bootstrap_signature(countsig, sc_data, annotations) -> pd.DataFrame:
|
|
176
|
+
def _create_bootstrap_signature(countsig, sc_data, annotations, number_of_bootstraps: int = 7) -> pd.DataFrame:
|
|
169
177
|
if scipy.sparse.issparse(sc_data):
|
|
170
178
|
sc_data = sc_data.toarray()
|
|
171
179
|
celltypes = countsig.columns
|
|
172
180
|
bootstrapped_signature = pd.DataFrame()
|
|
173
|
-
number_of_bootstraps = 7
|
|
174
181
|
samples_per_bootstrap = 500
|
|
175
182
|
np.random.seed(42)
|
|
176
183
|
for celltype in celltypes:
|
|
@@ -196,14 +203,30 @@ def _de_analysis(
|
|
|
196
203
|
n_cpus: int = None,
|
|
197
204
|
genes=None,
|
|
198
205
|
gene_expression_threshold=0.5,
|
|
206
|
+
advanced_parameters: RectangleAdvancedParameters = None,
|
|
199
207
|
) -> tuple[Series, dict[str, [str]] :, DataFrame | None]:
|
|
200
208
|
logger.info("Starting DE analysis")
|
|
201
|
-
|
|
209
|
+
advanced_parameters = advanced_parameters or RectangleAdvancedParameters()
|
|
210
|
+
deseq_results = _run_deseq2(
|
|
211
|
+
pseudo_count_sig,
|
|
212
|
+
sc_data,
|
|
213
|
+
annotations,
|
|
214
|
+
n_cpus,
|
|
215
|
+
gene_expression_threshold,
|
|
216
|
+
advanced_parameters.number_of_bootstraps,
|
|
217
|
+
)
|
|
202
218
|
optimization_results = None
|
|
203
219
|
|
|
204
220
|
if optimize_cutoffs:
|
|
205
221
|
logger.info("Optimizing cutoff parameters p and lfc")
|
|
206
|
-
optimization_results = _optimize_parameters(
|
|
222
|
+
optimization_results = _optimize_parameters(
|
|
223
|
+
sc_data,
|
|
224
|
+
annotations,
|
|
225
|
+
pseudo_count_sig,
|
|
226
|
+
deseq_results,
|
|
227
|
+
genes,
|
|
228
|
+
advanced_parameters.grid_search_split_size,
|
|
229
|
+
)
|
|
207
230
|
p, lfc = optimization_results.iloc[0, 0:2]
|
|
208
231
|
logger.info(f"Optimization done\n Best cutoffs p: {p} and lfc: {lfc}")
|
|
209
232
|
|
|
@@ -285,6 +308,7 @@ def build_rectangle_signatures(
|
|
|
285
308
|
lfc=1.5,
|
|
286
309
|
n_cpus: int = None,
|
|
287
310
|
gene_expression_threshold=0.5,
|
|
311
|
+
advanced_parameters: RectangleAdvancedParameters = None,
|
|
288
312
|
) -> RectangleSignatureResult:
|
|
289
313
|
r"""Builds rectangle signatures based on single-cell count data and annotations.
|
|
290
314
|
|
|
@@ -301,7 +325,7 @@ def build_rectangle_signatures(
|
|
|
301
325
|
raw
|
|
302
326
|
A flag indicating whether to use the raw Anndata data. Defaults to False.
|
|
303
327
|
optimize_cutoffs
|
|
304
|
-
Indicates whether to optimize the
|
|
328
|
+
Indicates whether to optimize the log fold change cutoffs using gridsearch. Defaults to True.
|
|
305
329
|
p
|
|
306
330
|
The p-value threshold for the DE analysis (only used if optimize_cutoffs is False).
|
|
307
331
|
lfc
|
|
@@ -310,11 +334,14 @@ def build_rectangle_signatures(
|
|
|
310
334
|
The number of cpus to use for the DE analysis. Defaults to the number of cpus available.
|
|
311
335
|
gene_expression_threshold
|
|
312
336
|
The gene expression threshold for the DE analysis. How many cells need to express a gene to be considered in DGE
|
|
337
|
+
advanced_parameters
|
|
338
|
+
Optional advanced Rectangle parameters. Defaults are used when not provided.
|
|
313
339
|
|
|
314
340
|
Returns
|
|
315
341
|
-------
|
|
316
342
|
The result of the rectangle signature analysis which is of type RectangleSignatureResult.
|
|
317
343
|
"""
|
|
344
|
+
advanced_parameters = advanced_parameters or RectangleAdvancedParameters()
|
|
318
345
|
annotations = adata.obs[cell_type_col]
|
|
319
346
|
adata = adata[:, adata.X.sum(axis=0) > len(annotations.value_counts())]
|
|
320
347
|
assert adata.var_names.is_unique, "Duplicate gene found in adata"
|
|
@@ -342,7 +369,16 @@ def build_rectangle_signatures(
|
|
|
342
369
|
m_rna_biasfactors = _create_bias_factors(pseudo_sig_counts, sc_counts, annotations)
|
|
343
370
|
|
|
344
371
|
marker_genes, marker_genes_per_cell_type, optimization_result = _de_analysis(
|
|
345
|
-
pseudo_sig_counts,
|
|
372
|
+
pseudo_sig_counts,
|
|
373
|
+
sc_counts,
|
|
374
|
+
annotations,
|
|
375
|
+
p,
|
|
376
|
+
lfc,
|
|
377
|
+
optimize_cutoffs,
|
|
378
|
+
n_cpus,
|
|
379
|
+
genes,
|
|
380
|
+
gene_expression_threshold,
|
|
381
|
+
advanced_parameters,
|
|
346
382
|
)
|
|
347
383
|
pseudo_sig_cpm = _convert_to_cpm(pseudo_sig_counts)
|
|
348
384
|
logger.info("Starting rectangle cluster analysis")
|
|
@@ -369,6 +405,7 @@ def build_rectangle_signatures(
|
|
|
369
405
|
lfc,
|
|
370
406
|
False,
|
|
371
407
|
gene_expression_threshold=gene_expression_threshold,
|
|
408
|
+
advanced_parameters=advanced_parameters,
|
|
372
409
|
)
|
|
373
410
|
clustered_signature = _convert_to_cpm(clustered_signature)
|
|
374
411
|
return RectangleSignatureResult(
|
|
@@ -398,7 +435,12 @@ def _create_pseudo_count_sig(sc_counts: np.ndarray, annotations: pd.Series, var_
|
|
|
398
435
|
|
|
399
436
|
|
|
400
437
|
def _optimize_parameters(
|
|
401
|
-
sc_data: pd.DataFrame,
|
|
438
|
+
sc_data: pd.DataFrame,
|
|
439
|
+
annotations: pd.Series,
|
|
440
|
+
pseudo_signature_counts: pd.DataFrame,
|
|
441
|
+
de_results,
|
|
442
|
+
genes=None,
|
|
443
|
+
grid_search_split_size: int = 50,
|
|
402
444
|
) -> pd.DataFrame:
|
|
403
445
|
# search space for p and lfc
|
|
404
446
|
lfcs = [x / 100 for x in range(160, 230, 10)]
|
|
@@ -406,7 +448,7 @@ def _optimize_parameters(
|
|
|
406
448
|
|
|
407
449
|
results = []
|
|
408
450
|
logger.info("generating pseudo bulks")
|
|
409
|
-
bulks, real_fractions = _generate_pseudo_bulks(sc_data, annotations, genes)
|
|
451
|
+
bulks, real_fractions = _generate_pseudo_bulks(sc_data, annotations, genes, grid_search_split_size)
|
|
410
452
|
for p in ps:
|
|
411
453
|
for lfc in lfcs:
|
|
412
454
|
try:
|
|
@@ -439,9 +481,8 @@ def _assess_parameter_fit(
|
|
|
439
481
|
return rsme, pearson_r
|
|
440
482
|
|
|
441
483
|
|
|
442
|
-
def _generate_pseudo_bulks(sc_data, annotations, genes=None):
|
|
484
|
+
def _generate_pseudo_bulks(sc_data, annotations, genes=None, split_size: int = 50):
|
|
443
485
|
number_of_bulks = 50
|
|
444
|
-
split_size = 50
|
|
445
486
|
bulks = []
|
|
446
487
|
real_fractions = []
|
|
447
488
|
np.random.seed(42)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# SPDX-License-Identifier: BSD-3-Clause OR LicenseRef-Rectangle-Commercial
|
|
2
|
+
|
|
1
3
|
from importlib.resources import files
|
|
2
4
|
|
|
3
5
|
import pandas as pd
|
|
@@ -5,6 +7,7 @@ from anndata import AnnData
|
|
|
5
7
|
from loguru import logger
|
|
6
8
|
from pandas import DataFrame
|
|
7
9
|
|
|
10
|
+
from .parameters import RectangleAdvancedParameters
|
|
8
11
|
from .pp import RectangleSignatureResult, build_rectangle_signatures
|
|
9
12
|
from .tl import deconvolution
|
|
10
13
|
|
|
@@ -22,6 +25,7 @@ def rectangle(
|
|
|
22
25
|
lfc=1.5,
|
|
23
26
|
n_cpus: int = None,
|
|
24
27
|
gene_expression_threshold=0.5,
|
|
28
|
+
advanced_parameters: RectangleAdvancedParameters = None,
|
|
25
29
|
) -> tuple[DataFrame, RectangleSignatureResult]:
|
|
26
30
|
r"""All in one deconvolution method. Creates signatures and deconvolutes the bulk data. Has options for subsampling and consensus runs.
|
|
27
31
|
|
|
@@ -38,7 +42,7 @@ def rectangle(
|
|
|
38
42
|
raw
|
|
39
43
|
A flag indicating whether to use the raw Anndata data.
|
|
40
44
|
optimize_cutoffs
|
|
41
|
-
Indicates whether to optimize the
|
|
45
|
+
Indicates whether to optimize the log fold change cutoffs using gridsearch.
|
|
42
46
|
p
|
|
43
47
|
The p-value threshold for the DE analysis (only used if optimize_cutoffs is False).
|
|
44
48
|
lfc
|
|
@@ -49,6 +53,8 @@ def rectangle(
|
|
|
49
53
|
A flag indicating whether to correct for mRNA bias. Defaults to True.
|
|
50
54
|
gene_expression_threshold : float
|
|
51
55
|
The threshold for gene expression. Genes with expression below this threshold are removed from the analysis.
|
|
56
|
+
advanced_parameters
|
|
57
|
+
Optional advanced Rectangle parameters. Defaults are used when not provided.
|
|
52
58
|
|
|
53
59
|
Returns
|
|
54
60
|
-------
|
|
@@ -69,6 +75,7 @@ def rectangle(
|
|
|
69
75
|
lfc=lfc,
|
|
70
76
|
n_cpus=n_cpus,
|
|
71
77
|
gene_expression_threshold=gene_expression_threshold,
|
|
78
|
+
advanced_parameters=advanced_parameters,
|
|
72
79
|
)
|
|
73
80
|
|
|
74
81
|
estimations, bulk_err = deconvolution(signatures, bulks, correct_mrna_bias, n_cpus)
|