scverse / squidpy_notebooks

Tutorials for Squidpy
https://squidpy.readthedocs.io/en/stable/
MIT License
26 stars 17 forks source link

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

Open realzehuali opened 10 months ago

realzehuali commented 10 months ago

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 commented 9 months ago

+1

caiquanyou commented 3 months ago

+1

Silaschuwen commented 3 months ago

+1 yes the same error :(

giovp commented 3 months ago

hi, which version of squidpy are you using?

Silaschuwen commented 3 months ago

hi, which version of squidpy are you using?

1.4.1

amonell commented 2 months ago

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 commented 2 months ago

@Silaschuwen have you used normalized data?

Silaschuwen commented 2 months ago

@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 commented 2 months ago

@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 commented 2 months ago

@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~