DessimozLab / pyham

MIT License
9 stars 5 forks source link

AttributeError: 'NoneType' object has no attribute 'features' #19

Open gmartinezredondo opened 2 years ago

gmartinezredondo commented 2 years ago

Hi!

I am using pyham 1.1.11 with 4 different gene trees/orthoxml files with a large species tree, and another orthoxml with a second species tree which is a clade within the other one. However, when I use the species trees without modifications I get this error: Traceback (most recent call last): File "/mnt/netapp2/Store_csbye/scripts/orthoxml_pyham.py", line 44, in <module> ham_analysis = pyham.Ham(tree_str, orthoxml_path, use_internal_name=False) File "/opt/cesga/2020/software/Core/pyham/1.1.11/lib/python3.7/site-packages/pyham/ham.py", line 263, in __init__ self.top_level_hogs, self.extant_gene_map, self.external_id_mapper = self._build_hogs_and_genes(orthoxml_file, filter_object=self.filter_obj) File "/opt/cesga/2020/software/Core/pyham/1.1.11/lib/python3.7/site-packages/pyham/ham.py", line 819, in _build_hogs_and_genes parser.feed(line) File "/opt/cesga/2020/software/Core/pyham/1.1.11/lib/python3.7/site-packages/pyham/parsers.py", line 159, in end ln['node'].set_MRCA() File "/opt/cesga/2020/software/Core/pyham/1.1.11/lib/python3.7/site-packages/pyham/abstractgene.py", line 512, in set_MRCA self.MRCA = self.ham._get_ancestral_genome_by_taxon(self.MRCA.taxon.up) File "/opt/cesga/2020/software/Core/pyham/1.1.11/lib/python3.7/site-packages/pyham/ham.py", line 907, in _get_ancestral_genome_by_taxon if "genome" in tax_node.features: AttributeError: 'NoneType' object has no attribute 'features'

If I add to the species trees an outgroup species (not present in the orthoxml file), pyham runs without any issue for all genes but one.

Why is it working if I add an outgroup species but not without it? What could be the source of the error?

I attach the smallest of my datasets (the original and modified species tree) to see if you can see where the issue lies. eglps.orthoxml.txt insecta_original.nwk.txt insecta_with_outgroup.nwk.txt

F4llis commented 2 years ago

Dear gmartinezredondo,

This is indeed not a normal behavior from pyham, it should run without the need to add an outgroup.

However, the newick files you send me are identicals. (md5 1532a2ea3364f46182a5fab65605c623 for both)

Also ALWAYS make sure you are using the reference species tree used to built the HOGs.

Clement

gmartinezredondo commented 2 years ago

Hi, Clement:

My bad. I uploaded the same file by mistake.

It is supposed to be the same reference species tree I used to build the HOGs. I execute all the steps using the same script. But I will double check everything, just in case.

insecta_original.nwk.txt

gmartinezredondo commented 2 years ago

Hi, Clement:

My bad. I uploaded the same file by mistake. Here is the good one: insecta_original.nwk.txt https://github.com/DessimozLab/pyham/files/7660028/insecta_original.nwk.txt

I obtained the orthoXML file directly from the gene tree using an ETE3 script as my goal is to identify when gene gain and losses occurred across my species tree.

Gemma

El lun, 6 dic 2021 a las 10:56, F4llis @.***>) escribió:

Dear gmartinezredondo,

This is indeed not a normal behavior from pyham, it should run without the need to add an outgroup.

However, the newick files you send me are identicals. (md5 1532a2ea3364f46182a5fab65605c623 for both)

Also ALWAYS make sure you are using the reference species tree used to built the HOGs.

Clement

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/DessimozLab/pyham/issues/19#issuecomment-986614482, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMFWOCXQGAF4QU5PNMRBN3TUPSCD5ANCNFSM5JOEJO3Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

alpae commented 1 year ago

Hi @gmartinezredondo

sorry for the late reply. It seems that your orthoxml file is not in agreement with the species tree. The gene from your outgroup species MHRA1 is somewhere deep in the orthologGroup/paralogGroup nesting. According the orthoxml file, the XVES1_DN6789_c0_g1_i1.p1 should be the outgroup protein, but that species is completely nested in the tree.

My feeling is that your gene tree is not properly rooted and you used a simple species overlap method for the label the events on the gene tree. Instead, you should properly reconcile the gene tree with your species tree you use for pyham.

Feel free to get back to us. Best wishes Adrian