scverse / scanpy

Single-cell analysis in Python. Scales to >1M cells.
https://scanpy.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.88k stars 594 forks source link

`regress_out` does not capture PerfectSeparation with statsmodels >= 0.14 #3260

Open jeskowagner opened 4 days ago

jeskowagner commented 4 days ago

Please make sure these conditions are met

What happened?

Hi, since statsmodels 0.14, perfect separation no longer raises an error but a warning (see function doc here). Because scanpy currently only catches the now-outdated error (instead of catch the warning), users may see many warnings from regress_out when no perfect separation exists (see usage in scanpy here). It seems to follow on the heels of this issue in statsmodels. I propose to implement that the warning is caught just as the errors were being caught. Cheers, Jesko

Minimal code sample

N/A

Error output

.../statsmodels/genmod/generalized_linear_model.py:1257: PerfectSeparationWarning: Perfect separation or prediction detected, parameter may not be identified
  warnings.warn(msg, category=PerfectSeparationWarning)

Versions

``` anndata 0.10.4 scanpy 1.9.6 statsmodels 0.14.0 ```