Skip to content

Commit

Permalink
fix to node labels when not all nodes are labelled
Browse files Browse the repository at this point in the history
  • Loading branch information
liamrevell committed Jun 23, 2017
1 parent 9f8390a commit 9c4ceef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
@@ -1,6 +1,6 @@
Package: phytools Package: phytools
Version: 0.6-16 Version: 0.6-17
Date: 2017-06-08 Date: 2017-06-23
Title: Phylogenetic Tools for Comparative Biology (and Other Things) Title: Phylogenetic Tools for Comparative Biology (and Other Things)
Author: Liam J. Revell Author: Liam J. Revell
Maintainer: Liam J. Revell <liam.revell@umb.edu> Maintainer: Liam J. Revell <liam.revell@umb.edu>
Expand Down Expand Up @@ -56,6 +56,6 @@ Description: Package contains various functions for phylogenetic analysis.
research. research.
License: GPL (>= 2) License: GPL (>= 2)
URL: http://github.com/liamrevell/phytools URL: http://github.com/liamrevell/phytools
Packaged: 2017-06-08 12:00:00 EST Packaged: 2017-06-23 12:00:00 EST
Repository: Repository:
Date/Publication: 2017-06-08 12:00:00 EST Date/Publication: 2017-06-23 12:00:00 EST
15 changes: 8 additions & 7 deletions R/read.newick.R
@@ -1,5 +1,5 @@
# function to read a Newick string with node labels & (possible) singles ## function to read a Newick string with node labels & (possible) singles
# written by Liam J. Revell 2013, 2014, 2015 ## written by Liam J. Revell 2013, 2014, 2015, 2017


read.newick<-function(file="",text,...){ read.newick<-function(file="",text,...){
# check to see if reading from file # check to see if reading from file
Expand Down Expand Up @@ -54,7 +54,7 @@ newick<-function(text){
temp<-getLabel(text,i) temp<-getLabel(text,i)
node.label[currnode]<-temp$label node.label[currnode]<-temp$label
i<-temp$end i<-temp$end
} } else node.label[currnode]<-NA
ii<-ei[currnode] ii<-ei[currnode]
# is there a branch length? # is there a branch length?
if(text[i]==":"){ if(text[i]==":"){
Expand Down Expand Up @@ -95,13 +95,14 @@ newick<-function(text){
edge[edge<0]<--edge[edge<0] edge[edge<0]<--edge[edge<0]
edge.length[is.na(edge.length)]<-0 edge.length[is.na(edge.length)]<-0
if(length(edge.length)==0) edge.length<-NULL if(length(edge.length)==0) edge.length<-NULL
node.label[is.na(node.label)]<-"" if(all(is.na(node.label))) node.label<-NULL
if(length(node.label)==0) node.label<-NULL else node.label[is.na(node.label)]<-""
# assemble into "phylo" object # 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" class(tree)<-"phylo"
attr(tree,"order")<-"cladewise" attr(tree,"order")<-"cladewise"
return(tree) tree
} }


# function gets label # function gets label
Expand Down

0 comments on commit 9c4ceef

Please sign in to comment.