# Pl.ligrec error in latest version of squidpy

**URL:** <https://discourse.scverse.org/t/pl-ligrec-error-in-latest-version-of-squidpy/1126>\
**Category:** squidpy\
**Created:** [February 13, 2023, 7:16pm UTC](https://discourse.scverse.org/t/pl-ligrec-error-in-latest-version-of-squidpy/1126 "2023-02-13T19:16:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sni](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@Sni](https://discourse.scverse.org/u/Sni)\
**Post date:** [February 13, 2023, 7:16pm UTC](https://discourse.scverse.org/t/pl-ligrec-error-in-latest-version-of-squidpy/1126/1 "2023-02-13T19:16:21Z")

</div>

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 = sq.gr.ligrec(  
adata,  
n\_perms=1000,  
cluster\_key=“Cell\_types”,  
copy=True,  
use\_raw=False,  
interactions\_params={‘resources’: ‘CellPhoneDB’}  
)

sq.pl.ligrec(res, source\_groups=“My\_Cells”, alpha=0.005)

Best,

---

<div class="post-metadata">

**Author:** ![giovp](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/giovp/32/153_2.png) [@giovp](https://discourse.scverse.org/u/giovp)\
**Post date:** [March 1, 2023, 11:00am UTC](https://discourse.scverse.org/t/pl-ligrec-error-in-latest-version-of-squidpy/1126/2 "2023-03-01T11:00:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Sni](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@Sni](https://discourse.scverse.org/u/Sni)\
**Post date:** [March 9, 2023, 4:56am UTC](https://discourse.scverse.org/t/pl-ligrec-error-in-latest-version-of-squidpy/1126/3 "2023-03-09T04:56:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cdpolt](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/cdpolt/32/628_2.png) [@cdpolt](https://discourse.scverse.org/u/cdpolt)\
**Post date:** [April 20, 2023, 10:04pm UTC](https://discourse.scverse.org/t/pl-ligrec-error-in-latest-version-of-squidpy/1126/4 "2023-04-20T22:04:57Z")

</div>

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()))

---

<div class="post-metadata">

**Author:** ![HelloWorldLTY](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/helloworldlty/32/749_2.png) [@HelloWorldLTY](https://discourse.scverse.org/u/HelloWorldLTY)\
**Post date:** [September 27, 2023, 1:54am UTC](https://discourse.scverse.org/t/pl-ligrec-error-in-latest-version-of-squidpy/1126/5 "2023-09-27T01:54:14Z")

</div>

Hi, I found one solution here:

```auto
    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.
