Hi,
Using Ape, I have constructed an object of class "phylo", using the
method 'nj' (lets call the object 'tree_ja').
I also have a given subset of 'tree_ja' in a vector (lets call the
vector 'subspecies').
What I want to do, is construct a nj tree - plot(tree_ja) - but have the
species in vector 'subspecies' shown as red at the tips of the tree.
The closest I've come is this:
Given that 'tree_ja$tip.label' provides the following:
[1] "1_T1" "2_T1" "3_T1" "4_T1" "5_T1" "6_T1"
[7] "7_T1" "8_T1" "9_T1" "10_T1" "11_T1" "12_T1"
and that my 'subspecies' vector is:
subspecies <- c("1_T1", "2_T1", "3_T1", "4_T1", "6_T1")
which can also be written as:
subspecies <- c(tree_ja$tip.label[1:4], tree_ja$tip.label[5])
I can construct a method which gives me the following statement:
plot(tree_ja, tip.col = c('red', 'red', 'red', 'red', 'black', 'red',
'black', 'black', 'black', 'black', 'black', 'black'))
But this doesn't work (at least not on my full dataset, which as 118
tips - reduced to 12 here for brevity) and I'm SURE there must be a
better way of doing it.
Could anyone help me with this?
Many thanks,
Graham
--
Dr. Graham Etherington
Post-doctoral Bioinformatician,
Department of Computational and Systems Biology
John Innes Centre
Norwich Research Park
Colney
Norwich
NR4 7UH
UK
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.