plotPvalues.data.frame | R Documentation |
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, alpha = 0.10,
sig.size = 3, sig.colour = "black",
sig.face = "plain", sig.family = "",
triangles = "both",
title = NULL, axis.labels = NULL, axis.text.size = 12,
colours = RColorBrewer::brewer.pal(3, "Set2"),
ggplotFuncs = NULL, printPlot = TRUE, ...)
object |
A |
p |
A |
x |
A |
y |
A |
gridspacing |
A |
show.sig |
A |
alpha |
A |
sig.size |
A |
sig.colour |
A |
sig.face |
A |
sig.family |
A |
triangles |
A |
title |
A |
axis.labels |
A |
axis.text.size |
A |
colours |
A vector of of colours to be passed to the |
ggplotFuncs |
A |
printPlot |
A |
... |
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
plotPvalues.alldiffs
, allDifferences.data.frame
, ggplot
##Subset WaterRunoff data to reduce time to execute
data(WaterRunoff.dat)
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",
wald.tab = current.asrt$wald.tab,
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 * (Type + Species)) +
(1|Benches:MainPlots),
data=na.omit(WaterRunoff.dat))
TS.emm <- emmeans::emmeans(m1.lmer, specs = ~ Sources:Type)
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:Type",
vcov = TS.vcov, tdf = den.df)
validAlldiffs(TS.diffs)
}
## Plot p-values for predictions obtained using asreml or lmerTest
if (exists("TS.diffs"))
{
p <- within(reshape2::melt(TS.diffs$p.differences),
{
Var1 <- factor(Var1, levels=dimnames(TS.diffs$p.differences)[[1]])
Var2 <- factor(Var2, levels=levels(Var1))
})
names(p) <- c("Rows","Columns","p")
plotPvalues(p, x = "Rows", y = "Columns",
gridspacing = rep(c(3,4), c(4,2)), show.sig = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.