Skip to content

Instantly share code, notes, and snippets.

@cromanpa94
Created May 26, 2021 15:48
Show Gist options
  • Save cromanpa94/2879d5bfd520218efcbb47a41ddb3b42 to your computer and use it in GitHub Desktop.
Save cromanpa94/2879d5bfd520218efcbb47a41ddb3b42 to your computer and use it in GitHub Desktop.
This scripts helps to read phylogenetic trees in newick or nexus automatically
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