dereneaton / ipyrad

Interactive assembly and analysis of RAD-seq data sets
http://ipyrad.readthedocs.io
GNU General Public License v3.0
72 stars 40 forks source link

ipyrad.analysis not compatible with recent toytree version #318

Closed TankredO closed 5 years ago

TankredO commented 6 years ago

First of all thank you for the great package!

I encountered a problem when using the recent versions of ipyrad and toytree together:

python version: 2.7.15, ipyrad version: 0.7.28 (py27ha99686e_0) toytree version: 0.1.18 (py27_0)

import ipyrad.analysis

throws error:

---------------------------------------------------------------------------
IPyradError                               Traceback (most recent call last)
<ipython-input-1-7dbab0508610> in <module>()
----> 1 import ipyrad.analysis as ipa
      2 import ipyparallel as ipp
      3 import toytree
      4 import toyplot

/opt/anaconda/envs/py27/lib/python2.7/site-packages/ipyrad/analysis/__init__.py in <module>()
     16 #from toytree import tree
     17 #from .tetrad import Tetrad as tetrad
---> 18 from .structure import Structure as structure
     19 from .treemix import Treemix as treemix
     20 from .tetrad2 import Tetrad as tetrad

/opt/anaconda/envs/py27/lib/python2.7/site-packages/ipyrad/analysis/structure.py in <module>()
     10 import numpy as np
     11 import pandas as pd
---> 12 from ipyrad.analysis.tetrad import get_spans
     13 from ipyrad.assemble.util import Params, IPyradWarningExit
     14 

/opt/anaconda/envs/py27/lib/python2.7/site-packages/ipyrad/analysis/tetrad.py in <module>()
     61 
     62     conda install toytree -c eaton-lab
---> 63     """)
     64 
     65 

/opt/anaconda/envs/py27/lib/python2.7/site-packages/ipyrad/assemble/util.pyc in __init__(self, *args, **kwargs)
     50     def __init__(self, *args, **kwargs):
     51         if ipyrad.__interactive__:
---> 52             raise IPyradError(*args, **kwargs)
     53         else:
     54             SystemExit.__init__(self, *args, **kwargs)

IPyradError: 
    Error: tetrad requires the dependency 'toytree', which we haven't yet
    included in the ipyrad installation. For now, you can install toytree
    using conda with the following command: 

    conda install toytree -c eaton-lab

This seems to originate from tetrad.py:

try:
    ## when you have time go back and set attrubutes on toytrees
    from toytree import ete3mini as ete3
except ImportError:
    raise IPyradWarningExit("""
    Error: tetrad requires the dependency 'toytree', which we haven't yet
    included in the ipyrad installation. For now, you can install toytree
    using conda with the following command:

    conda install toytree -c eaton-lab
    """)

The problem seems to be that newer versions of toytree don't have the field ete3mini. I solved the problem for myself by installing an older version of toytree (0.1.16, py27_0). Before looking into the code I was quite confused by the error telling me to install toytree. I guess it be very helpful for new users to add a version number for toytree to the error message.

eaton-lab commented 5 years ago

Thanks. Aware of this problem and working to update ipyrad for the latest toytree.

isaacovercast commented 5 years ago

Current workaround for this is: conda install toytree toytree=0.1.16 -c eaton-lab

mzinkgraf commented 5 years ago

I was receiving the original error associated with import ipyrad.analysis and downgrading toytree to version 0.1.16 now causes errors associated with attributes specified in tre.draw() and tre.root(). Thoughts on work around for this error?

# error example from tree tutorial
import toytree
import toyplot
import numpy as np
tre = toytree.tree("https://eaton-lab.org/data/Cyathophora.tre")
tre.draw(width=300);

error message:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-8-55937d305770> in <module>()
      1 # load a tree for this tutorial
      2 tre = toytree.tree("https://eaton-lab.org/data/Cyathophora.tre")
----> 3 tre.draw(width=300);

./miniconda2/lib/python2.7/site-packages/toytree-0.1.16-py2.7.egg/toytree/Toytree.py in draw(self, tree_style, height, width, axes, orient, tip_labels, tip_labels_color, tip_labels_style, tip_labels_align, tip_labels_space, node_labels, node_labels_style, node_size, node_color, node_style, node_hover, edge_type, edge_style, edge_align_style, use_edge_lengths, scalebar, padding, **kwargs)
    649         # update tree_style to custom style with user entered args
    650         self._style._update_from_dict(
--> 651             {i: j for (i, j) in userargs.items() if j is not None})
    652 
    653         # Init Drawing class object.

./miniconda2/lib/python2.7/site-packages/toytree-0.1.16-py2.7.egg/toytree/TreeStyle.py in _update_from_dict(self, kwargs)
     90                 if key in self.__dict__.keys():
     91                     if val is not None:
---> 92                         self.__setattr__(key, val)
     93 
     94             # extra style are dicts that contain CSS style '-' keys

AttributeError: TreeStyle instance has no attribute '__setattr__'
TimBoeh commented 5 years ago

Hey. I do get the exact same error message as @mzinkgraf does. I also downgraded the to toytree=0.1.16. Any suggestions? Cheers, Tim

isaacovercast commented 5 years ago

Fixed in 0.7.30

jferrerobiol commented 5 years ago

Hi, Is the version 0.7.30 already available? When installing ipyrad with the command conda install -c ipyrad ipyrad I install version 0.7.29. Thanks for your help. Cheers, Joan

isaacovercast commented 5 years ago

Are you on mac? I didn't pus the 0.7.30 package for mac yet. I'll work on it.

On Wed, Mar 27, 2019 at 11:53 AM jferrerobiol notifications@github.com wrote:

Hi, Is the version 0.7.30 already available? When installing ipyrad with the command conda install -c ipyrad ipyrad I install version 0.7.29. Thanks for your help. Cheers, Joan

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/dereneaton/ipyrad/issues/318#issuecomment-477222207, or mute the thread https://github.com/notifications/unsubscribe-auth/AFsrv4XfJo6tEvYvWagrR28tP9_5fI-zks5va5QGgaJpZM4Yd_Ri .

jferrerobiol commented 5 years ago

Yes, on mac. Thanks for your fast answer!!

isaacovercast commented 5 years ago

0.7.30 is up for mac.

jferrerobiol commented 5 years ago

Great!! Thanks!!

jferrerobiol commented 5 years ago

Hi again ,

I am trying to run abba-baba admixture tests in ipyrad and I get the following error when trying to generate tests from tree:


AttributeError Traceback (most recent call last)

in () 2 bb.generate_tests_from_tree(constraint_dict={ 3 "p4": ["CLeu1", "CLeu2"], ----> 4 "p3": ["CEdw1"], 5 }) 6 /Users/joan/miniconda2/lib/python2.7/site-packages/ipyrad/analysis/baba.pyc in generate_tests_from_tree(self, constraint_dict, constraint_exact, verbose) 192 if not self.newick: 193 raise AttributeError("no newick tree information in {self}.newick") --> 194 tests = tree2tests(self.newick, constraint_dict, constraint_exact) 195 if verbose: 196 print("{} tests generated from tree".format(len(tests))) /Users/joan/miniconda2/lib/python2.7/site-packages/ipyrad/analysis/baba.pyc in tree2tests(newick, constraint_dict, constraint_exact) 672 673 ## topnode must have children --> 674 for topnode in tree.tree.traverse("levelorder"): 675 for oparent in topnode.children: 676 for onode in oparent.traverse("levelorder"): AttributeError: ToyTree instance has no attribute 'tree' I am using the following versions of the required packages: print ipa.__version__ print toyplot.__version__ print toytree.__version__ 0.7.30 0.18.0 0.1.24 Any thoughts on work around for this error?
isaacovercast commented 5 years ago

I fixed this 2 hours ago: https://github.com/dereneaton/ipyrad/issues/330.

I will push a new conda package for mac and linux. Try again after dinner.

jferrerobiol commented 5 years ago

Worked fine, thanks Isaac! Nonetheless, I am getting another error now when trying to run the abba-baba tests. It looks like it is something related with ipyclient but I am not really sure of what may be the problem. Any thoughts about it:


IPyradError Traceback (most recent call last)

in () ----> 1 bb.run(ipyclient) /Users/joan/miniconda2/lib/python2.7/site-packages/ipyrad/analysis/baba.pyc in run(self, ipyclient) 151 An ipyparallel client object to distribute jobs to a cluster. 152 """ --> 153 self.results_table, self.results_boots = batch(self, ipyclient) 154 155 ## skip this for 5-part test results /Users/joan/miniconda2/lib/python2.7/site-packages/ipyrad/analysis/baba.pyc in batch(baba, ipyclient) 383 if not asyncs[job].successful(): 384 raise IPyradWarningExit(\ --> 385 " error: {}: {}".format(job, asyncs[job].exception())) 386 ## enter results for successful jobs 387 else: /Users/joan/miniconda2/lib/python2.7/site-packages/ipyrad/assemble/util.pyc in __init__(self, *args, **kwargs) 50 def __init__(self, *args, **kwargs): 51 if ipyrad.__interactive__: ---> 52 raise IPyradError(*args, **kwargs) 53 else: 54 SystemExit.__init__(self, *args, **kwargs) IPyradError: error: 1: ValueError(zero-size array to reduction operation maximum which has no identity) I am running ipcluster locally with ipcluster start. Thank you very much for your help and apologize for the inconvenience.
isaacovercast commented 5 years ago

It's not an ipcluster issue. This is the result of calling np.max() on an empty array, so most likely there's a problem with your input. Check to make sure you're giving it reasonable inputs.

jferrerobiol commented 5 years ago

Thanks for the help! It is working fine now for me. Nonetheless, when I try to run the following command to plot the ABBA BABA tests results:

calonectris.plot(height=850, width=700, pct_tree_y=0.2, pct_tree_x=0.5, alpha=4.0);

I get this error:


TypeError Traceback (most recent call last)

in () 1 ## plot results on the tree ----> 2 calonectris.plot(height=850, width=700, pct_tree_y=0.2, pct_tree_x=0.5, alpha=4.0); /Users/joan/miniconda2/lib/python2.7/site-packages/ipyrad/analysis/baba.py in plot(self, show_test_labels, use_edge_lengths, collapse_outgroup, pct_tree_x, pct_tree_y, subset_tests, *args, **kwargs) 255 ttree = toytree.tree( 256 self.newick, 257 orient='down', --> 258 use_edge_lengths=use_edge_lengths) 259 TypeError: __init__() got an unexpected keyword argument 'use_edge_lengths' I tried to take this argument out from the baba.py but then it complains in the same way about the argument orient. Any thoughts about how to solve the error? Cheers, Joan
isaacovercast commented 5 years ago

It's hard to tell what's going on here because I can't see your code. The error looks like you're not importing toytree properly? Or maybe it's an old version? What version of toytree?

jferrerobiol commented 5 years ago

Hi Isaac, I am using version 0.1.24.

These are the versions I am using:

print ipa.version print toyplot.version print toytree.version

0.7.30 0.18.0 0.1.24

isaacovercast commented 5 years ago

Can you post the code? Versions look fine.

jferrerobiol commented 5 years ago

Yes! It is basically the same code as the ABBA-BABA tutorial adapted to my data. Please, find attached the jupyter notebook: dtest.pdf

Thanks for your help!

isaacovercast commented 5 years ago

Yeah, the baba.py code is somewhat out of date with respect to the newest version of toytree. The 'orient' and 'use_edge_lengths' arguments are now part of the draw() functiont of toytree, and no longer part of the constructor. If you remove both of those it should work fine, but no guarantees, since other stuff could be broken.

On Tue, Apr 2, 2019 at 1:16 PM jferrerobiol notifications@github.com wrote:

Yes! It is basically the same code as the ABBA-BABA tutorial adapted to my data. Please, find attached the jupyter notebook: dtest.pdf https://github.com/dereneaton/ipyrad/files/3035149/dtest.pdf

Thanks for your help!

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/dereneaton/ipyrad/issues/318#issuecomment-479102495, or mute the thread https://github.com/notifications/unsubscribe-auth/AFsrv1tshaG2BnMwKl5pi8Et5SEmZTzTks5vc5BzgaJpZM4Yd_Ri .