View source: R/phylo.barplot.R
phylo.barplot | R Documentation |
The function could be used as plotting a phylogenetic tree and associated with barplot. It is very convenient to visualize the traits on phylogenetic tree.
phylo.barplot(phylo,dat,SE=NULL,var.lab=NULL, ...)
phylo |
a phylogenetic tree.
dat |
a data.frame including continous traits
SE |
an associated barplot
with standard error (se
)
var.lab |
the labs of trait(s) used for a barplot
... |
further arguments passed to the plot.phylo
plot.phylo
, se
, barplot
library(ape)
tre
N <- length(tre$tip.label)
tre$tip.label <- paste(substr(tre$tip.label,1,1), substr(tre$tip.label,2,100), sep='')
# traits mean
set.seed(1)
traits <- data.frame(species = tre$tip.label, trt1 = runif(N, 0, 1), trt2 = runif(N,
0, 100))
# traits se
set.seed(1)
traits.se = data.frame(species = tre$tip.label, trt1 = runif(N, 0, 0.1), trt2 = runif(N,
0, 10))
head(traits.se)
# match dat according to species name
traits <- traits[match(tre$tip.label,traits$species),]
traits.se <- traits.se[match(tre$tip.label,traits.se$species),]
# two traits barplot and a phylogenetic tree
phylo.barplot(phylo=tre,dat=traits,SE=traits.se,var.lab=c("Trait 1","Trait 2"),cex=0.7)
traits2=traits[,1:2]
traits.se2=traits[,1:2]
# one trait barplot and a phylogenetic tree
phylo.barplot(phylo=tre,dat=traits2,SE=traits.se2,var.lab="Trait 1",cex=0.6)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.