Hi Dave (I've Cc'd the list back in, in case someone else knows the answer),

Thanks for the suggestions. You're right—the simulated data does plot in
matching order (both for your example and Emmanuel's original one), so
Emmanuel's code is not the problem. The difficulty is apparently in getting
both my tree and trait data to be in the order they plot *on the tree*
(backwards, actually, as they are ordered vertically from bottom to top
relative to the way R reports them when probing the tree or data objects).
Currently they are ordered in a completely different way.

Here is the ordering of my tree tips and data:

> tree$tip.label
[1] "Menura"                 "Tyrannus"               "Cacatua"
   "Herpetotheres"
 [5] "Momotus"                "Tyto"                   "Pandion"
   "Sagittarius"
 [9] "Rostratula"             "Larus"                  "Phalacrocorax"
   "Ardea"
[13] "Cochlearius"            "Pelecanoides"           "Cuculus"
   "Eurostopodus"
[17] "Podargus"               "Phoenicopterus"         "Podiceps"
    "Coturnix"
[21] "Numida"                 "Anas"                   "Oxyura"
    "Chauna"
[25] "Crypturellus"           "Tinamus"                "Accipiter"
   "Aechmophorus"
[29] "Ajaja"                  "Anhinga_n"              "Anhinga_r"
   "Anodorhynchus"
[33] "Aptenodytes"            "Ardeotis"               "Argusianus"
    "Cerorhinca"
[37] "Chionis"                "Circus"                 "Colaptes"
    "Colluricincla"
[41] "Coracina"               "Corcorax"               "Corvus_c"
    "Corvus_m"
[45] "Corvus_o"               "Cygnus"                 "Dacelo"
    "Diomedea_e"
[49] "Diomedea_i"             "Esacus"
"Eudyptes_chryosolophus" "Eudyptes_chrysocome"
[53] "Falco_p"                "Falco_r"                "Fulica"
    "Geranospiza"
[57] "Grallina"               "Guttera"                "Gymnorhina"
    "Hirundapus"
[61] "Leipoa"                 "Leptoptilos"            "Limosa"
    "Macrocephalon"
[65] "Megaceryle"             "Morus_b"                "Morus_s"
   "Mycteria"
[69] "Ninox"                  "Oriolus"                "Pagodroma"
   "Phaethon"
[73] "Phaps"                  "Pterodroma"             "Ptilonorhynchus"
   "Pulsatrix"
[77] "Recurvirostra"          "Rynchops"               "Spheniscus"
    "Stercorarius"
[81] "Stiltia"                "Sturnus"                "Thalassarche"
    "Threskiornis"
[85] "Tityra"                 "Vanellus"

> row.names(data)
 [1] "Menura"                 "Tyrannus"               "Cacatua"
   "Herpetotheres"
 [5] "Momotus"                "Tyto"                   "Pandion"
   "Sagittarius"
 [9] "Rostratula"             "Larus"                  "Phalacrocorax"
   "Ardea"
[13] "Cochlearius"            "Pelecanoides"           "Cuculus"
   "Eurostopodus"
[17] "Podargus"               "Phoenicopterus"         "Podiceps"
    "Coturnix"
[21] "Numida"                 "Anas"                   "Oxyura"
    "Chauna"
[25] "Crypturellus"           "Tinamus"                "Accipiter"
   "Aechmophorus"
[29] "Ajaja"                  "Anhinga_n"              "Anhinga_r"
   "Anodorhynchus"
[33] "Aptenodytes"            "Ardeotis"               "Argusianus"
    "Cerorhinca"
[37] "Chionis"                "Circus"                 "Colaptes"
    "Colluricincla"
[41] "Coracina"               "Corcorax"               "Corvus_c"
    "Corvus_m"
[45] "Corvus_o"               "Cygnus"                 "Dacelo"
    "Diomedea_e"
[49] "Diomedea_i"             "Esacus"
"Eudyptes_chryosolophus" "Eudyptes_chrysocome"
[53] "Falco_p"                "Falco_r"                "Fulica"
    "Geranospiza"
[57] "Grallina"               "Guttera"                "Gymnorhina"
    "Hirundapus"
[61] "Leipoa"                 "Leptoptilos"            "Limosa"
    "Macrocephalon"
[65] "Megaceryle"             "Morus_b"                "Morus_s"
   "Mycteria"
[69] "Ninox"                  "Oriolus"                "Pagodroma"
   "Phaethon"
[73] "Phaps"                  "Pterodroma"             "Ptilonorhynchus"
   "Pulsatrix"
[77] "Recurvirostra"          "Rynchops"               "Spheniscus"
    "Stercorarius"
[81] "Stiltia"                "Sturnus"                "Thalassarche"
    "Threskiornis"
[85] "Tityra"                 "Vanellus"

And here is a pdf of the tree with adjacent barplots I'm attempting to
reorder (ignore the factor colours; they're correct for the tip labels but
hopelessly wrong for the barplots—that a different problem!):
http://cl.ly/1p2V2A2D352y0O1R3F01

I've tried to reorder the taxa to match the phylo plot using
reorder.phylo()or the
names(data$trait)<-tree$tip.label trick, but the order stays exactly the
same.

If anyone knows how to make the ordering match the phylo plot, I'd be very
keen to hear from them!

Cheers,

Roger


---
Roger Close
PhD Student
School of Geosciences
Monash University
Clayton 3800
Victoria, Australia

email: roger.cl...@monash.edu
phone: +61423 131 176

Research Collaborator
Department of Earth Sciences
University of Bristol
Queens Rd, Bristol BS8 1RJ
United Kingdom


On 29 June 2011 15:38, David Bapst <dwba...@uchicago.edu> wrote:
>
> Hello Roger,
> Have you tried simulated data to see if it is your data or the code that
is messing up?
>
> tree<-rtree(10)
> data<-list(trait=rnorm(10))
> names(data$trait)<-tree$tip.label
> plot(tree, x.lim = 40, cex = 0.4) # <- adjust x.lim
> offset <- 22 # <- adjust offset
> barplot(c(NA, data$trait), add = TRUE, horiz = TRUE, space = 0, offset =
> offset, axes = FALSE, axisnames = FALSE)
> lab <- pretty(data$trait)
> axis(1, lab + offset, labels = lab, cex.axis = 0.4, padj = 0)
> data$trait
>
> ...then compare the output of data$trait to the bar graph. do they agree?
>
> If so, than there is something funky with your data, probably. Hard to say
what without seeing it. Maybe try reorder.phylo() and see if that changes
anything (you'll need to reorder the trait$data too). If it didn't work,
than maybe try downloading the newest version of R and reinstalling ape.
>
> I hope this helps. Also, good to see another paleo person on this list.
> -Dave
>
> On Tue, Jun 28, 2011 at 10:52 PM, Roger Close <roger.cl...@gmail.com>
wrote:
>>
>> Hello all,
>>
>> I have borrowed Emmanuel Paradis' example code for adding a barplot of
trait
>> data next to a phylo plot (
>> https://stat.ethz.ch/pipermail/r-sig-phylo/2010-September/000777.html),
and
>> it works with one troublesome exception: although the traits are ordered
to
>> match the tip.labels as they appear in the tree object (they were
>> matched by match.phylo.data, and row names definitely correspond), when
>> plotted next to the tree they don't match up, as the taxa in the plotted
>> tree are ordered differently to the tree object. Also, they're ordered
>> backwards—bottom to top—for some reason! How can I fix this? I suspect it
>> would require reordering the taxa in the tree and data files to match the
>> tip labels in the rendered phylogeny, but I can't figure out how to do
that.
>>
>> Here is my code:
>>
>> plot(tree, x.lim = 40, cex = 0.4) # <- adjust x.lim
>> offset <- 22 # <- adjust offset
>> barplot(c(NA, data$trait), add = TRUE, horiz = TRUE, space = 0, offset =
>> offset, axes = FALSE, axisnames = FALSE)
>> lab <- pretty(data$trait)
>> axis(1, lab + offset, labels = lab, cex.axis = 0.4, padj = 0)
>>
>> Any suggestions?
>>
>> Thanks in advance!
>> Roger
>>
>> ---
>> Roger Close
>> PhD Student
>> School of Geosciences
>> Monash University
>> Clayton 3800
>> Victoria, Australia
>>
>> email: roger.cl...@monash.edu
>> phone: +61423 131 176
>>
>> Research Collaborator
>> Department of Earth Sciences
>> University of Bristol
>> Queens Rd, Bristol BS8 1RJ
>> United Kingdom
>>
>>        [[alternative HTML version deleted]]
>>
>>
>> _______________________________________________
>> R-sig-phylo mailing list
>> R-sig-phylo@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
>>
>
>
>
> --
> David Bapst
> Dept of Geophysical Sciences
> University of Chicago
> 5734 S. Ellis
> Chicago, IL 60637
> http://home.uchicago.edu/~dwbapst/

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo

Reply via email to