Skip to content

Commit

Permalink
comment cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Gautam8387 committed Oct 29, 2024
1 parent c90134c commit 9fccff9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
3 changes: 0 additions & 3 deletions scarf/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

# LISI - The Local Inverse Simpson Index
def compute_lisi(
# X: np.array,
distances: zarrArrayType,
indices: zarrArrayType,
metadata: pd.DataFrame,
Expand Down Expand Up @@ -56,7 +55,6 @@ def compute_lisi(
# Don't count yourself
indices = indices[:, 1:]
distances = distances[:, 1:]
# Save the result
lisi_df = np.zeros((n_cells, n_labels))
for i, label in enumerate(label_colnames):
logger.info(f"Computing LISI for {label}")
Expand All @@ -66,7 +64,6 @@ def compute_lisi(
distances.T, indices.T, labels, n_categories, perplexity
)
lisi_df[:, i] = 1 / simpson
# lisi_df = lisi_df.flatten()
return lisi_df


Expand Down
20 changes: 16 additions & 4 deletions scarf/tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@


def test_metric_lisi(datastore, make_graph):
# datastore.auto_filter_cells(show_qc_plots=False)
# datastore.mark_hvgs(top_n=100, show_plot=False)
# datastore.make_graph(feat_key="hvgs")
lables = np.random.randint(0, 2, datastore.cells.N)
datastore.cells.insert(
column_name="samples_id",
Expand All @@ -21,7 +18,7 @@ def test_metric_silhouette(datastore, make_graph, leiden_clustering):
_ = datastore.metric_silhouette()


def test_metric_integration(datastore, make_graph, leiden_clustering):
def test_metric_integration_ari(datastore, make_graph, leiden_clustering):
lables1 = np.random.randint(0, 2, datastore.cells.N)
lables2 = np.random.randint(0, 2, datastore.cells.N)
datastore.cells.insert(
Expand All @@ -35,3 +32,18 @@ def test_metric_integration(datastore, make_graph, leiden_clustering):
overwrite=True,
)
_ = datastore.metric_integration(batch_labels=["lables1", "lables2"], metric="ari")

def test_metric_integration_nmi(datastore, make_graph, leiden_clustering):
lables1 = np.random.randint(0, 2, datastore.cells.N)
lables2 = np.random.randint(0, 2, datastore.cells.N)
datastore.cells.insert(
column_name="lables1",
values=lables1,
overwrite=True,
)
datastore.cells.insert(
column_name="lables2",
values=lables2,
overwrite=True,
)
_ = datastore.metric_integration(batch_labels=["lables1", "lables2"], metric="nmi")

0 comments on commit 9fccff9

Please sign in to comment.