scverse / squidpy

Spatial Single Cell Analysis in Python
https://squidpy.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
428 stars 79 forks source link

After removing rows with only NaN interactions, none remain. #840

Open asmlgkj opened 3 months ago

asmlgkj commented 3 months ago

Description

...

Minimal reproducible example

import numpy as np
import os
import scanpy as sc
import squidpy as sq

sc.logging.print_header()
print(f"squidpy=={sq.__version__}")
adata = sc.read_h5ad('seqfish.h5ad')

sq.pl.spatial_scatter(
    adata, color="celltype_mapped_refined", shape=None, figsize=(10, 10)
)

sq.gr.spatial_neighbors(adata, coord_type="generic")
sq.gr.nhood_enrichment(adata, cluster_key="celltype_mapped_refined")
sq.pl.nhood_enrichment(adata, cluster_key="celltype_mapped_refined", method="ward")

sq.gr.co_occurrence(adata, cluster_key="celltype_mapped_refined")
sq.pl.co_occurrence(
    adata,
    cluster_key="celltype_mapped_refined",
    clusters="Lateral plate mesoderm",
    figsize=(10, 5),
)

sq.gr.ligrec(
    adata,
    n_perms=100,
    cluster_key="celltype_mapped_refined",
)
sq.pl.ligrec(
    adata,
    cluster_key="celltype_mapped_refined",
    source_groups="Lateral plate mesoderm",
    target_groups=["Intermediate mesoderm", "Allantois"],
    means_range=(0.3, np.inf),
    alpha=1e-4,
    swap_axes=True,
)

Traceback

```pytb ... ```

Version

scanpy==1.9.5 anndata==0.9.2 umap==0.5.6 numpy==1.24.3 scipy==1.11.3 pandas==2.2.2 scikit-learn==1.3.0 statsmodels==0.14.1 igraph==0.11.5 pynndescent==0.5.12 squidpy==1.5.0 ...

asmlgkj commented 3 months ago

it seems change the code as following sq.gr.ligrec(     adata,     n_perms=100,     cluster_key="celltype_mapped_refined",     use_raw=False,     threshold=0 ) sq.pl.ligrec(     adata,     cluster_key="celltype_mapped_refined",     source_groups="Lateral plate mesoderm",     target_groups=["Intermediate mesoderm", "Allantois"],     means_range=(0.3, np.inf),     alpha=1e-4,     swap_axes=True, ) but I do not know wthether it is right to set like this, because the tutorial does not do like this

LLehner commented 3 months ago

Hi @asmlgkj At what point does the problem appear?

asmlgkj commented 3 months ago

thanks a lot. @LLehner

when I run this code sq.gr.ligrec( adata, n_perms=100, cluster_key="celltype_mapped_refined",

)

giovp commented 2 months ago

hi @asmlgkj are you using log normalized data?

MEFarhadieh commented 1 month ago

Dear @asmlgkj Thank you for providing edited parameters of sq.gr.ligrec function. I had same problem in both seqFISH and Slide-seq tutorials but when I applied use_raw=False and threshold=0 the problem is solved.

TTTPOB commented 4 weeks ago

https://github.com/scverse/squidpy/issues/871#issuecomment-2326748408 same here