theislab / cpa

The Compositional Perturbation Autoencoder (CPA) is a deep generative framework to learn effects of perturbations at the single-cell level. CPA performs OOD predictions of unseen combinations of drugs, learns interpretable embeddings, estimates dose-response curves, and provides uncertainty estimates.
BSD 3-Clause "New" or "Revised" License
83 stars 17 forks source link

Errors in running notebook #7

Closed wershofe closed 6 months ago

wershofe commented 2 years ago

Hello When trying to run the notebook I run into a few problems: 1) cpa.CPA.setup_anndata(adata, drug_key='condition', dose_key='dose_val', categorical_covariate_keys=['cell_type'], control_key='control', combinatorial=True, ) TypeError: register_fields() got unexpected keyword arguments {'combinatorial': True} passed without a source_registry.

2) model = cpa.CPA(adata=adata, n_latent=256, loss_ae='gauss', doser_type='logsigm', split_key='split', **ae_hparams, ) TypeError: init() missing 1 required positional argument: 'n_cat_list'

Are you able to provide solutions? Thank you

yanwu2014 commented 2 years ago

I'm also running into this issue, seems like VanillaEncoder and DecoderNormal expect n_cat_list as a parameter with no default value specified?

Naghipourfar commented 2 years ago

Hi, Just published a new version with this issue fixed recently. Tutorials are also updated with the latest API. Sorry for the inconvenience. Please let me know if anything goes wrong.

yanwu2014 commented 2 years ago

Awesome it's working for me now!

tuln128 commented 2 years ago

Hi, Just published a new version with this issue fixed recently. Tutorials are also updated with the latest API. Sorry for the inconvenience. Please let me know if anything goes wrong.

Hello @Naghipourfar, In the updated tutorial notebooks, it seems the trainer_params was assigned with arbitrary values (following is the example from the GSM.ipynb file:

_trainer_params = { 'n_epochs_warmup': 5, 'adversary_lr': 0.0008847032648856746, 'adversary_wd': 9.629190571404551e-07, 'adversary_steps': 3, 'autoencoder_lr': 0.0007208558788012054, 'autoencoder_wd': 1.2280838320404273e-07, 'dosers_lr': 0.0008835011062896268, 'dosers_wd': 5.886005123780177e-06, 'penalty_adversary': 63.44954424334805, 'reg_adversary': 48.73324753854268, 'cycle_coeff': 7.19539336141403, 'step_sizelr': 25, }).

I am wondering how these hyperparameter values were decided (randomly or by optimized tuning)? If the latter is correct, could you please share how to conduct hyperparameter tuning for CPA model?

Thank you very much, and I am looking forward to your feedback. Kind regards,

ArianAmani commented 6 months ago

Hyperparameter tuner added #46 https://github.com/theislab/cpa/#how-to-optmize-cpa-hyperparamters-for-your-data