rerooting trees - set_root_node

32 views
Skip to first unread message

László Nagy

unread,
Sep 13, 2012, 11:28:01 AM9/13/12
to bio-...@googlegroups.com
Hi All,

I am trying to midpoint root raxml trees. After getting the midpoint, I reroot the trees using set_root_node. However, the rerooted tree contains only the subtree of the original tree right to the midpoint:

my $tree = Bio::Phylo::IO->parse(
-file => "$single",
-format => 'newick'
)->first;
$tree_ref = &find_root(\$tree);
$tree = $$tree_ref;
my $output = $tree->to_nexus;
print "$output";


sub find_root {
    my $in = shift;
    my $intree = $$in;
    my $midpoint = $intree->get_midpoint;
    $intree->set_root_node($midpoint);
    return(\$intree);
}

Find below the examples I was working with. Any suggestions on what is going wrong? Are there any other ways to reroot trees?

Thanks,
Laszlo Nagy

input tree: (((47223|Glotr1_1:0.1870256405731729,((((9129|Copci1:0.2638993467789102,((142250|Lacbi1:0.01881944728995953,(397690|Lacbi1:1.22123005994819E-6,397714|Lacbi1:1.22123005994819E-6):0.00856208412070986):0.0059691182878844765,(392686|Lacbi1:0.01596983665385525,(397906|Lacbi1:0.017070032001284357,148241|Lacbi1:1.22123005994819E-6):1.22123005994819E-6):0.006802378804587311):0.18478986495932254):0.12520488809248406,(((125215|Wolco1:0.12167857594827831,162486|Fompi1:0.26641858306435384):0.09209820252355427,130304|Trave1:0.15852096455669132):1.22123005994819E-6,43177|Phchr1:0.20974876864397232):0.06641452623687252):0.008014004605706703,(94360|Stehi1:0.2822376570811102,325846|Hetan2:0.08090723404430938):0.07942461992624911):0.011433786260801894,(98391|Fomme1:0.2597254343303018,(86051|Schco1:0.3697221593786481,(66345|Dacsp1:0.4605187202448926,(70510|Aurde1:0.3881829407263203,((14351|Treme1:0.17125083275934758,324|Cryne_H99_1:0.09923585318365416):0.2632201255925525,(((64487|Picst3:1.0034498880881788,(72459|Trire2:0.40677928854089973,(199607|Aspni5:0.47394572717508054,7181|Stano1:0.43213766992483355):0.06590285463854209):0.09784763698049438):0.3476439979681281,(8973|Batde5:0.7522430469640745,((97688|Phybl2:0.22997388685296616,87373|Phybl2:0.1700306850144633):0.24765128159768707,(97048|Phybl2:0.29558248669353065,97924|Phybl2:0.5417961198596051):0.12488623048496786):0.2191163075980682):0.19074867266778958):0.26179524614297195,((46552|Mellp1:0.3513073312340472,(139|Malgl1:0.871938875455747,3809|Ustma1:0.1669640062225054):0.1666049545406587):0.0692231228791192,15753|Sporo1:0.43665354638787446):0.0634445695986755):0.1260037440876534):0.07216844097041415):0.023608476589111554):0.04200961955597732):0.03561139393606009):0.02121742875157713):0.034109162578782465):0.06972369280567248,108015|Conpu1:0.3038467622200568):0.0,458330|Serla_S7_9:0.10696531521701169):0.0;


output tree:

BEGIN TREES;
[! Trees block written by Bio::Phylo::Forest 0.47_1660 on Thu Sep 13 11:22:49 2012 ]
    TRANSLATE
        1 64487|Picst3,
        2 8973|Batde5,
        3 72459|Trire2,
        4 199607|Aspni5,
        5 7181|Stano1,
        6 97688|Phybl2,
        7 87373|Phybl2,
        8 97048|Phybl2,
        9 97924|Phybl2;
    TREE Tree65 = [&R] ((1:1.003450,(3:0.406779,(4:0.473946,5:0.432138):0.065903):0.097848):0.347644,(2:0.752243,((6:0.229974,7:0.170031):0.247651,(8:0.295582,9:0.541796):0.124886):0.219116):0.190749):0.261795;
END;



Rutger Vos

unread,
Oct 11, 2012, 11:20:25 AM10/11/12
to bio-...@googlegroups.com
Hi Laszlo,

again a terribly late response, sorry about that. Anyway, what you want to use is not set_root_node (which makes the midpoint node the root of the subtree), but set_root_below, which re-arranges the tree so that it becomes rooted on the midpoint.

Hope this is still useful for someone.

Best wishes,

Rutger

Laszlo Nagy

unread,
Oct 11, 2012, 3:04:05 PM10/11/12
to bio-...@googlegroups.com
Hi Rutger,

thanks, this helps, now it is working.

cheers,
Laszlo
Reply all
Reply to author
Forward
0 new messages