diff --git a/CHANGELOG.md b/CHANGELOG.md index 31b8988f..06fa5e2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -248,3 +248,7 @@ as scalars instead of lists, as required by `file_score.yaml` (PR #130). * Clean up stale mock parameters and dead code (PR #133). + + +* Fix bug in `average_batch_r2` where the R2 was computed on all cell types of a donor at once + instead of on each cell type separately (PR #127). diff --git a/src/metrics/average_batch_r2/script.py b/src/metrics/average_batch_r2/script.py index 6788bf69..a0d82436 100644 --- a/src/metrics/average_batch_r2/script.py +++ b/src/metrics/average_batch_r2/script.py @@ -60,13 +60,13 @@ s2_view_ct = s2_view[s2_view.obs["cell_type"] == ct] if ( s1_view_ct.shape[0] < 20 or s2_view_ct.shape[0] < 20 - ): # Skip Rˆ2 calculation if there are less than 10 cells + ): # Skip Rˆ2 calculation if there are less than 20 cells print( f"Warning: Rˆ2 not computed for donor {donor} cell type {ct}. Too few cells were present: {s1_view_ct.shape[0]} for split 1 and {s2_view_ct.shape[0]} for split 2" ) continue - r2_list, marker_list = batch_r2(s1_view, s2_view) + r2_list, marker_list = batch_r2(s1_view_ct, s2_view_ct) marker_list = [ct + "_" + donor + "_" + x for x in marker_list] r2_info = [*r2_info, *marker_list]