growthPheno (version 1.0-13)

plotMedianDeviations: Calculates and plots the median of the deviations of the smoothed values from the observed values.

Description

Calculates and plots the median of the deviations of the supplied smoothed values from the supplied observed values for traits and combinations of different smoothing methods and smoothing degrees of freedom, possibly for subsets of factor combinations. The requisite values can be generated using probeSmoothing with both which.plots and deviations.plots set to none. The results of smoothing methods applied externally to growthPheno can be included via the extra.smooths argument. Envelopes of the median value of a trait for each factor combination can be added.

Usage

plotMedianDeviations(data, response, response.smoothed, 
                     x = NULL, xname="xDays", 
                     individuals = "Snapshot.ID.Tag",  
                     x.title = NULL, y.titles = NULL,
                     facet.x = "Treatment.1", facet.y = "Smarthouse", 
                     labeller = NULL, 
                     trait.types = c("response", "AGR", "RGR"), 
                     propn.types = c(0.1, 0.5, 0.75), propn.note = TRUE, 
                     alpha.med.devn = 0.5, 
                     smoothing.methods = "direct", df, extra.smooths = NULL, 
                     ggplotFuncsMedDevn = NULL, ...)

Arguments

data

A data.frame containing the observed and smoothed values from which the deviations are to be computed. There should be a column of smoothed values for each combination of smoothing.methods, df and the types specified by trait.types. In addition, there should be a column of values for each element of extra.smooths in combination with the elements of trait.types. Also, there should be a column of observed values for the types specified by trait.types

response

A character specifying the response variable for which the observed values are supplied. Depending on the setting of trait.types, the observed values of related trait.types may also need to be be supplied.

response.smoothed

A character specifying the name of the column containing the values of the smoothed response variable, corresponding to response and obtained for the combinations of smoothing.methods and df, usually using smoothing splines. Depending on the setting of trait.types, the smoothed values of related trait.types may also need to be be supplied.

x

A character giving the variable to be plotted on the x-axis; it may incorporate an expression. If x is NULL then xname is used.

xname

A character giving the name of the numeric that contains the values from which x is derived, it being that x may incorporate an expression.

individuals

A character giving the name(s) of the factor(s) that define the subsets of the data for which each subset corresponds to the response values for an individual.

x.title

Title for the x-axis. If NULL then set to xname.

y.titles

A character giving the titles for the y-axis, one for each trait specified by trait.types. If NULL then set to the traits derived for response from trait.types.

facet.x

A data.frame giving the variable to be used to form subsets to be plotted in separate columns of plots. Use "." if a split into columns is not wanted. For which.plots set to methodcompare or dfcompare facet.x is ignored.

facet.y

A data.frame giving the variable to be used to form subsets to be plotted in separate rows of plots. Use "." if a split into columns is not wanted.

labeller

A ggplot function for labelling the facets of a plot produced using the ggplot function. For more information see ggplot.

trait.types

A character giving the traits types that are to be plotted. While AGR and RGR are commonly used, the names can be arbitrary, except that response is a special case that indicates that the original response is to be plotted.

propn.types

A numeric giving the proportion of the medians the values of each of the trait.types that are to be plotted in the median deviations plots. If set to NULL, the plots of the proprotions are omitted.

propn.note

A logical indicating whether a note giving the proportion of the median values plotted in the compare.medians plots.

alpha.med.devn

A numeric specifying the degrees of transparency to be used in plotting a median deviations plot. It is a ratio in which the denominator specifies the number of points (or lines) that must be overplotted to give a solid cover.

smoothing.methods

A character giving one or more methods to use for smoothing. Currently, the two possibilites are (i) "direct", for directly smoothing the observed response, and (ii) "logarithmic", for smoothing the log-transformed response, followed by taking exponentials of the fitted values to back-trasnform them.

df

A numeric specifying the set of degrees of freedom to be probed.

extra.smooths

A character specifying a smoothing.method label that has been used in naming of columns of smooths of the response obtained by methods other than the smoothing spline methods provided by growthPheno. Depending on the setting of trait.types, the smoothed values of related trait types must also be supplied, with names constructed according to the convention described under data.

ggplotFuncsMedDevn

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.

...

allows passing of arguments to plotLongitudinal.

Value

A data.frame containing the median deviations that have been plotted.

See Also

plotDeviationsBoxes, probeSmoothing, ggplot.

Examples

Run this code
# NOT RUN {
data(exampleData)
vline <- list(ggplot2::geom_vline(xintercept=20, linetype="longdash", size=1),
              ggplot2::scale_x_continuous(breaks=seq(12, 36, by=2)))
traits <- probeSmoothing(data = longi.dat, response = "Area", 
                         df = c(4:7), x="xDays+24.16666667", 
                         facet.x = ".", facet.y = ".",
                         which.plots = "none",
                         deviations.plots = "none", 
                         propn.types = NULL)
med <- plotMedianDeviations(data = traits, 
                            response = "Area", response.smoothed = "Area.smooth", 
                            x="xDays+24.16666667", xname = "xDays", 
                            df = c(4,7), x.title = "DAP", 
                            facet.x = ".", facet.y = ".",
                            trait.types = "response", propn.types = 0.05,
                            ggplotFuncsMedDevn = vline)
# }

Run the code above in your browser using DataCamp Workspace