Skip to content

Commit

Permalink
Merge pull request #140 from PixelgenTechnologies/fix/jaccard-index-s…
Browse files Browse the repository at this point in the history
…etting-negative-marker-values-to-true

explicitly check marker value expressions to be greater than zero bef…
  • Loading branch information
ptajvar committed May 17, 2024
2 parents 28e0e10 + 9a8a42b commit 5fb97ff
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/pixelator/analysis/colocalization/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def jaccard(df: RegionByCountsDataFrame) -> MarkerColocalizationResults:
:return: MarkerColocalizationResults with Jaccard indexes
"""
jaccard_matrix = pd.DataFrame(
1 - pairwise_distances(df.T.to_numpy(dtype=bool), metric="jaccard"),
1 - pairwise_distances((df.T > 0).to_numpy(dtype=bool), metric="jaccard"),
index=df.columns.copy(),
columns=df.columns.copy(),
)
Expand Down
4 changes: 2 additions & 2 deletions tests/analysis/colocalization/test_colocalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ def test_colocalization_scores_ratediff(
"pearson_z": np.nan,
"pearson_p_value": np.nan,
"pearson_p_value_adjusted": np.nan,
"jaccard": 1.0,
"jaccard_mean": 1.0,
"jaccard": 0.0,
"jaccard_mean": 0.0,
"jaccard_stdev": 0.0,
"jaccard_z": np.nan,
"jaccard_p_value": np.nan,
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis/colocalization/test_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_pearson_no_variation():

def test_jaccard():
df = pd.DataFrame(
[[0, 0, 3, 4], [2, 3, 0, 6], [0, 5, 3, 8]],
[[0, -1, 3, 4], [2, 3, 0, 6], [0, 5, 3, 8]],
columns=["marker1", "marker2", "marker3", "marker4"],
)
results = jaccard(df)
Expand Down

0 comments on commit 5fb97ff

Please sign in to comment.