TypeError: '>' not supported between instances of 'NoneType' and 'int'
Dear @tschuelia,
if the predicted difficulty for MSA is: 0.64, it is very hard or hard?
Edit from @tschuelia:
The original issue was:
Dear @tschuelia I have error:
(base) simon@192 raxml-ng_v1.2.0_macos_x86_64 % pythia -m data/example.phy -r raxml-ng -v -b
PyPythia version 1.0.1 released by The Exelixis Lab
Developed by: Julia Haag
Latest version: [tschuelia/PyPythia](https://github.com/tschuelia/PyPythia)
Questions/problems/suggestions? Please open an issue on GitHub.
[00:00:00] Starting prediction.
[00:00:00] Loading predictor /Users/simon/opt/miniconda3/lib/python3.9/site-packages/pypythia/predictors/predictor_lgb_v1.0.0.pckl
[00:00:01] Checking MSA
[00:00:01] Starting to compute MSA features for MSA data/example.phy
[00:00:01] Retrieving num_patterns, percentage_gaps, percentage_invariant
[00:00:01] Retrieving num_taxa, num_sites
[00:00:01] Inferring 100 parsimony trees
[00:00:04] Computing the RF-Distance for the parsimony trees
[00:00:14] Predicting the difficulty
Traceback (most recent call last):
File "/Users/simon/opt/miniconda3/lib/python3.9/site-packages/pypythia/predictor.py", line 86, in predict
prediction = self.predictor.predict(df, num_threads=1)
File "/Users/simon/opt/miniconda3/lib/python3.9/site-packages/lightgbm/sklearn.py", line 899, in predict
predict_params = self._process_params(stage="predict")
File "/Users/simon/opt/miniconda3/lib/python3.9/site-packages/lightgbm/sklearn.py", line 674, in _process_params
if self._n_classes > 2:
TypeError: '>' not supported between instances of 'NoneType' and 'int'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/simon/opt/miniconda3/bin/pythia", line 10, in
sys.exit(main())
File "/Users/simon/opt/miniconda3/lib/python3.9/site-packages/pypythia/prediction.py", line 259, in main
difficulty = predictor.predict(msa_features)
File "/Users/simon/opt/miniconda3/lib/python3.9/site-packages/pypythia/predictor.py", line 92, in predict
raise PyPythiaException(
pypythia.custom_errors.PyPythiaException: An error occurred predicting the difficulty for the provided set of MSA features.
I'm keeping this to make sure other uses having the same error can find the solution 🙂
Hi Liam, we just had this error recently with a colleague as well and it turned out that conda sometimes installs an old version of PyPythia (1.0.1 as can be seen in the first line of the output), but the current version is 1.1.4. Can you try to upgrade PyPythia by typing conda install pypythia=1.1.4, or (even better) try to create a new conda environment (conda env create -n pythia and conda activate pythia) and install PyPythia again (conda install pypythia -c conda-forge), that should automatically install the correct latest version.
Let me know if that works! 🙂
Dear @tschuelia, Thank you for your great help.
I am confused again, which one should I use:
conda install pypythia=1.1.4 or
conda install pypythia -c conda-forge or
conda install pypythia -c conda-forge -c nodefaults
Hi @liamxg, sorry for the confusion!
In theory, all three commands should do the same thing if you are installing Pythia in a new conda environment. However, when you are adding Pythia to an existing environment, some previous configurations might result in conda solving for an old version of Pythia (it solved for 1.0.1 in your initial error) causing Pythia to fail du to mismatching versions. In this case conda install pypythia=1.1.4 explicitly asks conda to install the 1.1.4 version. The modifier -c coda-forge tells conda in which channel to look for Pythia and -c nodefaults means to not use the default conda packages, as they are sometimes broken and it's better to use the conda-forge builds.
As for your question on the difficulty of your MSA: I opened a new issue (#14) for your new question. Please don't change the title and text of an issue to make sure other uses who might have a similar issue can find the solution as well 🙂
Dear @tschuelia, thanks.
Greetings, @tschuelia! Hope all is well. I'm getting the same/similar error as reported above, namely the following:
pythia --msa HPV16_ABCD_woPremStop_n4704.fasta --raxmlng raxml-ng --removeDuplicates --shap --verbose
PyPythia version 1.1.2 released by The Exelixis Lab
Developed by: Julia Haag
Latest version: https://github.com/tschuelia/PyPythia
Questions/problems/suggestions? Please open an issue on GitHub.
[00:00:00] Starting prediction.
[00:00:00] Loading predictor /opt/anaconda3/lib/python3.12/site-packages/pypythia/predictors/latest.pckl
[00:00:00] Checking MSA
[00:00:00] The input alignment HPV16_ABCD_woPremStop_n4704.fasta contains duplicate sequences: saving a reduced alignment as HPV16_ABCD_woPremStop_n4704.fasta.pythia.reduced
[00:00:01] Starting to compute MSA features for MSA HPV16_ABCD_woPremStop_n4704.fasta.pythia.reduced
[00:00:01] Number of threads not specified, using RAxML-NG autoconfig.
[00:00:01] Retrieving num_patterns, percentage_gaps, percentage_invariant
[00:00:02] Retrieving num_taxa, num_sites
[00:00:02] Inferring 100 parsimony trees
[00:08:56] Computing the RF-Distance for the parsimony trees
[00:10:34] Predicting the difficulty
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.12/site-packages/pypythia/predictor.py", line 102, in predict
prediction = self.predictor.predict(df, num_threads=1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/lib/python3.12/site-packages/lightgbm/sklearn.py", line 1017, in predict
predict_params = self._process_params(stage="predict")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/lib/python3.12/site-packages/lightgbm/sklearn.py", line 769, in _process_params
if self._n_classes > 2:
^^^^^^^^^^^^^^^^^^^
TypeError: '>' not supported between instances of 'NoneType' and 'int'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/anaconda3/bin/pythia", line 10, in <module>
sys.exit(main())
^^^^^^
File "/opt/anaconda3/lib/python3.12/site-packages/pypythia/prediction.py", line 297, in main
difficulty = predictor.predict(msa_features)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/lib/python3.12/site-packages/pypythia/predictor.py", line 108, in predict
raise PyPythiaException(
pypythia.custom_errors.PyPythiaException: An error occurred predicting the difficulty for the provided set of MSA features.
I think the problem may be that my version of Python (3.12.2) is actually too recent and not supported, is that possible? When I try to take your suggestions to liamxg to explicitly reinstall the most recent version, it errors as follows:
conda install pypythia=1.1.4
Channels:
- bioconda
- defaults
- conda-forge
Platform: osx-arm64
Collecting package metadata (repodata.json): done
Solving environment: \ warning libmamba Added empty dependency for problem type SOLVER_RULE_UPDATE
failed
LibMambaUnsatisfiableError: Encountered problems while solving:
- package pypythia-1.1.4-pyh707e725_0 requires scikit-learn >=1.0,<1.3, but none of the providers can be installed
Could not solve for environment specs
The following packages are incompatible
├─ pin-1 is installable and it requires
│ └─ python 3.12.* , which can be installed;
└─ pypythia 1.1.4** is not installable because it requires
└─ scikit-learn >=1.0,<1.3 but there are no viable options
├─ scikit-learn [1.0|1.0.1|...|1.2.2] would require
│ └─ python >=3.8,<3.9.0a0 , which conflicts with any installable versions previously reported;
├─ scikit-learn [1.0|1.0.1|...|1.2.2] would require
│ └─ python >=3.9,<3.10.0a0 , which conflicts with any installable versions previously reported;
├─ scikit-learn [1.0.2|1.1.1|...|1.2.2] would require
│ └─ python >=3.10,<3.11.0a0 , which conflicts with any installable versions previously reported;
├─ scikit-learn [1.1.3|1.2.1|1.2.2] would require
│ └─ python >=3.11,<3.12.0a0 , which conflicts with any installable versions previously reported;
├─ scikit-learn [1.0.1|1.0.2|...|1.2.2] would require
│ └─ python >=3.10,<3.11.0a0 *_cpython, which conflicts with any installable versions previously reported;
├─ scikit-learn [1.0.1|1.0.2|...|1.2.2] would require
│ └─ python >=3.8,<3.9.0a0 *_cpython, which conflicts with any installable versions previously reported;
├─ scikit-learn [1.0.1|1.0.2|...|1.2.2] would require
│ └─ python >=3.9,<3.10.0a0 *_cpython, which conflicts with any installable versions previously reported;
└─ scikit-learn [1.1.3|1.2.0|1.2.1|1.2.2] would require
└─ python >=3.11,<3.12.0a0 *_cpython, which conflicts with any installable versions previously reported.
This may be beyond the ambit of (more basic issue than) Pythia, but I'd be grateful if you have any insight or suggestions!
Thanks a ton, Chase
Dear @singing-scientist , Nice to meet you here, you are working on HPV?
Hi Chase! Indeed, the problem seems to be your Python version. For legacy support, Pythia requires scikit-learn < 1.3 which does not support Python 3.12. I intend to do some changes soon to support newer versions of Python.
Could you try setting up a new environment with Python 3.11? That should work (unless I messed something up :)), and you can try to install the latest version Pythia 1.2