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

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

Open
realzehuali opened this issue Sep 17, 2023 · 10 comments
Open

Comments

@realzehuali
Copy link

Following the same jupyter notebook (tutorial_visium_hne.ipynb) with the same tutorial data but got the following error:

ValueError Traceback (most recent call last)
Cell In[10], line 6
1 sq.gr.ligrec(
2 adata,
3 n_perms=100,
4 cluster_key="cluster",
5 )
----> 6 sq.pl.ligrec(
7 adata,
8 cluster_key="cluster",
9 source_groups="Hippocampus",
10 target_groups=["Pyramidal_layer", "Pyramidal_layer_dentate_gyrus"],
11 means_range=(3, np.inf),
12 alpha=1e-4,
13 swap_axes=True,
14 )

File \squidpy\lib\site-packages\squidpy\pl_ligrec.py:295, in ligrec(adata, cluster_key, source_groups, target_groups, means_range, pvalue_threshold, remove_empty_interactions, remove_nonsig_interactions, dendrogram, alpha, swap_axes, title, figsize, dpi, save, **kwargs)
292 pvals = pvals[pvals <= pvalue_threshold]
294 if remove_empty_interactions:
--> 295 pvals, means = filter_values(pvals, means, mask=
(pd.isnull(means) | pd.isnull(pvals)), kind="NaN")
296 if remove_nonsig_interactions and alpha is not None:
297 pvals, means = filter_values(pvals, means, mask=pvals <= alpha, kind="non-significant")

File ~\squidpy\lib\site-packages\squidpy\pl_ligrec.py:205, in ligrec..filter_values(pvals, means, mask, kind)
202 means = means.loc[mask_rows]
204 if pvals.empty:
--> 205 raise ValueError(f"After removing rows with only {kind} interactions, none remain.")
207 mask_cols = mask.any(axis=0)
208 pvals = pvals.loc[:, mask_cols]

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

Thank you for any help!

@Hagibaer
Copy link

Hagibaer commented Oct 9, 2023

+1

1 similar comment
@caiquanyou
Copy link

+1

@Silaschuwen
Copy link

+1 yes the same error :(

@giovp
Copy link
Member

giovp commented Apr 26, 2024

hi, which version of squidpy are you using?

@Silaschuwen
Copy link

hi, which version of squidpy are you using?

1.4.1

@amonell
Copy link

amonell commented Apr 30, 2024

I got the same error using squidpy on my own data. It happened when I was using raw counts. After log-normalizing, the function worked.

sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)

@giovp
Copy link
Member

giovp commented Apr 30, 2024

@Silaschuwen have you used normalized data?

@Silaschuwen
Copy link

Silaschuwen commented Apr 30, 2024

@Silaschuwen have you used normalized data?

i tried normalized data but it doesn't look like it's working out very well. here is my code (the same as the notebooks/examples)

@amonell may i ask you what is your version of squidpy?

import squidpy as sq

adata = sq.datasets.seqfish()

sc.pp.normalize_total(adata, target_sum=1e4)

sc.pp.log1p(adata)

res = sq.gr.ligrec(
    adata,
    n_perms=1000,
    cluster_key="celltype_mapped_refined",
    copy=True,
    use_raw=True,
    transmitter_params={"categories": "ligand"},
    receiver_params={"categories": "receptor"},
)

sq.pl.ligrec(res, source_groups="Erythroid", alpha=0.005)

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

@amonell
Copy link

amonell commented Apr 30, 2024

@Silaschuwen You have "use_raw" set to true which may be using un-normalized counts. I would try setting it to False.
Maybe the default threshold is too high, you can try setting "threshold = 0".

I am using Squidpy version 1.3.1 in python 3.10

@Silaschuwen
Copy link

@Silaschuwen You have "use_raw" set to true which may be using un-normalized counts. I would try setting it to False. Maybe the default threshold is too high, you can try setting "threshold = 0".

I am using Squidpy version 1.3.1 in python 3.10

thanks so much! everything works smoothly~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants