DessimozLab / pyham

MIT License
9 stars 5 forks source link

How to draw a singleton? #27

Open billzhanghantao opened 3 months ago

billzhanghantao commented 3 months ago

Thank you very much for developing this tool, but I'm having problems visualising the singleton and don't know how to fix it. Since singleton doesn't belong to any hog, I encountered this error when running ham_analysis.get_hog_by_gene(gene_iseg): TypeError: Invalid argument Gene(138338) for HOG. When I switch to the other way and run the following commands in sequence: filter_ham = pyham.ParserFilter() filter_ham.add_hogs_via_GeneIntId([138338]) ham_analysis_filter = pyham.Ham(tree_str, orthoxml_path, use_internal_name=True, filter_object=filter_ham) treeprofile = ham_analysis_filter.create_tree_profile(outfile="/Users/test.html") from IPython.display import IFrame IFrame("/Users/zhanghantao/Desktop/test.html", width=240, height=120) I encountered this error:KeyError: 'No ancestral genomes match the query name: 1',the 1 I assume refers to the root node in my evolutionary tree. Can you please tell me how to visualize singletons using pyham?

F4llis commented 3 months ago

Hello,

Singleton gene does not belong to any hogs therefore it's not possible to access them through/toward hog object or to use hog based features such as create_tree_profile.

You can access your extant gene using ham_analysis.get_gene_by_id function. No tree profile is available for this object though since it's an gene and not a hierarchical group.

I hope this helps, Clement