简体   繁体   中英

Annotating tree nodes with data for analysis with the Java Evolutionary Biology Library (JEBL)

I'm using JEBL and am stumbling along with the API as I can't find very clear documentation or examples anywhere.

What I would like to do is read in a tree with branches annotated with lengths and nodes annotated too. I should then be able to get the leaves and traverse the tree upwards, checking the annotations of the nodes as I go (the traversal is easy enough with JEBL, my problem is really with the annotation).

They are phylogenetic trees where each node is a species and the annotations will mark whether certain genes are present on a particular node, and there are likely few enough genes that a string would be sufficient (eg if there are three genes A, B, and C possible node annotations might be "AB", "AC", or ""), and this must be allowed to be non-unique (since two nodes might have the same set of genes).

At the moment I am reading the trees in Newick format - I can read the trees in and have branch lengths and traverse the tree, but I don't know how to label the nodes in a useful way (they must be able to be annotated in the format that they are read in from, not programmatically after they are read in):

import java.io.IOException;
import java.io.StringReader;
import java.util.Set;
import jebl.evolution.trees.SimpleRootedTree;
import jebl.evolution.graphs.Node;
import jebl.evolution.io.ImportException;
import jebl.evolution.io.NewickImporter;
import jebl.gui.trees.treeviewer.TreeViewer;
import jebl.evolution.trees.Tree;

public class TreeLoader {  
    public static void main(String[] args) {
        String newick = "(A:0.1,B:0.2,(C:0.3,D:0.4)E:0.5)F;";
        StringReader sr = new StringReader(newick);
        NewickImporter ni = new NewickImporter(sr, true);
        try {
            SimpleRootedTree srt = (SimpleRootedTree) ni.importNextTree();
            Set<Node> leaves = srt.getExternalNodes();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ImportException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }           
    }   
    }

I can't see a way to include the node annotations in the Newick representation to be read in correctly. (I can't use the node names (A, B, etc in the above example) because they have to be unique). I have been looking at the Nexus format but don't really understand it very well. I downloaded Tree Graph to try to create appropriate Nexus files but I can't quite figure out how to do the annotations as I require. And then afterwards I'm not sure if they'll be read in by JEBL in a useful way anyway. I imagine the way forward is to make use of JEBL's Attributable functionality (since Node implements this) but I'm not sure how it will work.

Any advice on how to set up my Nexus files and/or how to get JEBL to read them in correctly and how I can access the annotations would be very gratefully received!!

May be off topic, but have you considered using ETE Toolkit :

In addition to a bunch of functionality, such as searching and traversal, it can also do node annotation:

http://etetoolkit.org/docs/latest/tutorial/tutorial_trees.html#node-annotation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM