{asremlPlus}R Documentation

Plots a heat map of p-values for pairwise differences between predictions.


Produces a heat-map plot of the p-values for pairwise differences between predictions that is in a data.frame. The data.frame includes two factors whose levels specify, for each p-value, which factor levels are being compared.


## S3 method for class 'data.frame'
plotPvalues(object, p = "p", x, y, 
            gridspacing = 0, show.sig = FALSE, triangles = "both", 
            title = NULL, axis.labels = NULL, 
            colours = RColorBrewer::brewer.pal(3, "Set2"), 
            ggplotFuncs = NULL, printPlot = TRUE, ...)



A data.frame containing the three columns specified by p, x and y.


A character giving the name of the column in object that contains the p-values to be plotted.


A character giving the name of the column in object that contains the factor whose levels index the p-values that are to be plotted in the same column.


A character giving the name of the column in object that contains the labels of the the p-values that are to be plotted as the rows.


A numeric specifying the number(s) of rows and columns that form groups in the grid of differences. This is most useful when two or more factors index the rows and columns. If a single, nonzero number, k say, is given then a grid line is placed after every kth row and column. If a vector of values is given then the number of grid lines is the length of the vector and the spacing between each is specified by the elements of the vector.


A logical that specifies whether asterisks indicating the level of significance are to be added to the plot. If they are then ‘***’ indicates that p <= 0.001, ‘**’ that 0.001 < p <= 0.01, ‘*’ that 0.01 < p <= 0.05 ‘.’ that 0.05 < p <= 0.10.


A character indicating whether the plot should include the lower, upper or both traingle(s). Here it is only used to adjust gridlines for the omission of the diagonal.


A character string giving the main title for the plot.


A character string giving the label to use for both the x- and y-axis.


A vector of of colours to be passed to the ggplot function scale\_colour\_gradientn.


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. It is passed to ggplot.


A logical indicating whether or not the a plot is to be printed. This would be used when just the returned ggplot object is required.


Provision for passsing arguments to functions called internally - not used at present.


An object of class "ggplot", which can be plotted using print or otherwise manipulated.


Chris Brien

See Also

plotPvalues.alldiffs,, ggplot


##Subset WaterRunoff data to reduce time to execute
tmp <- subset(WaterRunoff.dat, Date == "05-18")

##Use asreml to get predictions and associated statistics

## Not run: 
asreml.options(keep.order = TRUE) #required for asreml-R4 only
current.asr <- asreml(fixed = pH ~ Benches + (Sources * (Type + Species)), 
                      random = ~ Benches:MainPlots,
                      keep.order=TRUE, data= tmp))
current.asrt <- as.asrtests(current.asr, NULL, NULL)
SS.diffs <- predictPlus.asreml(classify = "Sources:Type", 
                               asreml.obj = current.asr, tables = "none", 
                      = current.asrt$, 
                               present = c("Type","Species","Sources"))

## End(Not run)

## Use lmeTest and emmmeans to get predictions and associated statistics

if (requireNamespace("lmerTest", quietly = TRUE) & 
    requireNamespace("emmeans", quietly = TRUE))
  m1.lmer <- lmerTest::lmer(pH ~ Benches + Sources * Species + 
  TS.emm <- emmeans::emmeans(m1.lmer, specs = ~ Sources:Species)
  TS.preds <- summary(TS.emm)
  den.df <- min(TS.preds$df, na.rm = TRUE)
  ## Modify TS.preds to be compatible with a predictions.frame
  TS.preds <- as.predictions.frame(TS.preds, predictions = "emmean", 
                                   se = "SE", interval.type = "CI", 
                                   interval.names = c("lower.CL", "upper.CL"))
  ## Form an all.diffs object and check its validity
  TS.vcov <- vcov(TS.emm)
  TS.diffs <- allDifferences(predictions = TS.preds, classify = "Sources:Species", 
                             vcov = TS.vcov, tdf = den.df)

## Plot p-values for predictions obtained using asreml or lmerTest
if (exists("TS.diffs"))
  p <- within(reshape::melt(TS.diffs$p.differences), 
                X1 <- factor(X1, levels=dimnames(TS.diffs$p.differences)[[1]])
                X2 <- factor(X2, levels=levels(X1))
  names(p)[match("value", names(p))] <- "p"
  plotPvalues(p, x = "X1", y = "X2", 
              gridspacing = rep(c(3,4), c(4,2)), show.sig = TRUE)

[Package asremlPlus version 4.2-32 Index]