Add SpatialLeiden as clustering method
Close #879
Added support for spatialleiden as a flavor in sq.gr.calculate_niche, following up on the idea mentioned in #879. The method is now integrated via the flavor="spatialleiden" option, wrapping the spatialleiden.spatialleiden() function.
@niklasmueboe FYI as the author of spatialleiden.
This PR adds spatialleiden as an option in sq.gr.calculate_niche() via the flavor argument.
Note: spatialleiden depends on leidenalg, which was removed as a hard dependency in PR #972 to keep BSD3 compliance. So, there might be some overlap or conflicts to consider regarding dependencies.
Codecov Report
:x: Patch coverage is 16.00000% with 42 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 66.14%. Comparing base (d4f256f) to head (44817e7).
:warning: Report is 2 commits behind head on main.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/squidpy/gr/_niche.py | 14.28% | 34 Missing and 8 partials :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #1019 +/- ##
==========================================
- Coverage 66.45% 66.14% -0.31%
==========================================
Files 44 44
Lines 7115 7158 +43
Branches 1199 1218 +19
==========================================
+ Hits 4728 4735 +7
- Misses 1913 1944 +31
- Partials 474 479 +5
| Files with missing lines | Coverage Δ | |
|---|---|---|
| src/squidpy/_constants/_constants.py | 100.00% <100.00%> (ø) |
|
| src/squidpy/gr/_niche.py | 32.28% <14.28%> (-2.23%) |
:arrow_down: |
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Hi @melocery sorry for my late response. We were a bit inactive regarding the update of the niche function, but we are getting back into it now. This looks like a great PR and was certainly needed! Thank you for the contribution.
Will check it asap. Shouldn't take too long to merge.
Hey @melocery, thank you for PR! However, there's a licensing issue with it, so we can't accept it in this state.
Your PR adds a hard dependency on SpatialLeiden. While it mostly mirrors our dependencies, it has leidenalg as a hard dependency, which is licensed under GPL3. GPL3 is a copy-left license, and therefore your package is actually also GPL3 (not MIT), and ours would be too. That'd prevent most commercial entities from using Squidpy, which we don't want to prevent.
For us to depend on SpatialLeiden, you'd have to find a way how people can install and run your algorithm without the leidenalg package.
... it has leidenalg as a hard dependency, which is licensed under GPL3. GPL3 is a copy-left license, and therefore your package is actually also GPL3 (not MIT) ...
Thanks for the hint, I didn't properly check the licenses before apparently.
Another question (that may be misplaced here but is still in scope of the scverse); scanpy is also BSD3 but does also depend on leidenalg and igraph which are both GPL licensed. Is this because they are only used in optional dependencies?
For us to depend on SpatialLeiden, you'd have to find a way how people can install and run your algorithm without the leidenalg package.
Currently, i don't think there is a way short of a reimplementation of leidenalg. The Leiden implementation in igraph does not implement the necessary functionality and even if it did it is also GPL licensed.
scanpy is also BSD3 but does also depend on leidenalg and igraph which are both GPL licensed. Is this because they are only used in optional dependencies?
Yes, exactly 👍
I just pushed some changes that make it an optional dependency, similar to how scanpy handles it. I'll play around with it a bit and then give feedback.
@timtreis before you merge, I would push a new spatialleiden version today reflecting the license changes (otherwise it will be the same). Maybe it then makes sense to include a dependency specifier in the pyproject.toml as either >=0.4.0 or ~=0.4.0 (depending on your preferences/conventions) to make sure the version with the correct license is pulled
Ok, so the new release is published to PyPI (conda will follow soon).
The package is available on both PyPI and bioconda.
Is there anything I can support you with from my side?
merged! Thank you for the contribution @niklasmueboe !