Closed rgranit closed 2 years ago
Hi @rgranit ,
currently, there isn't any convenient way of directly specifying a subset of interactions to plot (source_groups
and target_groups
are the closest, which control the source/target clusters, respectively).
You could try something along the lines:
import squidpy as sq
adata = sq.datasets.visium_fluo_adata()
sq.gr.ligrec(adata, "leiden")
ligrec = adata.uns['leiden_ligrec']
mask = ligrec['means'].index[:10]
ligrec_to_plot = {k: df.loc[mask] for k, df in ligrec.items()}
sq.pl.ligrec(ligrec_to_plot)
since sq.pl.ligrec
also accepts the output of sq.gr.ligrec
(a dictionary of dataframes).
Thanks @michalk8 it works well, any way to also lifter the source_groups
and target_groups
in the process? I could not really figure out how to accomplish this using the dict of DFs
Thanks @michalk8 it works well, any way to also lifter the source_groups and target_groups in the process? I could not really figure out how to accomplish this using the dict of DFs
You can run e.g. sq.pl.ligrec(ligrec_to_plot, source_groups=["0"], target_groups=["1"])
from the example above. Internally, it's done by running
df = ... # pandas.DataFrame
source_groups = ["0"]
target_groups = ["1"]
subset = df.loc[:, (source_groups, target_groups)]
Amazing, thanks again @michalk8 !
Does the
sq.pl.ligrec
function support plotting just some of the interactions?Sometimes there are many results and I would like to make a figure with just selected interactions.