theislab / chemCPA

Code for "Predicting Cellular Responses to Novel Drug Perturbations at a Single-Cell Resolution", NeurIPS 2022.
https://arxiv.org/abs/2204.13545
MIT License
88 stars 23 forks source link

Add class imbalance to BCE loss. #26

Closed siboehm closed 2 years ago

siboehm commented 2 years ago

Class imbalance should be incorporated into the BCE loss. Example on Trapnell:

> adata.obs["condition"].value_counts()[:10]
control         6464
GSK-LSD1        1868
BRD4770         1868
Baricitinib     1862
Entacapone      1853
RG108           1852
WP1066          1851
Curcumin        1850
Capecitabine    1849
Mesna           1847
Name: condition, dtype: int64
> adata.obs["condition"].value_counts()[-10:]
Rigosertib      984
Luminespib      980
Tozasertib      975
Mocetinostat    949
Alvespimycin    930
AT9283          910
Patupilone      757
Flavopiridol    693
Epothilone      583
YM155           394
Name: condition, dtype: int64

This is not super important, as the dataset is not actually very imbalanced. But it will make the adversarial loss more meaningful.