# Reproducing scib-metrics usage after API change

**URL:** <https://discourse.scverse.org/t/reproducing-scib-metrics-usage-after-api-change/2274>\
**Category:** Help\
**Tags:** integration\
**Created:** [May 14, 2024, 8:09am UTC](https://discourse.scverse.org/t/reproducing-scib-metrics-usage-after-api-change/2274 "2024-05-14T08:09:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yugeji](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/yugeji/32/175_2.png) [@yugeji](https://discourse.scverse.org/u/yugeji)\
**Post date:** [May 14, 2024, 8:09am UTC](https://discourse.scverse.org/t/reproducing-scib-metrics-usage-after-api-change/2274/1 "2024-05-14T08:09:01Z")

</div>

Hiya,

I used to be able to run

```auto
from scib_metrics import lisi_knn
labels = adata.obs.perturbation_name.values
labels = np.asarray(pd.Categorical(labels).codes)
adata.obs['lisi'] = lisi_knn(adata.obsp['distances'], labels, perplexity=None)

```

However, the input to `lisi_knn` has since changed to a [NeighborsResult](https://scib-metrics.readthedocs.io/en/stable/generated/scib_metrics.nearest_neighbors.NeighborsResults.html#scib_metrics.nearest_neighbors.NeighborsResults) object, which I cannot figure out how to generate. Could an example please be provided so that I can continue using these metrics?

Thanks,  
Yuge

---

<div class="post-metadata">

**Author:** ![yugeji](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/yugeji/32/175_2.png) [@yugeji](https://discourse.scverse.org/u/yugeji)\
**Post date:** [June 3, 2024, 9:50am UTC](https://discourse.scverse.org/t/reproducing-scib-metrics-usage-after-api-change/2274/2 "2024-06-03T09:50:11Z")

</div>

Bumping this! Would really appreciate a note.

---

<div class="post-metadata">

**Author:** ![Justin\_Hong](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/justin_hong/32/85_2.png) [@Justin\_Hong](https://discourse.scverse.org/u/Justin_Hong)\
**Post date:** [June 3, 2024, 7:52pm UTC](https://discourse.scverse.org/t/reproducing-scib-metrics-usage-after-api-change/2274/3 "2024-06-03T19:52:29Z")

</div>

Haven’t touched scib-metrics in a while, but it looks like it’s meant to directly take output nearest neighbor modules like that of sklearn.neighbors.NearestNeighbors ([scib-metrics/tests/utils/data.py at v0.5.1 · YosefLab/scib-metrics · GitHub](https://github.com/YosefLab/scib-metrics/blob/v0.5.1/tests/utils/data.py#L18-L20)). As long as you can massage the adata.obsp[“distances”] in the same form along with the appropriate indices, it should work.

Usage example: [scib-metrics/tests/test\_metrics.py at v0.5.1 · YosefLab/scib-metrics · GitHub](https://github.com/YosefLab/scib-metrics/blob/v0.5.1/tests/test_metrics.py#L74-L77)
