plotCorrmatrix {growthPheno}R Documentation

Calculates and plots correlation matrices for a set of responses

Description

Having calculated the correlations a heat map indicating the magnitude of the correlations is produced using ggplot. In this heat map, the darker the red in a cell then the closer the correlation is to -1, while the deeper the blue in the cell, then the closer the correlation is to 1. A matrix plot of all pairwise combinations of the variables can be produced. The matrix plot contains a scatter diagram for each pair, as well as the value of the correlation coefficient. The argument pairs.sets can be used to restrict the pairs in the matrix plot to those combinations within each set.

Usage

plotCorrmatrix(data, responses, which.plots = c("heatmap","matrixplot"), 
               title = NULL, labels = NULL, labelSize = 4, pairs.sets = NULL, 
               show.sig = FALSE, axis.text.size = 20, ggplotFuncs = NULL, 
               printPlot = TRUE, ...)

Arguments

data

A data.frame containing the columns of variables to be correlated.

responses

A character giving the names of the columns in data containing the variables to be correlated.

which.plots

A character specifying the plots of the correlations to be produced. The possibilities are one or both of heatmap and matrixplot.

title

Title for the plots.

labels

A character specifying the labels to be used in the plots. If labels is NULL, responses is used for the labels.

labelSize

A numeric giving the size of the labels in the matrixplot.

pairs.sets

A list each of whose components is a numeric giving the position of the variable names in responses that are to be included in the set. All pairs of variables in this pairs.set will be included in a matrixplot.

show.sig

A logical indicating whether or not to give asterisks on the heatmap indicating the correlations are significantly different from zero.

axis.text.size

A numeric giving the size of the labels on the axes of the heatmap.

ggplotFuncs

A list, each element of which contains the results of evaluating a ggplot function. It is created by calling the list function with a ggplot function call for each element. These functions are applied in creating the ggplot object.

printPlot

A logical indicating whether or not to print the plot.

...

allows passing of arguments to other functions; not used at present.

Details

The correlations and their p-values are producced using rcorr from the Hmisc package. The heatmap is produced using ggplot and the matrixplot is produced using GGally.

Value

The heatmap plot, if produced, as an object of class "ggplot", which can be plotted using print; otherwise NULL is returned.

Author(s)

Chris Brien

See Also

rcorr, GGally, ggplot.

Examples


data(exampleData)
longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1)
longi.dat <- within(longi.dat, 
                    {
                      Max.Height <- pmax(Max.Dist.Above.Horizon.Line.SV1,  
                                         Max.Dist.Above.Horizon.Line.SV2)
                      Density <- PSA/Max.Height
                      PSA.SV = (PSA.SV1 + PSA.SV2) / 2
                      Image.Biomass = PSA.SV * (PSA.TV^0.5)
                      Centre.Mass <- (Center.Of.Mass.Y.SV1 + Center.Of.Mass.Y.SV2) / 2
                      Compactness.SV = (Compactness.SV1 + Compactness.SV2) / 2
                    })
responses <- c("PSA","PSA.SV","PSA.TV", "Image.Biomass", "Max.Height","Centre.Mass",
               "Density", "Compactness.TV", "Compactness.SV")
plotCorrmatrix(longi.dat, responses, pairs.sets=list(c(1:4),c(5:7)))


[Package growthPheno version 2.1.25 Index]