We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 48b09db commit a96098cCopy full SHA for a96098c
1 file changed
hvantk/ptm/test.py
@@ -272,7 +272,14 @@ def _skipped(note: str, bin_levels=None) -> BinnedLMMResult:
272
dfx["expr_bin"] = pd.Categorical(assigned, categories=ordered, ordered=True)
273
274
# Sparsity gate: every (expr_bin, is_ptm) cell must have >= min_cell_n.
275
- bc = dfx.groupby(["expr_bin", "is_ptm"], observed=False).size().unstack(fill_value=0)
+ # Reindex columns to [0, 1] so strata missing an entire PTM class still
276
+ # fail the gate instead of squeezing through on a degenerate design.
277
+ bc = (
278
+ dfx.groupby(["expr_bin", "is_ptm"], observed=False)
279
+ .size()
280
+ .unstack(fill_value=0)
281
+ .reindex(columns=[0, 1], fill_value=0)
282
+ )
283
if (bc < min_cell_n).any().any():
284
return _skipped("skipped: sparse bins", bin_levels=ordered)
285
0 commit comments