Permalink
Browse files

fix to node labels when not all nodes are labelled

  • Loading branch information...
liamrevell committed Jun 23, 2017
1 parent 9f8390a commit 9c4ceef543d28cf167e1a7afe6b9da57ffee4511
Showing with 12 additions and 11 deletions.
  1. +4 −4 DESCRIPTION
  2. +8 −7 R/read.newick.R
View
@@ -1,6 +1,6 @@
Package: phytools
Version: 0.6-16
Date: 2017-06-08
Version: 0.6-17
Date: 2017-06-23
Title: Phylogenetic Tools for Comparative Biology (and Other Things)
Author: Liam J. Revell
Maintainer: Liam J. Revell <liam.revell@umb.edu>
@@ -56,6 +56,6 @@ Description: Package contains various functions for phylogenetic analysis.
research.
License: GPL (>= 2)
URL: http://github.com/liamrevell/phytools
Packaged: 2017-06-08 12:00:00 EST
Packaged: 2017-06-23 12:00:00 EST
Repository:
Date/Publication: 2017-06-08 12:00:00 EST
Date/Publication: 2017-06-23 12:00:00 EST
View
@@ -1,5 +1,5 @@
# function to read a Newick string with node labels & (possible) singles
# written by Liam J. Revell 2013, 2014, 2015
## function to read a Newick string with node labels & (possible) singles
## written by Liam J. Revell 2013, 2014, 2015, 2017
read.newick<-function(file="",text,...){
# check to see if reading from file
@@ -54,7 +54,7 @@ newick<-function(text){
temp<-getLabel(text,i)
node.label[currnode]<-temp$label
i<-temp$end
}
} else node.label[currnode]<-NA
ii<-ei[currnode]
# is there a branch length?
if(text[i]==":"){
@@ -95,13 +95,14 @@ newick<-function(text){
edge[edge<0]<--edge[edge<0]
edge.length[is.na(edge.length)]<-0
if(length(edge.length)==0) edge.length<-NULL
node.label[is.na(node.label)]<-""
if(length(node.label)==0) node.label<-NULL
if(all(is.na(node.label))) node.label<-NULL
else node.label[is.na(node.label)]<-""
# assemble into "phylo" object
tree<-list(edge=edge,Nnode=as.integer(Nnode),tip.label=tip.label,edge.length=edge.length,node.label=node.label)
tree<-list(edge=edge,Nnode=as.integer(Nnode),tip.label=tip.label,
edge.length=edge.length,node.label=node.label)
class(tree)<-"phylo"
attr(tree,"order")<-"cladewise"
return(tree)
tree
}
# function gets label

0 comments on commit 9c4ceef

Please sign in to comment.