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
100 stars 24 forks source link

Molecular Featurizer 'Pretrain' fails #1

Closed MxMstrmn closed 3 years ago

MxMstrmn commented 3 years ago

Running the DrugEmb class with the molecular featurizer set to Pretrain fails at computing the graphs from the SMILES strings.

At graph_from_smiles it fails: https://github.com/theislab/chemical_CPA/blob/0ef1363f762cef91f9a046b91827d190aa93225a/compert/data.py#L137-L146

This is the Traceback:

Traceback (most recent call last):
  File "/home/icb/leon.hetzel/miniconda3/envs/py38/lib/python3.8/site-packages/sacred/experiment.py", line 312, in run_commandline
    return self.run(
  File "/home/icb/leon.hetzel/miniconda3/envs/py38/lib/python3.8/site-packages/sacred/experiment.py", line 276, in run
    run()
  File "/home/icb/leon.hetzel/miniconda3/envs/py38/lib/python3.8/site-packages/sacred/run.py", line 238, in __call__
    self.result = self.main_function(*args)
  File "/home/icb/leon.hetzel/miniconda3/envs/py38/lib/python3.8/site-packages/sacred/config/captured_function.py", line 42, in captured_function
    result = wrapped(*args, **kwargs)
  File "/tmp/26918/compert/seml_sweep_icb.py", line 266, in train
    experiment = ExperimentWrapper()
  File "/tmp/26918/compert/seml_sweep_icb.py", line 69, in __init__
    self.init_all()
  File "/tmp/26918/compert/seml_sweep_icb.py", line 152, in init_all
    self.init_dataset()
  File "/home/icb/leon.hetzel/miniconda3/envs/py38/lib/python3.8/site-packages/sacred/config/captured_function.py", line 42, in captured_function
    result = wrapped(*args, **kwargs)
  File "/tmp/26918/compert/seml_sweep_icb.py", line 84, in init_dataset
    self.datasets, self.dataset = load_dataset_splits(
  File "/tmp/26918/compert/data.py", line 281, in load_dataset_splits
    dataset = Dataset(
  File "/tmp/26918/compert/data.py", line 137, in __init__
    graph_tuple = graph_from_smiles(
  File "/tmp/26918/compert/helper.py", line 162, in graph_from_smiles
    graph = smiles2graph(smiles)
  File "/tmp/26918/compert/helper.py", line 148, in <lambda>
    smiles2graph = lambda smiles: smiles_to_bigraph(
  File "/home/icb/leon.hetzel/miniconda3/envs/py38/lib/python3.8/site-packages/dgllife/utils/mol_to_graph.py", line 369, in smiles_to_bigraph
    return mol_to_bigraph(mol, add_self_loop, node_featurizer, edge_featurizer,
  File "/home/icb/leon.hetzel/miniconda3/envs/py38/lib/python3.8/site-packages/dgllife/utils/mol_to_graph.py", line 269, in mol_to_bigraph
    return mol_to_graph(mol, partial(construct_bigraph_from_mol, add_self_loop=add_self_loop),
  File "/home/icb/leon.hetzel/miniconda3/envs/py38/lib/python3.8/site-packages/dgllife/utils/mol_to_graph.py", line 85, in mol_to_graph
    g.ndata.update(node_featurizer(mol))
  File "/home/icb/leon.hetzel/miniconda3/envs/py38/lib/python3.8/site-packages/dgllife/utils/featurizers.py", line 1289, in __call__
    self._atomic_number_types.index(atom.GetAtomicNum()),
ValueError: 0 is not in list
M0hammadL commented 3 years ago

pretrain from another network (cpa) or pretrained SS large models from other papers?

MxMstrmn commented 3 years ago

It is just this featurizer:

AtomFeaturizer in Strategies for Pre-training Graph Neural Networks.

    The atom featurization performed in `Strategies for Pre-training Graph Neural Networks
    <https://arxiv.org/abs/1905.12265>`__, which considers:

    * atomic number
    * chirality