AMPL icon indicating copy to clipboard operation
AMPL copied to clipboard

Tutorial notebook 01_Exploring_Target_Activity_ExcapeDB.ipynb errs generating a diversity plot

Open bmoxon opened this issue 1 year ago • 1 comments

The cell in that notebook with code

dp.diversity_plots(dset_key=ifile,datastore=False,id_col='compound_id',response_col='pXC50')

errs as follows ...

Canonicalizing 597 molecules...
Done
Computing fingerprints...
Done
Computing Tanimoto distance matrix...
Done
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-33-0fcf5b0f8bc3> in <module>
----> 1 dp.diversity_plots(dset_key=ifile,datastore=False,id_col='compound_id',response_col='pXC50')

~/localfiles/AMPL/atomsci/ddm/pipeline/diversity_plots.py in diversity_plots(dset_key, datastore, bucket, title_prefix, ecfp_radius, umap_file, out_dir, id_col, smiles_col, is_base_smiles, response_col, max_for_mcs)
    322     print("Done")
    323     # Draw a UMAP projection based on Tanimoto distance
--> 324     mapper = umap.UMAP(n_neighbors=20, min_dist=0.1, n_components=2, metric='precomputed', random_state=17)
    325     reps = mapper.fit_transform(tani_dist)
    326     rep_df = pd.DataFrame.from_records(reps, columns=['x', 'y'])

AttributeError: module 'umap' has no attribute 'UMAP'

A stackoverflow post reports this problem and suggests a solution consistent with umap-learn pypi documentation that works for me when applied to my python virtual environment with an atomsci build (I install the additional dependencies at the start of the notebooks in my virtual environment, i.e. rdkit-pypi, deepchem, umap-learn, molvs, bravado). In an existing environment, the following:

$ pip uninstall umap-learn
$ pip uninstall umap
$ pip install umap-learn

with a change to the notebook to

import umap.umap_ as umap

ahead of the importing of AMPL libraries

works. I've modified my python env to not install umap (just umap-learn) and to use the modified import statement, which seems to work consistently.

That approach also allows the integrative test integrative/multitask_split/test_split.py::test_splits to succeed (it fails without these fixes).

bmoxon avatar Apr 06 '23 23:04 bmoxon

I wasn't able to reproduce the error when running on Google Colab. Could you elaborate on your environment?

stewarthe6 avatar Apr 12 '23 23:04 stewarthe6