Created
February 12, 2018 14:53
-
-
Save DomBennett/04cf9d102b82f7bf3f1f861bb375f8b2 to your computer and use it in GitHub Desktop.
Convert RAxML consensus tree | Readable in R | APE library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# LIB | |
library(ape) | |
# DATA | |
# tree string produced by `RAxML -J ` arg | |
trstr <- "(A,B,(C,((D,((E,F):1.0[80],((G,H):1.0[100],(I,J):1.0[100]):1.0[67]):1.0[58]):1.0[98],(K,(L,(M,N):1.0[89]):1.0[91]):1.0[100]):1.0[97]):1.0[97]);" | |
# FAIL | |
tree <- read.tree(text=trstr) | |
# node.label = NULL | |
# CONVERT STRING | |
# remove branch lengths and [] | |
trstr <- gsub(':[0-9.]+', '', trstr) | |
trstr <- gsub('(\\[|\\])', '', trstr) | |
# SUCCESS | |
tree <- read.tree(text=trstr) | |
# node.label = "" "97" "97" "98" "58" "80" "67" "100" "100" "100" "91" "89" | |
# Note, branch lengths are lost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment