Skip to content

Commit fb531d6

Browse files
authored
Merge pull request #228 from saezlab/metalinks_access
Metalinks access
2 parents 305ea03 + a41a3ba commit fb531d6

File tree

9 files changed

+73
-46
lines changed

9 files changed

+73
-46
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 1.7.0
2+
current_version = 1.7.1
33
commit = True
44
tag = True
55

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 1.7.1 (24.01.2026)
4+
5+
- Fixed issue with Metalinks download due to User-Agent restrictions.
6+
- Added scanpy version compatibility using getattr to handle both _set_default_colors_for_categorical_obs (old) and set_default_colors_for_categorical_obs (new).
7+
8+
39
## 1.7.0 (07.01.2026)
410

511
- Inflow implementation and tutorial #221 by @AtheerAS

README.md

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,51 @@ We welcome suggestions, ideas, and contributions! Please do not hesitate to cont
2020
A set of extensive vignettes can be found in the [LIANA+ documentation](https://liana-py.readthedocs.io/en/latest/).
2121

2222
## Decision Tree
23-
### Does the data contain spatial coordinates?
24-
#### Yes
25-
- **Q: Bivariate or unsupervised, multi-variate, and multi-view analysis?**
26-
- **Bivariate:**
27-
- **Q: Are you interested in identifying the subregions of interactions (i.e., local interactions)?**
28-
- **Yes:** Check the [**Local** Bivariate Metrics](https://liana-py.readthedocs.io/en/latest/notebooks/bivariate.html#Bivariate-Ligand-Receptor-Relationships)
29-
- **No:** Check the [**Global** Bivariate Metrics](https://liana-py.readthedocs.io/en/latest/notebooks/bivariate.html#Bivariate-Ligand-Receptor-Relationships)
30-
- **Unsupervised:** [Multi-view learning](https://liana-py.readthedocs.io/en/latest/notebooks/misty.html)
31-
32-
#### No
33-
- **Q: Are you interested in comparing CCC across samples?**
34-
- **Yes:**
35-
- **Q: Are you interested in a specific contrast?**
36-
- **Yes:** [Differential Contrasts and Downstream Signalling](https://liana-py.readthedocs.io/en/latest/notebooks/targeted.html)
37-
- **No:** Unsupervised Cross-conditional LR inference with [MOFA+](https://liana-py.readthedocs.io/en/latest/notebooks/mofatalk.html) or [Tensor-cell2cell](https://liana-py.readthedocs.io/en/latest/notebooks/liana_c2c.html)
38-
- **No:** [Steady-state Ligand-Receptor inference](https://liana-py.readthedocs.io/en/latest/notebooks/basic_usage.html)
39-
40-
### Is your data Multi-modal?
41-
- **Spatial:** [Integrating Multi-Modal Spatially-Resolved Technologies](https://liana-py.readthedocs.io/en/latest/notebooks/sma.html)
42-
- **Non-Spatial:** [Integrating Multi-Modal Single-Cell Technologies](https://liana-py.readthedocs.io/en/latest/notebooks/sc_multi.html)
43-
44-
#### Infer Metabolite-mediated CCC from transcriptomics?
45-
- [Non-spatial Data](https://liana-py.readthedocs.io/en/latest/notebooks/sc_multi.html#Metabolite-mediated-CCC-from-Transcriptomics-Data)
23+
24+
```mermaid
25+
flowchart TD
26+
Start[What type of data?] --> Spatial{Spatial<br/>coordinates?}
27+
Start --> Modal{Multi-modal?}
28+
29+
%% Spatial branch
30+
Spatial -->|Yes| SpatialRes{Resolution?}
31+
SpatialRes -->|Single-cell| Inflow[Inflow Score]
32+
SpatialRes -->|Spot-based| SpatialType{Analysis type?}
33+
SpatialType -->|Bivariate| LocalQ{Local<br/>interactions?}
34+
LocalQ -->|Yes| Local[Local Bivariate Metrics]
35+
LocalQ -->|No| Global[Global Bivariate Metrics]
36+
SpatialType -->|Unsupervised| MISTy[Multi-view Learning]
37+
38+
%% Non-spatial branch
39+
Spatial -->|No| Compare{Compare across<br/>samples?}
40+
Compare -->|Yes| Contrast{Specific<br/>contrast?}
41+
Contrast -->|Yes| Targeted[Differential Contrasts]
42+
Contrast -->|No| MOFA[MOFA+]
43+
Contrast -->|No| Tensor[Tensor-cell2cell]
44+
Tensor --> TensorExt[Extended Tutorials]
45+
Compare -->|No| Steady[Steady-state LR Inference]
46+
47+
%% Multi-modal branch
48+
Modal -->|Spatial| SMA[Multi-Modal Spatial]
49+
Modal -->|Non-Spatial| SCMulti[Multi-Modal Single-Cell]
50+
51+
%% Metabolite sub-branch
52+
SCMulti --> Metab[Metabolite-mediated CCC]
53+
54+
%% Links (click events)
55+
click Inflow "https://liana-py.readthedocs.io/en/latest/notebooks/inflow_score.html"
56+
click Local "https://liana-py.readthedocs.io/en/latest/notebooks/bivariate.html"
57+
click Global "https://liana-py.readthedocs.io/en/latest/notebooks/bivariate.html"
58+
click MISTy "https://liana-py.readthedocs.io/en/latest/notebooks/misty.html"
59+
click Targeted "https://liana-py.readthedocs.io/en/latest/notebooks/targeted.html"
60+
click MOFA "https://liana-py.readthedocs.io/en/latest/notebooks/mofatalk.html"
61+
click Tensor "https://liana-py.readthedocs.io/en/latest/notebooks/liana_c2c.html"
62+
click TensorExt "https://ccc-protocols.readthedocs.io/en/latest/"
63+
click Steady "https://liana-py.readthedocs.io/en/latest/notebooks/basic_usage.html"
64+
click SMA "https://liana-py.readthedocs.io/en/latest/notebooks/sma.html"
65+
click SCMulti "https://liana-py.readthedocs.io/en/latest/notebooks/sc_multi.html"
66+
click Metab "https://liana-py.readthedocs.io/en/latest/notebooks/sc_multi.html#Metabolite-mediated-CCC"
67+
```
4668

4769
## API
4870
For further information please check LIANA's [API documentation](https://liana-py.readthedocs.io/en/latest/api.html).

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ requires = [ "hatchling" ]
44

55
[project]
66
name = "liana"
7-
version = "1.7.0"
7+
version = "1.7.1"
88
description = "LIANA+: a one-stop-shop framework for cell-cell communication"
99
readme = "README.md"
1010
license = { file = "LICENSE" }

src/liana/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '1.7.0'
1+
__version__ = '1.7.1'
22

33
from liana import method as mt, plotting as pl, resource as rs, multi as mu, utils as ut, testing
44

src/liana/plotting/_circle_plot.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ def _set_adata_color(adata, label, color_dict=None, hex=True):
5454
]
5555
else:
5656
if f"{label}_colors" not in adata.uns:
57-
sc.pl._utils._set_default_colors_for_categorical_obs(adata, label)
57+
# Handle both old (_set_default...) and new (set_default...) scanpy API
58+
_set_colors = getattr(
59+
sc.pl._utils,
60+
'_set_default_colors_for_categorical_obs',
61+
getattr(sc.pl._utils, 'set_default_colors_for_categorical_obs', None)
62+
)
63+
_set_colors(adata, label)
5864

5965
return adata
6066

src/liana/resource/get_metalinks.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,23 @@ def _download_metalinksdb(verbose=True):
1919
"""
2020
requests = _check_if_installed("requests")
2121

22-
METALINKS_URL = "https://figshare.com/ndownloader/files/60861292"
22+
# GitHub Releases URL (CI-friendly, no WAF issues)
23+
METALINKS_URL = "https://github.com/saezlab/liana-py/releases/download/metalinksdb/metalinksdb.db"
2324

24-
# Define the local filename to save the downloaded database
2525
db_file_name = 'metalinksdb.db'
2626
db_path = os.path.join(os.getcwd(), db_file_name)
2727

28-
# Check if the database file already exists and is valid
2928
if os.path.exists(db_path):
30-
# Check if file is empty or corrupted
3129
if os.path.getsize(db_path) == 0:
3230
_logg("Existing database file is empty. Removing and re-downloading...", verbose=verbose)
3331
os.remove(db_path)
3432
else:
3533
return db_path
3634

37-
# Download the database
3835
_logg("Downloading database...", verbose=verbose)
3936
try:
40-
# Figshare requires a browser-like User-Agent to bypass WAF
41-
headers = {
42-
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
43-
}
44-
response = requests.get(METALINKS_URL, headers=headers, stream=True, allow_redirects=True)
45-
response.raise_for_status() # Raise an error for bad status codes
37+
response = requests.get(METALINKS_URL, stream=True, allow_redirects=True)
38+
response.raise_for_status()
4639

4740
with open(db_path, 'wb') as f:
4841
for chunk in response.iter_content(chunk_size=8192):

tests/test_converters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def zi_minmax_cutoff(x):
2727
adata = mdata_to_anndata(mdata, x_mod='adata_x', y_mod='adata_y',
2828
x_transform=zi_minmax_cutoff, y_transform=zi_minmax_cutoff,
2929
verbose=False)
30-
assert_almost_equal(adata.X.sum(), 2120.704, decimal=4)
30+
assert_almost_equal(adata.X.sum(), 2120.704, decimal=3)
3131

3232
# test non-negative
3333
from scanpy.pp import scale

tests/test_spatial_utils.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,37 @@
1111
def test_get_spatial_connectivities():
1212
spatial_neighbors(adata=adata, bandwidth=200, set_diag=True, cutoff=0.2)
1313
np.testing.assert_equal(adata.obsp['spatial_connectivities'].shape, (adata.shape[0], adata.shape[0]))
14-
np.testing.assert_equal(adata.obsp['spatial_connectivities'].sum(), 4550.654013895928)
14+
np.testing.assert_almost_equal(adata.obsp['spatial_connectivities'].sum(), 4550.654013895928, decimal=4)
1515

1616
spatial_neighbors(adata=adata, bandwidth=100, set_diag=True, cutoff=0.1)
17-
np.testing.assert_equal(adata.obsp['spatial_connectivities'].sum(), 1802.332962418902)
17+
np.testing.assert_almost_equal(adata.obsp['spatial_connectivities'].sum(), 1802.332962418902, decimal=4)
1818

1919
conns = spatial_neighbors(adata=adata, bandwidth=100,
2020
kernel='linear', cutoff=0.1,
2121
set_diag=True, inplace=False)
22-
assert conns.sum() == 899.065036633088
22+
np.testing.assert_almost_equal(conns.sum(), 899.065036633088, decimal=4)
2323

2424
conns = spatial_neighbors(adata=adata, bandwidth=100,
2525
kernel='exponential', cutoff=0.1,
2626
set_diag=True, inplace=False)
27-
assert conns.sum() == 1520.8496098963612
27+
np.testing.assert_almost_equal(conns.sum(), 1520.8496098963612, decimal=4)
2828

2929
conns = spatial_neighbors(adata=adata, bandwidth=100, set_diag=True,
3030
kernel='misty_rbf', cutoff=0.1,
3131
inplace=False)
32-
assert conns.sum() == 1254.3161716188595
32+
np.testing.assert_almost_equal(conns.sum(), 1254.3161716188595, decimal=4)
3333

3434
conns = spatial_neighbors(adata=adata, bandwidth=250, set_diag=False,
3535
max_neighbours=100,
3636
kernel='gaussian', cutoff=0.1,
3737
inplace=False)
38-
assert conns.sum() == 6597.05237692107
38+
np.testing.assert_almost_equal(conns.sum(), 6597.05237692107, decimal=4)
3939

4040
conns = spatial_neighbors(adata=adata, bandwidth=250,
4141
set_diag=False, max_neighbours=100,
4242
kernel='gaussian', cutoff=0.1,
4343
inplace=False, standardize=True)
44-
np.testing.assert_almost_equal(conns.sum(), conns.shape[0])
44+
np.testing.assert_almost_equal(conns.sum(), conns.shape[0], decimal=4)
4545

4646
# toy test data
4747
seed = 0

0 commit comments

Comments
 (0)