Created
May 26, 2021 15:48
-
-
Save cromanpa94/2879d5bfd520218efcbb47a41ddb3b42 to your computer and use it in GitHub Desktop.
This scripts helps to read phylogenetic trees in newick or nexus automatically
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
library(phytools) | |
# fullNew = path to tree files | |
trees<-lapply(seq_along(fullNew), function(x){ | |
cat(x,'_',fullNew[x], '\n') | |
k<-grep('#NEXUS', readLines(fullNew[x])) | |
if(length(k)>0){ | |
read.nexus(fullNew[x]) | |
}else{ | |
read.newick(fullNew[x]) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment