kr-colab / diploSHIC

feature-based deep learning for the identification of selective sweeps
MIT License
49 stars 14 forks source link

Error printing out confusion matrix #52

Closed MattHartfield closed 7 months ago

MattHartfield commented 7 months ago

Hi, I'm encountering errors when trying to print out the confusion matrix when training diploSHIC.

Minimal code: If I simply want to run the training command on mosquito simulation data, as provided in your tutorial, but also outputting the confusion matrix:

diploSHIC train trainingSets/ trainingSets/ bfsModel --confusionFile ConfusionMatrix

I get the following error message:

Traceback (most recent call last):
  File "/ceph/users/mhartfield/.conda/envs/diploshic/bin/diploSHIC", line 537, in <module>
    from misc import plot_confusion_matrix
ModuleNotFoundError: No module named 'misc'

I looked at the 'diploSHIC' python file in the repo and there is no 'import misc' command; I added such a command to the end of the other 'import' commands but there is still an error message.

Program was run on a linux-based cluster.

Update - I realised that I added the 'import misc' command to the downloaded version of diploSHIC, but not the installed version in the conda env on the server. I manually edited that file but still get an error:

Traceback (most recent call last):
  File "/ceph/users/mhartfield/.conda/envs/diploshic/bin/diploSHIC", line 3, in <module>
    import argparse, time, sys, subprocess, misc
ModuleNotFoundError: No module named 'misc'
bruce-edelman commented 7 months ago

Hi Matt, I was able to reproduce this in a fresh env and installation. I am guessing testing the confusion matrix plotting got lost in some downstream changes to the packaging.

If you change the import at line 537 to from diploshic.misc import plot_confusion_matrix and then re-install that should fix it.

I am not sure if you are installing diploshic from source or through pip but the easiest and quickest fix will be to download the repo -- make this one line change -- and then re-install from source. In the meantime I will make a PR to get it fixed in the master branch and then propagated to the versions of diploshic on PyPI

MattHartfield commented 7 months ago

That now works, thanks for your rapid reply!