-
Notifications
You must be signed in to change notification settings - Fork 110
Description
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_testVersion
python=3.10.16, squidpy=1.6.1
...