BayraktarLab / cell2location

Comprehensive mapping of tissue cell architecture via integrated single cell and spatial transcriptomics (cell2location model)
https://cell2location.readthedocs.io/en/latest/
Apache License 2.0
324 stars 58 forks source link

Model training failed #156

Closed xiaoxiaozhihuishu closed 2 years ago

xiaoxiaozhihuishu commented 2 years ago

I am trying to run the new tutorial of cell2location for Mapping human lymph node cell types to 10X Visium. When I try training the regression model and Iam encountering this problem:

from cell2location.models import RegressionModel mod = RegressionModel(adata_ref) mod.train(max_epochs=250, batch_size=2500, train_size=1, lr=0.002, use_gpu=True)

Traceback (most recent call last): File "F:\anaconda3\envs\cell2\lib\code.py", line 90, in runcode exec(code, self.locals) File "", line 1, in File "F:\anaconda3\envs\cell2\lib\site-packages\cell2location-0.8a0-py3.9.egg\cell2location\models\reference_reference_model.py", line 157, in train File "F:\anaconda3\envs\cell2\lib\site-packages\scvi\model\base_pyromixin.py", line 138, in train runner = TrainRunner( File "F:\anaconda3\envs\cell2\lib\site-packages\scvi\train_trainrunner.py", line 66, in init self.trainer = Trainer(max_epochs=max_epochs, gpus=gpus, trainer_kwargs) File "F:\anaconda3\envs\cell2\lib\site-packages\scvi\train_trainer.py", line 139, in init super().init( File "F:\anaconda3\envs\cell2\lib\site-packages\pytorch_lightning\utilities\argparse.py", line 339, in insert_env_defaults return fn(self, kwargs) File "F:\anaconda3\envs\cell2\lib\site-packages\pytorch_lightning\trainer\trainer.py", line 541, in init self._callback_connector.on_trainer_init( File "F:\anaconda3\envs\cell2\lib\site-packages\pytorch_lightning\trainer\connectors\callback_connector.py", line 103, in on_trainer_init self._configure_progress_bar(progress_bar_refresh_rate, process_position, enable_progress_bar) File "F:\anaconda3\envs\cell2\lib\site-packages\pytorch_lightning\trainer\connectors\callback_connector.py", line 241, in _configure_progress_bar raise MisconfigurationException( pytorch_lightning.utilities.exceptions.MisconfigurationException: Trainer was configured with enable_progress_bar=False but found ProgressBar in callbacks list. RegressionBackgroundDetectionTech model with the following params: n_factors: 34 n_batch: 23 Training status: Not Trained

I can't solve this problem. Thank you for your time.

xiaoxiaozhihuishu commented 2 years ago

Also, when use_gpu=False, the same error occurs mod.train(max_epochs=250, batch_size=2500, train_size=1, lr=0.002, use_gpu=False)

vitkl commented 2 years ago

Hi @xiaoxiaozhihuishu

Did you create the conda environment as described here https://github.com/BayraktarLab/cell2location#installation using the latest cell2location? I would recommend re-creating the environment including the PYTHONNOUSERSITE option.

Screenshot 2022-05-17 at 17 52 23
vitkl commented 2 years ago

Please try installing the just released cell2location version (v0.1) as described here https://github.com/BayraktarLab/cell2location#installation

xiaoxiaozhihuishu commented 2 years ago

thank you for your reply. This issue has been resolved when I adjust pytorch_lightning = 1.5.10