Skip to content

Commit d803136

Browse files
rcannoodghar1821LuLeom
authored
Return NaN instead of crashing when every EMD stratum is too small (#131)
* return nan instead of crashing when every emd stratum is too small * Guard the pd.concat() calls in both the horizontal and vertical path * Warn as soon as one cell type is missing from a split, not two * Fix the newline in that warning * update changelog * simplify changes * Update CHANGELOG.md --------- Co-authored-by: Givanna Putri <givanna.h@gmail.com> Co-authored-by: Luca Leomazzi <76624347+LuLeom@users.noreply.github.com>
1 parent ae68ce3 commit d803136

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,6 @@
252252

253253
* Fix bug in `average_batch_r2` where the R2 was computed on all cell types of a donor at once
254254
instead of on each cell type separately (PR #127).
255+
256+
257+
* Fix check cell_type_in_both to > 0 (instead of 1) and some spelling mistakes in print.

src/metrics/emd/helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,11 @@ def calculate_horizontal_emd(
224224
i_split1_donor.obs["cell_type"].unique(),
225225
i_split2_donor.obs["cell_type"].unique(),
226226
)
227-
if len(cell_type_not_in_both) > 1:
227+
if len(cell_type_not_in_both) > 0:
228228
print(
229229
f"In donor {donor}: some cell types are in split 1"
230230
f" but not in split 2.\n"
231-
f"Cell types missing: {''.join(cell_type_not_in_both)}]n"
231+
f"Cell types missing: {', '.join(cell_type_not_in_both)}\n"
232232
f"Computing cell type EMD using just cell types common in both."
233233
)
234234

0 commit comments

Comments
 (0)