phylo.barplot: Plot a phylogenetic tree and associated barplot(s) based on...

View source: R/phylo.barplot.R

phylo.barplotR Documentation

Plot a phylogenetic tree and associated barplot(s) based on same species list

Description

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.

Usage

phylo.barplot(phylo,dat,SE=NULL,var.lab=NULL, ...)

Arguments

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

See Also

plot.phylo, se, barplot

Examples


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)



liuguofang/figsci documentation built on Nov. 24, 2023, 1:45 p.m.