createQtlPlot: Create the QTL plot

Description Usage Arguments Value Usage Notes Examples

View source: R/functions.R

Description

Create the QTL plot

Usage

1
2
3
4
5
createQtlPlot(mcmcData, mcmcVar = Value, groupData,
  groupResponse = ObservedResponse, groupSize = N, groupType = NULL,
  basicTheme = ggplot2::theme_light, qtls = c(0.1, 0.2, 0.8, 0.9),
  postScaleFactor = NULL, mcmcAlpha = 0.2, nDensity = 512,
  xAxisRange = NULL)

Arguments

mcmcData

the tibble containing the posterior MCMC samples of the metric

mcmcVar

the column in mcmcData containing the sampled values of the metric

groupData

the tibble containing the observed group data

groupResponse

the column in groupData containing the observed by-group metric values

groupSize

the column in the groupData containing the group sizes

groupType

The column in groupData containing the group type for for the observation. If NULL, group types are not identified in the plot. Otherwise, groupType is converted to a factor and used as an aesthetic.

basicTheme

one of the themes provided by ggplot2, for example theme_light or theme_dark.

qtls

a list containing the quantiles that define the QTL thresholds. If NULL or of zero length, the QTL thresholds are not shown.

postScaleFactor

scales the posterior density relative to the height of the groupSize bars. If NULL, postScaleFactor is chosen so that the mode of the posterior is twice as high as the tallest group size bar. See Usage Notes below.

mcmcAlpha

the transparency of the fill used to indicate QTL bands

nDensity

the number of bins used to estimate the density. Must be a power of two. Normally, this can be left unchanged, but occasionally a different value is needed to correct visual artefacts related to the shading of the plot

xAxisRange

the range of the x-axis, as defined by a call to coord_cartesian(). NULL uses the default axis range.

Value

the QTL plot

Usage Notes

The plot returned by the function is deliberately crude: the x axis is unlabelled, the legends are unfomatted, and so on. However, it can be easily customised to include more appropriate titles, legends and so forth, as shown in the second example.

The scaled kernel estimate of the density is multiplied by postScaleFactor to obtain the curve shown in the plot. The height of the scaled kernel density at its mode is 1. Therefore, by default, postScaleFactor is set to twice the largest group size.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
b <- createBerryData() %>% 
       tibble::add_column(Region=as.factor(c(1,1,1,2,2,2,3,3,3)))
m <- fitBinomialModel(b$Subjects, b$Events) %>% dplyr::filter(Index==10)
createQtlPlot(groupData=b,
              groupResponse=ObservedResponse,
              groupSize=Subjects,
              groupType=Region,
              mcmcData=m,
              mcmcVar=Value) +
              ggplot2::scale_fill_manual(name="QTL",
                                         labels=c("Action low",
                                                  "Warn low",
                                                  "",
                                                  "Warn high",
                                                  "Action high"),
                                         values=c("red",
                                                  "yellow",
                                                  "white",
                                                  "yellow",
                                                  "red")) +
              ggplot2::scale_colour_manual(name="Region",
                                           values=1:3,
                                           labels=c("US",
                                                    "EMEA",
                                                    "Other")) +
              ggplot2::labs(x="Observed response",
                            title="Example QTL plot")

PuzzledFace/qtlr documentation built on March 19, 2020, 1:17 a.m.