plotPvalues.alldiffs | R Documentation |
Produces a heat-map plot of the p-values for pairwise differences between
predictions that is stored in the p.differences
component of an
all.diffs
object. This is generally a matrix whose rows and columns
are labelled by the levels of one or more factors, the set of labels being
the same for rows and columns. The sections
argument allows multiple
plots to be produced, one for each combination of the levels of the factors
listed in sections
. Otherwise, a single plot is produced for all
observed combinations of the levels of the factors in the classify
for the alldiffs.object
. The plots are produced using
plotPvalues.data.frame
. The order of plotting the levels of
one of the factors indexing the predictions can be modified using
sort.alldiffs
.
plotPvalues(object, ...)
## S3 method for class 'alldiffs'
plotPvalues(object, sections = NULL,
gridspacing = 0, factors.per.grid = 0,
show.sig = FALSE, alpha = 0.10,
sig.size = 3, sig.colour = "black",
sig.face = "plain", sig.family = "",
triangles = "both",
title = NULL, axis.labels = TRUE, axis.text.size = 12,
sep=",", colours = RColorBrewer::brewer.pal(3, "Set2"),
ggplotFuncs = NULL, printPlot = TRUE,
sortFactor = NULL, sortParallelToCombo = NULL,
sortNestingFactor = NULL, sortOrder = NULL,
decreasing = FALSE, ...)
object |
An |
sections |
A |
gridspacing |
A |
factors.per.grid |
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 |
sep |
A |
colours |
A vector of of colours to be passed to the |
ggplotFuncs |
A |
printPlot |
A |
sortFactor |
A |
sortParallelToCombo |
A |
sortNestingFactor |
A |
sortOrder |
A The following creates a |
decreasing |
A |
... |
Provision for passsing arguments to functions called internally - not used at present. |
A list
with components named pvalues
and plots
.
The pvalues
component contains the data.frame
with the columns Rows
,
Columns
, p
, sections1
and sections2
. This data.frame
is
formed using the sed
component of object
and is used by
plotPvalues.data.frame
in producng the plot. The plots
component contains a list of ggplot
objects, one for each plot produced.
Multiple plots are stored in the plots
component if the sections
argument
is set and the plots are are named for the levels combinations of the sections.
Chris Brien
plotPvalues.data.frame
, allDifferences.data.frame
,
sort.alldiffs
, subset.alldiffs
, ggplot
##Subset WaterRunoff data to reduce time to execute
data(WaterRunoff.dat)
tmp <- subset(WaterRunoff.dat, Date == "05-18" & Benches != "3")
##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)
TS.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"))
{
plotPvalues(TS.diffs, gridspacing = rep(c(3,4), c(4,2)), show.sig = TRUE)
plotPvalues(TS.diffs, sections = "Sources", show.sig = TRUE, axis.labels = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.