Pl.ligrec error in latest version of squidpy

Hi all,

I was using v1.0.0 before and I have recently updated squidpy to v1.2.3. Unfortunately ligrec plotting function doesn’t work anymore and I get an error message:

(f"Expected all groups to have the same number of interacting clusters, found {size}.")

AttributeError: ‘int’ object has no attribute ‘values’

I have v1.0.0 still installed in another conda env and code works perfectly fine:
res =
interactions_params={‘resources’: ‘CellPhoneDB’}
), source_groups=“My_Cells”, alpha=0.005)


1 Like

hi @Sni could you please install squidpy from main? we’ll make a new release soon!

Thanks, forgot to answer here, installing from main helped with this issue

hey, I reinstalled from main and i am still getting this error - any other thoughts on the cause? break is in line 296 size = np.unique(list(size.values()))

Hi, I found one solution here:

    for cls, size in (pvals.groupby(level=0, axis=1)).size().to_dict().items():
        # print(size)
        size = np.unique(list((pvals.groupby(level=0, axis=1)).size().to_dict().values()))
        if len(size) != 1:
            raise ValueError(f"Expected all groups to have the same number of interacting clusters, found `{size}`.")
        size = size[0]
        label_ranges[cls] = (start, start + size - 1)
        start += size
    label_ranges = {k: label_ranges[k] for k in sorted(label_ranges.keys())}

We can replace the size based on that dict. The plot looks good to me. I can create a pull request later.

It seems that the version in github already updated.