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

significance of same dots changes based on plotted clusters in sq.pl.ligrec #945

Open
t-a-m-i opened this issue Jan 24, 2025 · 0 comments
Open

Comments

@t-a-m-i
Copy link

t-a-m-i commented Jan 24, 2025

Description

sq.gr.ligrec was used to calculate ligand-receptor statistics for the whole input dataset. However, when plotting the results, the dots for the same interactions differ depending on the clusters selected for plotting. If I only plot clusters 1 and 2 as source and clusters 1, 2, and 3 as target groups, the same dots shown in the graph as being significant (tori) might suddenly become non-significant when I choose to plot clusters 1 and 2 as source and 1 and 2 as target groups.
To my understanding the pvalues shouldn't get modified based on result subsetting. Additionally, when I subset the result["pvalues"] for my own data to the remaining source and target molecules that are being plotted, all should be shown to be significant, but are not in the plot.

...

Minimal reproducible example

adata = sq.datasets.seqfish()
sc.pp.normalize_total(adata) 
sc.pp.log1p(adata)

res_test = sq.gr.ligrec(
    adata,
    n_perms=100,
    threshold=0,
    copy=True,
    cluster_key="celltype_mapped_refined",
    use_raw=False
)

sq.pl.ligrec(
    res_test,
    source_groups=["Lateral plate mesoderm","Intermediate mesoderm"],
    target_groups=["Lateral plate mesoderm","Intermediate mesoderm",'Allantois'],
    means_range=(0.5, np.inf),
    alpha=0.005,
    swap_axes=True,
)

# vs. 

sq.pl.ligrec(
    res_test,
    source_groups=["Lateral plate mesoderm","Intermediate mesoderm"],
    target_groups=["Lateral plate mesoderm","Intermediate mesoderm"],
    means_range=(0.5, np.inf),
    alpha=0.005,
    swap_axes=True,
)

# in the second plot for example the pair "WNT5A" and "FZD2" should all be significant like seen here, but is not in the plot
# Target clusters to keep
targets = ["Lateral plate mesoderm","Intermediate mesoderm"]

# Filter the columns
filtered_test = res_test["pvalues"].loc[:, 
    res_test["pvalues"].columns.get_level_values('cluster_1').isin(targets) &
    res_test["pvalues"].columns.get_level_values('cluster_2').isin(targets)
]
filtered_test = filtered_test[(filtered_test.index.get_level_values(0) == "WNT5A") & 
                (filtered_test.index.get_level_values(1) == "FZD2")]

filtered_test

Version

python=3.10.16, squidpy=1.6.1

...

@t-a-m-i t-a-m-i changed the title differing plotting results based on plotted clusters in sq.pl.ligrec significance of same dots changes based on plotted clusters in sq.pl.ligrec Jan 24, 2025
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

1 participant