R code to draw simplex graphs
A few functions to draw simplex graphs and add data points.
The main functions are:
- simplexPlot
arguments include:
- plotData (default = 0): This should be a matrix or data.frame in which the first three columns represent the values for the upper vertex, the lower left vertex, and the lower right vertex, respectively.
- vertexlabels: a vector of three elements to label the three vertices (upper, lower left, lower right)
- drawLabels (default = FALSE): whether to draw the vertex labels or not
- cexLabels (default = .5): size to draw the vertex labels
- cexPoints (default = .1): size to draw the points
- main (default = ""): title of graph
- col (default = black): The color to paint the points
Example:
myData = matrix(c(0.9,0.1,0,.05,.9,.05), ncol=3, byrow=T)
simplexPlot(myData, cexPoints = .5, col="red", vertexLabels = c("A","B","C"), drawLabels = TRUE) - quartetPlot
An extension of simplexPlot designed to display concordance factors or posterior probabilities for the three topologies in phylogenetic studies of quartets. The display replaces the vertex labels with small tree diagrams. Arguments include:
- plotData: same as above, the column order of the data should be (12|34), (13|24), (14|23).
- binLabels (default NULL): A vector with labels for the four taxa. If provided, a legend is drawn to the upper left of the simplex.
- cexLabels (default = .7): the size of the legend text
- cexPoints (default = .1): same as above
- main (default = ""): same as above
- col (default = black): same as above
Example:
myData = matrix(c(0.9,0.1,0,.05,.9,.05), ncol=3, byrow=T)
quartetPlot(myData, cexPoints = .5, col="red", binLabels = c("outgroup","gorillas","humans","chimps")) - simplexPoints
This function adds points to an already drawn simplex plot. Arguments include:
- plotData: same as above.
- col: same as above.
- cexPoints: same as above.
Example:
myData = matrix(c(0.9,0.1,0,.05,.9,.05), ncol=3, byrow=T)
quartetPlot(0, binLabels = c("outgroup","gorillas","humans","chimps"))
simplexPoints(myData[1,,drop=F], col="red", cexPoints = 1)
simplexPoints(myData[2,,drop=F], col="blue", cexPoints = 1)