Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ligand-receptor plot always report Error #871

Open
ryrl970311 opened this issue Aug 9, 2024 · 5 comments
Open

Ligand-receptor plot always report Error #871

ryrl970311 opened this issue Aug 9, 2024 · 5 comments
Assignees
Labels
bug 🐛 Something isn't working

Comments

@ryrl970311
Copy link

Description

When I use sq.pl.ligrec after sq.gr.ligrec( adata, n_perms=100, cluster_key="cluster", clusters=["Polydendrocytes", "Oligodendrocytes"], ) , it always report an error 'ValueError: After removing rows with only NaN interactions, none remain'. Is thes normal? I use the data fro tutorials adata = sq.datasets.seqfish() or adata = sq.datasets.slideseqv2(), which do not raise error in examples. How should I solve it? Thanks.

Minimal reproducible example

adata = sq.datasets.seqfish() or adata = sq.datasets.slideseqv2()
...

sq.gr.ligrec(
adata,
n_perms=100,
cluster_key="cluster",
clusters=["Polydendrocytes", "Oligodendrocytes"],
)

sq.pl.ligrec(
adata,
cluster_key="cluster",
source_groups="Oligodendrocytes",
target_groups=["Polydendrocytes"],
pvalue_threshold=0.05,
swap_axes=True,
)

Traceback

ValueError Traceback (most recent call last)
Cell In[56], line 1
----> 1 sq.pl.ligrec(
2 adata,
3 cluster_key="cluster",
4 source_groups="Oligodendrocytes",
5 target_groups=["Polydendrocytes"],
6 pvalue_threshold=0.05,
7 swap_axes=True,
8 )

287 pvals = pvals[pvals <= pvalue_threshold]
289 if remove_empty_interactions:

--> 290 pvals, means = filter_values(pvals, means, mask=~(pd.isnull(means) | pd.isnull(pvals)), kind="NaN")
291 if remove_nonsig_interactions and alpha is not None:
292 pvals, means = filter_values(pvals, means, mask=pvals <= alpha, kind="non-significant")

197 means = means.loc[mask_rows]
199 if pvals.empty:

--> 200 raise ValueError(f"After removing rows with only {kind} interactions, none remain.")
202 mask_cols = mask.any(axis=0)
203 pvals = pvals.loc[:, mask_cols]

ValueError: After removing rows with only NaN interactions, none remain.

Version

python 3.12.4
squidpy==1.6.0

...

@giovp
Copy link
Member

giovp commented Aug 19, 2024

hi @ryrl970311 did you normalize and log1p the data before using this function?

@noob000007
Copy link

I also encountered this error. In this new version, even the official example tutorial encounters the same issue.

@TTTPOB
Copy link

TTTPOB commented Sep 3, 2024

update:
tried 1.5.0 from conda-forge and 1.6.1 self-built conda package (from pypi source) got the same error

same here, my code

# hidden code for read in the data
# then preprocess using standard scanpy pipeline
# standard scanpy pipeline for slice1
sc.pp.filter_cells(slice1, min_genes=200)
sc.pp.filter_genes(slice1, min_cells=3)
slice1.raw = slice1
slice1.layers["counts"] = slice1.X.copy()
sc.pp.normalize_total(slice1)
sc.pp.log1p(slice1)
sc.pp.highly_variable_genes(slice1, n_top_genes=2000)
sc.tl.pca(slice1)
sc.pp.neighbors(slice1)
sc.tl.umap(slice1)
sc.tl.leiden(slice1)

# then spatial scatterplot
# see it on the spatial image
sq.pl.spatial_scatter(
    slice1,
    img_res_key="lowres",
    color=["leiden"],
    size=12000,
)

image

# then do the ligand receptor analysis
sq.gr.ligrec(
    slice1,
    n_perms=100,
    cluster_key="leiden",
    use_raw=True,
)
# above runs normally,

# plot fails
sq.pl.ligrec(
    slice1,
    cluster_key="leiden",
    source_groups=["4"],
    target_groups=["1", "2"],
    means_range=(0.1, np.inf),
    alpha=1e-4,
    swap_axes=True,
)

traceback
image

@TTTPOB
Copy link

TTTPOB commented Sep 3, 2024

update, running the code from the tutorial would fail as well (the dataset is from this tutorial as well)
https://squidpy.readthedocs.io/en/stable/notebooks/tutorials/tutorial_visium_hne.html#import-packages-data

sq.gr.ligrec(
    adata,
    n_perms=100,
    cluster_key="cluster",
)
sq.pl.ligrec(
    adata,
    cluster_key="cluster",
    source_groups="Hippocampus",
    target_groups=["Pyramidal_layer", "Pyramidal_layer_dentate_gyrus"],
    means_range=(3, np.inf),
    alpha=1e-4,
    swap_axes=True,
)

@giovp giovp added the bug 🐛 Something isn't working label Sep 16, 2024
@wxicu
Copy link

wxicu commented Oct 28, 2024

Hello, I’m encountering the same issue. Have there been any updates or resolutions so far?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants