R: newick tree from list of lists -
i working on create newick tree out of list of childs. have list of lists list name parent name , list element childs. here example:
$`825` [1] 824 $`824` [1] 823 $`823` [1] 822 $`822` [1] 821 $`821` [1] 820 777 $`820` [1] 819 816 789 787 785 783 $`789` [1] 788 $`787` [1] 786 $`785` [1] 784 $`783` [1] 782 $`777` [1] 776
hence output want phylo tree in newick format follows:
825(824(823(822(821(820(819,816,789(788),787,785(784),783(782)),777(776)))))
what best way this? 1 way write recursive function traverses in depth first order , creates tree. in r recursions known bad.
thanks.
if looking pre-canned solution believe bioconductor/ape library has list -> newick converter
http://www.r-phylo.org/wiki/howto/inputtingtrees
otherwise, wrote code while ago did neighbour-joining algorithm; it's extremely terse (written in tight deadline), perhaps help.
https://github.com/rgrannell1/nj/blob/master/main.r
hope helps somewhat
Comments
Post a Comment