Skip to content

Commit

Permalink
Fix Lisi return type and docstring (#182)
Browse files Browse the repository at this point in the history
* Update _lisi.py

* Update _lisi.py

* Update CHANGELOG.md

* Update CHANGELOG.md
  • Loading branch information
adamgayoso authored Nov 4, 2024
1 parent e31aa1c commit 2ffccb4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning][].
- Fix neighbors connectivities in test to use new scanpy fn {pr}`170`.
- Fix Kmeans test {pr}`172`.
- Fix deprecation and future warnings {pr}`171`.
- Fix lisi return type and docstring {pr}`182`.

## 0.5.1 (2024-02-23)

Expand Down
8 changes: 4 additions & 4 deletions src/scib_metrics/metrics/_lisi.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def lisi_knn(X: NeighborsResults, labels: np.ndarray, perplexity: float = None)
return 1 / simpson


def ilisi_knn(X: NeighborsResults, batches: np.ndarray, perplexity: float = None, scale: bool = True) -> np.ndarray:
def ilisi_knn(X: NeighborsResults, batches: np.ndarray, perplexity: float = None, scale: bool = True) -> float:
"""Compute the integration local inverse simpson index (iLISI) for each cell :cite:p:`korsunsky2019harmony`.
Returns a scaled version of the iLISI score for each cell, by default :cite:p:`luecken2022benchmarking`.
Expand All @@ -60,7 +60,7 @@ def ilisi_knn(X: NeighborsResults, batches: np.ndarray, perplexity: float = None
Returns
-------
ilisi
Array of shape (n_cells,) with the iLISI score for each cell.
iLISI score.
"""
batches = np.asarray(pd.Categorical(batches).codes)
lisi = lisi_knn(X, batches, perplexity=perplexity)
Expand All @@ -71,7 +71,7 @@ def ilisi_knn(X: NeighborsResults, batches: np.ndarray, perplexity: float = None
return ilisi


def clisi_knn(X: NeighborsResults, labels: np.ndarray, perplexity: float = None, scale: bool = True) -> np.ndarray:
def clisi_knn(X: NeighborsResults, labels: np.ndarray, perplexity: float = None, scale: bool = True) -> float:
"""Compute the cell-type local inverse simpson index (cLISI) for each cell :cite:p:`korsunsky2019harmony`.
Returns a scaled version of the cLISI score for each cell, by default :cite:p:`luecken2022benchmarking`.
Expand All @@ -92,7 +92,7 @@ def clisi_knn(X: NeighborsResults, labels: np.ndarray, perplexity: float = None,
Returns
-------
clisi
Array of shape (n_cells,) with the cLISI score for each cell.
cLISI score.
"""
labels = np.asarray(pd.Categorical(labels).codes)
lisi = lisi_knn(X, labels, perplexity=perplexity)
Expand Down

0 comments on commit 2ffccb4

Please sign in to comment.