Title: | Functional Analysis of Phenotypic Growth Data to Smooth and Extract Traits |
---|---|
Description: | Assists in the plotting and functional smoothing of traits measured over time and the extraction of features from these traits, implementing the SET (Smoothing and Extraction of Traits) method described in Brien et al. (2020) Plant Methods, 16. Smoothing of growth trends for individual plants using natural cubic smoothing splines or P-splines is available for removing transient effects and segmented smoothing is available to deal with discontinuities in growth trends. There are graphical tools for assessing the adequacy of trait smoothing, both when using this and other packages, such as those that fit nonlinear growth models. A range of per-unit (plant, pot, plot) growth traits or features can be extracted from the data, including single time points, interval growth rates and other growth statistics, such as maximum growth or days to maximum growth. The package also has tools adapted to inputting data from high-throughput phenotyping facilities, such from a Lemna-Tec Scananalyzer 3D (see <https://www.youtube.com/watch?v=MRAF_mAEa7E/> for more information). The package 'growthPheno' can also be installed from <http://chris.brien.name/rpackages/>. |
Authors: | Chris Brien [aut, cre] |
Maintainer: | Chris Brien <[email protected]> |
License: | GPL (>=2) |
Version: | 2.1.26 |
Built: | 2024-11-07 02:57:12 UTC |
Source: | https://github.com/briencj/growthpheno |
Assists in the plotting and functional smoothing of traits measured over time and the extraction of features from these traits, implementing the SET (Smoothing and Extraction of Traits) method described in Brien et al. (2020) Plant Methods, 16. Smoothing of growth trends for individual plants using natural cubic smoothing splines or P-splines is available for removing transient effects and segmented smoothing is available to deal with discontinuities in growth trends. There are graphical tools for assessing the adequacy of trait smoothing, both when using this and other packages, such as those that fit nonlinear growth models. A range of per-unit (plant, pot, plot) growth traits or features can be extracted from the data, including single time points, interval growth rates and other growth statistics, such as maximum growth or days to maximum growth. The package also has tools adapted to inputting data from high-throughput phenotyping facilities, such from a Lemna-Tec Scananalyzer 3D (see <https://www.youtube.com/watch?v=MRAF_mAEa7E/> for more information). The package 'growthPheno' can also be installed from <http://chris.brien.name/rpackages/>.
Version: 2.1.26
Date: 2024-08-08
The following list of functions does not include those that are soft-deprecated, i.e. those that have been available in previous versions of growthPheno
but will be removed in future versions. For a description of the use of the listed functions and vignettes that are available, see the Overview section below.
(i) Wrapper functions | |
traitSmooth
|
Obtain smooths for a trait by fitting spline |
functions and, having compared several smooths, | |
allows one of them to be chosen and returned in | |
a data.frame . |
|
traitExtractFeatures
|
Extract features, that are single-valued for each |
individual, from smoothed traits over time. | |
(ii) Helper functions | |
args4chosen_plot
|
Creates a list of the values for the options of |
profile plots for the chosen smooth. | |
args4chosen_smooth
|
Creates a list of the values for the smoothing |
parameters for which a smooth is to be extracted. | |
args4meddevn_plot
|
Creates a list of the values for the options of |
median deviations plots for smooths. | |
args4profile_plot
|
Creates a list of the values for the options of |
profile plots for comparing smooths. | |
args4smoothing
|
Creates a list of the values for the smoothing |
parameters to be passed to a smoothing function. | |
(iii) Data | |
exampleData
|
A small data set to use in function examples. |
RicePrepped.dat
|
Prepped data from an experiment to investigate |
a rice germplasm panel. | |
RiceRaw.dat
|
Data for an experiment to investigate a rice |
germplasm panel. | |
tomato.dat
|
Longitudinal data for an experiment to investigate |
tomato response to mycorrhizal fungi and zinc. | |
(iv) Plots | |
plotAnom
|
Identifies anomalous individuals and produces |
profile plots without them and with just them. | |
plotCorrmatrix
|
Calculates and plots correlation matrices for a |
set of responses. | |
plotDeviationsBoxes
|
Produces boxplots of the deviations of the observed |
values from the smoothed values over values of x. | |
plotImagetimes
|
Plots the time within an interval versus the interval. |
For example, the hour of the day carts are imaged | |
against the days after planting (or some other | |
number of days after an event). | |
plotMedianDeviations
|
Calculates and plots the medians of the deviations |
of the smoothed values from the observed values. | |
plotProfiles
|
Produces profile plots of longitudinal data for a set |
of individuals. | |
plotSmoothsComparison
|
Plots several sets of smoothed values for a response, |
possibly along with growth rates and optionally including | |
the unsmoothed values, as well as deviations boxplots. | |
plotSmoothsMedianDevns
|
Calculates and plots the medians of the deviations |
from the observed values of several sets for smoothed | |
values stored in a data.frame in long format. |
|
probeSmooths
|
Computes and compares, for a set of smoothing parameters, |
a response and the smooths of it, possibly along with | |
growth rates calculated from the smooths. | |
(v) Smoothing and calculation | |
of growth rates and water use traits | |
for each individual (Indv) | |
byIndv4Intvl_GRsAvg
|
Calculates the growth rates for a specified |
time interval for individuals in a data.frame in |
|
long format by taking weighted averages of growth | |
rates for times within the interval. | |
byIndv4Intvl_GRsDiff
|
Calculates the growth rates for a specified |
time interval for individuals in a data.frame in |
|
long format by differencing the values for | |
a response within the interval. | |
byIndv4Intvl_ValueCalc
|
Calculates a single value that is a function of |
the values of an individual for a response in a | |
data.frame in long format over a specified |
|
time interval. | |
byIndv4Intvl_WaterUse
|
Calculates, water use traits (WU, WUR, WUI) over a |
specified time interval for each individual in a | |
data.frame in long format. |
|
byIndv4Times_GRsDiff
|
Adds, to a 'data.frame', the growth rates |
calculated for consecutive times for individuals in | |
a data.frame in long format by differencing |
|
response values. | |
byIndv4Times_SplinesGRs
|
For a response in a data.frame in long format, |
computes, for a single set of smoothing parameters, | |
smooths of the response, possibly along with | |
growth rates calculated from the smooths. | |
byIndv_ValueCalc
|
Applies a function to calculate a single value from |
an individual's values for a response in a data.frame in |
|
long format. | |
smoothSpline
|
Fit a spline to smooth the relationship between a |
response and an x in a data.frame , |
|
optionally computing growth rates using derivatives. | |
probeSmooths
|
For a response in a data.frame in long format, computes and |
compares, for sets of smoothing parameters, smooths | |
of the response, possibly along with growth rates | |
calculated from the smooths. | |
(vi) Data frame manipulation | |
as.smooths.frame
|
Forms a smooths.frame from a data.frame , |
ensuring that the correct columns are present. | |
designFactors
|
Adds the factors and covariates for a blocked, |
split-unit design. | |
getTimesSubset
|
Forms a subset of 'responses' in 'data' that |
contains their values for the nominated times. | |
importExcel
|
Imports an Excel imaging file and allows some |
renaming of variables. | |
is.smooths.frame
|
Tests whether an object is of class smooths.frame. |
prepImageData
|
Selects a set variables to be retained in a |
data frame of longitudinal data. | |
smooths.frame
|
Description of a smooths.frame object, |
twoLevelOpcreate
|
Creates a data.frame formed by applying, for |
each response, a binary operation to the values of | |
two different treatments. | |
validSmoothsFrame
|
Checks that an object is a valid smooths.frame . |
(vii) General calculations | |
anom
|
Tests if any values in a vector are anomalous |
in being outside specified limits. | |
calcLagged
|
Replaces the values in a vector with the result |
of applying an operation to it and a lagged value. | |
calcTimes
|
Calculates for a set of times, the time intervals |
after an origin time and the position of each | |
within a time interval | |
cumulate
|
Calculates the cumulative sum, ignoring the |
first element if exclude.1st is TRUE. | |
GrowthRates
|
Calculates growth rates (AGR, PGR, RGRdiff) |
between a pair of values in a vector. | |
WUI
|
Calculates the Water Use Index (WUI) for a value |
of the response and of the water use. | |
(viii) Principal variates analysis (PVA) | |
intervalPVA.data.frame
|
Selects a subset of variables using PVA, based on |
the observed values within a specified time interval | |
PVA.data.frame
|
Selects a subset of variables stored in a data.frame |
using PVA. | |
PVA.matrix
|
Selects a subset of variables using PVA based on a |
correlation matrix. | |
rcontrib.data.frame
|
Computes a measure of how correlated each |
variable in a set is with the other variable, | |
conditional on a nominated subset of them. | |
rcontrib.matrix
|
Computes a measure of how correlated each |
variable in a set is with the other variable, | |
conditional on a nominated subset of them. | |
This package can be used to perform a functional analysis of growth data using splines to smooth the trend of individual plant traces over time and then to extract features or tertiarty traits for further analysis. This process is called smoothing and extraction
of traits (SET) by Brien et al. (2020), who detail the use of growthPheno
for carrying out the method. However, growthPheno
now has the two wrapper, or primary, functions traitSmooth
and traitExtractFeatures
that implement the SET approach. These may be the only functions that are used in that the complete SET process can be carried out using only them. The Tomato
vignette illustrates their use for the example presented in Brien et al. (2020).
The function traitSmooth
utilizes the secondary functions probeSmooths
, plotSmoothsComparison
and plotSmoothsMedianDevns
and accepts the arguments of the secondary functions. The function probeSmooths
utilizes the tertiary functions byIndv4Times_SplinesGRs
and byIndv4Times_GRsDiff
, which in turn call the function smoothSpline
. The function plotSmoothsComparison
calls plotDeviationsBoxes
. All of these functions play a role in choosing the smoothing method and parameters for a data set.
The primary function traitExtractFeatures
uses the secondary functions getTimesSubset
and the set of byIndv4Intvl_
functions. These functions are concerned with the extraction of traits that yield a single value for each individual in the data.
Recourse to the secondary and terriary functions may be necessary for special cases. Their use is illustrated in the Rice
vignette.
Use vignette("Tomato", package = "growthPheno")
or vignette("Rice", package = "growthPheno")
to access either of the vignettes.
In addition to functions that implement SET approach, growthPheno
also has functions for importing and organizing the data that are generally applicable, although they do have defaults that make them particularly adapted to data from a high-throughput phenotyping facility based on a Lemna-Tec Scananalyzer 3D system.
Data suitable for use with this package consists of columns of data obtained from a set of individuals (e.g. plants, pots, carts, plots or units) over time. There should be a unique identifier for each individual and a time variable, such as Days after Planting (DAP), that contain no repeats for an individual. The combination of the identifier and a time for an individual should be unique to that individual. For imaging data, the individuals may be arranged in a grid of Lanes Positions. That is, the minimum set of columns is an individuals, a times and one or more primary trait columns.
Chris Brien [aut, cre] (<https://orcid.org/0000-0003-0581-1817>)
Maintainer: Chris Brien <[email protected]>
Brien, C., Jewell, N., Garnett, T., Watts-Williams, S. J., & Berger, B. (2020). Smoothing and extraction of traits in the growth analysis of noninvasive phenotypic data. Plant Methods, 16, 36. doi:10.1186/s13007-020-00577-6.
Test whether any values in x
are less than the value of
lower
, if it is not NULL
, or are greater than the
value of upper
, if it is not NULL
, or both.
anom(x, lower=NULL, upper=NULL, na.rm = TRUE)
anom(x, lower=NULL, upper=NULL, na.rm = TRUE)
x |
A |
lower |
A |
upper |
A |
na.rm |
A |
A logical
indicating whether any values have been found to
be outside the limits specified by lower
or upper
or both.
Chris Brien
data(exampleData) anom.val <- anom(longi.dat$sPSA.AGR, lower=2.5)
data(exampleData) anom.val <- anom(longi.dat$sPSA.AGR, lower=2.5)
list
of the values for the options of profile plots for the chosen smoothCreates a list
of the values for the options of profile plots (and boxplots facets) for comparing smooths.
Note that plots.by
, facet.x
, facet.y
and include.raw
jointly
define the organization of the plots. The default settings are optimized for traitSmooth
.
args4chosen_plot(plots.by = NULL, facet.x = ".", facet.y = ".", include.raw = "no", collapse.facets.x = FALSE, collapse.facets.y = FALSE, facet.labeller = NULL, facet.scales = "fixed", breaks.spacing.x = -2, angle.x = 0, colour = "black", colour.column = NULL, colour.values = NULL, alpha = 0.3, addMediansWhiskers = TRUE, ggplotFuncs = NULL, ...)
args4chosen_plot(plots.by = NULL, facet.x = ".", facet.y = ".", include.raw = "no", collapse.facets.x = FALSE, collapse.facets.y = FALSE, facet.labeller = NULL, facet.scales = "fixed", breaks.spacing.x = -2, angle.x = 0, colour = "black", colour.column = NULL, colour.values = NULL, alpha = 0.3, addMediansWhiskers = TRUE, ggplotFuncs = NULL, ...)
plots.by |
A |
facet.x |
A |
facet.y |
A |
include.raw |
A |
collapse.facets.x |
A |
collapse.facets.y |
A |
facet.labeller |
A |
facet.scales |
A |
breaks.spacing.x |
A |
angle.x |
A |
colour |
A |
colour.column |
A |
colour.values |
A |
alpha |
A |
addMediansWhiskers |
A |
ggplotFuncs |
A |
... |
allows arguments to be passed to other functions; not used at present. |
A named list
.
Chris Brien
traitSmooth
, probeSmooths
, plotSmoothsComparison
and args4profile_plot
.
args4chosen_plot(plots.by = "Type", facet.x = "Tuning", facet.y = c("Smarthouse", "Treatment.1"), include.raw = "facet.x", alpha = 0.4, colour.column = "Method", colour.values = c("orange", "olivedrab"))
args4chosen_plot(plots.by = "Type", facet.x = "Tuning", facet.y = c("Smarthouse", "Treatment.1"), include.raw = "facet.x", alpha = 0.4, colour.column = "Method", colour.values = c("orange", "olivedrab"))
list
of the values for the smoothing parameters for
which a smooth is to be extractedCreates a list
of the values for the smoothing parameters for
which a smooth is to be extracted.
The default settings for these are optimized for traitSmooth
.
args4chosen_smooth(smoothing.methods = "logarithmic", spline.types = "PS", df = NULL, lambdas = NULL, combinations = "single")
args4chosen_smooth(smoothing.methods = "logarithmic", spline.types = "PS", df = NULL, lambdas = NULL, combinations = "single")
smoothing.methods |
A |
spline.types |
A |
df |
A |
lambdas |
A named |
combinations |
Generally, this argument should be set to |
A named list
.
Chris Brien
traitSmooth
and probeSmooths
.
args4chosen_smooth(smoothing.methods = "direct", spline.types = "NCSS", df = 4) args4chosen_smooth(smoothing.methods = "log", spline.types = "PS", lambdas = 0.36)
args4chosen_smooth(smoothing.methods = "direct", spline.types = "NCSS", df = 4) args4chosen_smooth(smoothing.methods = "log", spline.types = "PS", lambdas = 0.36)
list
of the values for the options of profile plots for comparing smoothsCreates a list
of the values for the options of deviations boxplots for comparing smooths.
Note that plots.by
, facet.x
and facet.y
jointly
define the organization of the plots. The default settings are optimized for traitSmooth
so that,
if you want to change any of these from their default settings when using args4devnboxes_plot
with a function
other than traitSmooth
, then it is recommended that you specify all of them to ensure that the complete set
has been correctly specified. Otherwise, the default settings will be those shown here and these may be different to the
default settings shown for the function with which you are using args4devnboxes_plot
.
args4devnboxes_plot(plots.by = "Type", facet.x = c("Method", "Tuning"), facet.y = ".", collapse.facets.x = TRUE, collapse.facets.y = FALSE, facet.labeller = NULL, facet.scales = "fixed", angle.x = 0, which.plots = "none", ggplotFuncs = NULL, ...)
args4devnboxes_plot(plots.by = "Type", facet.x = c("Method", "Tuning"), facet.y = ".", collapse.facets.x = TRUE, collapse.facets.y = FALSE, facet.labeller = NULL, facet.scales = "fixed", angle.x = 0, which.plots = "none", ggplotFuncs = NULL, ...)
plots.by |
A |
facet.x |
A |
facet.y |
A |
collapse.facets.x |
A |
collapse.facets.y |
A |
facet.labeller |
A |
facet.scales |
A |
angle.x |
A |
which.plots |
A |
ggplotFuncs |
A |
... |
allows arguments to be passed to other functions; not used at present. |
A named list
.
Chris Brien
traitSmooth
, probeSmooths
, plotSmoothsComparison
and args4chosen_plot
.
args4devnboxes_plot(plots.by = "Type", facet.x = "Tuning", facet.y = c("Smarthouse", "Treatment.1"), which.plots = "absolute")
args4devnboxes_plot(plots.by = "Type", facet.x = "Tuning", facet.y = c("Smarthouse", "Treatment.1"), which.plots = "absolute")
list
of the values for the options of median deviations plots for smoothsCreates a list
of the values for the options of median deviations plots for smooths.
Note that the arguments plots.by
, plots.group
, facet.x
and facet.y
jointly define the organization of the plots. The default settings are optimized for traitSmooth
so that,
if you want to change any of these from their default settings when using args4meddevn_plot
with a function
other than traitSmooth
, then it is recommended that you specify all of them to ensure that the complete set
has been correctly specified. Otherwise, the default settings will be those shown here and these may be different to the
default settings shown for the function with which you are using args4meddevn_plot
.
args4meddevn_plot(plots.by = NULL, plots.group = "Tuning", facet.x = c("Method","Type"), facet.y = ".", facet.labeller = NULL, facet.scales = "free_x", breaks.spacing.x = -4, angle.x = 0, colour.values = NULL, shape.values = NULL, alpha = 0.5, propn.note = TRUE, propn.types = NULL, ggplotFuncs = NULL, ...)
args4meddevn_plot(plots.by = NULL, plots.group = "Tuning", facet.x = c("Method","Type"), facet.y = ".", facet.labeller = NULL, facet.scales = "free_x", breaks.spacing.x = -4, angle.x = 0, colour.values = NULL, shape.values = NULL, alpha = 0.5, propn.note = TRUE, propn.types = NULL, ggplotFuncs = NULL, ...)
plots.by |
A |
plots.group |
A |
facet.x |
A |
facet.y |
A |
facet.labeller |
A |
facet.scales |
A |
breaks.spacing.x |
A |
angle.x |
A |
colour.values |
A |
shape.values |
A |
alpha |
A |
propn.note |
A |
propn.types |
A |
ggplotFuncs |
A |
... |
allows arguments to be passed to other functions; not used at present. |
A named list
.
Chris Brien
traitSmooth
, probeSmooths
and plotSmoothsMedianDevns
.
args4meddevn_plot(plots.by = "Type", plots.group = "Tuning", facet.x = "Method", facet.y = ".", propn.types = c(0.02,0.1, 0.2))
args4meddevn_plot(plots.by = "Type", plots.group = "Tuning", facet.x = "Method", facet.y = ".", propn.types = c(0.02,0.1, 0.2))
list
of the values for the options of profile plots for comparing smoothsCreates a list
of the values for the options of profile plots for comparing smooths.
Note that plots.by
, facet.x
, facet.y
and include.raw
jointly
define the organization of the plots. The default settings are optimized for traitSmooth
so that,
if you want to change any of these from their default settings when using args4profile_plot
with a function
other than traitSmooth
, then it is recommended that you specify all of them to ensure that the complete set
has been correctly specified. Otherwise, the default settings will be those shown here and these may be different to the
default settings shown for the function with which you are using args4profile_plot
.
args4profile_plot(plots.by = "Type", facet.x = c("Method", "Tuning"), facet.y = ".", include.raw = "facet.x", collapse.facets.x = TRUE, collapse.facets.y = FALSE, facet.labeller = NULL, facet.scales = "fixed", breaks.spacing.x = -4, angle.x = 0, colour = "black", colour.column = NULL, colour.values = NULL, alpha = 0.3, addMediansWhiskers = TRUE, ggplotFuncs = NULL, ...)
args4profile_plot(plots.by = "Type", facet.x = c("Method", "Tuning"), facet.y = ".", include.raw = "facet.x", collapse.facets.x = TRUE, collapse.facets.y = FALSE, facet.labeller = NULL, facet.scales = "fixed", breaks.spacing.x = -4, angle.x = 0, colour = "black", colour.column = NULL, colour.values = NULL, alpha = 0.3, addMediansWhiskers = TRUE, ggplotFuncs = NULL, ...)
plots.by |
A |
facet.x |
A |
facet.y |
A |
include.raw |
A |
collapse.facets.x |
A |
collapse.facets.y |
A |
facet.labeller |
A |
facet.scales |
A |
breaks.spacing.x |
A |
angle.x |
A |
colour |
A |
colour.column |
A |
colour.values |
A |
alpha |
A |
addMediansWhiskers |
A |
ggplotFuncs |
A |
... |
allows arguments to be passed to other functions; not used at present. |
A named list
.
Chris Brien
traitSmooth
, probeSmooths
, plotSmoothsComparison
and args4chosen_plot
.
args4profile_plot(plots.by = "Type", facet.x = "Tuning", facet.y = c("Smarthouse", "Treatment.1"), include.raw = "facet.x", alpha = 0.4, colour.column = "Method", colour.values = c("orange", "olivedrab"))
args4profile_plot(plots.by = "Type", facet.x = "Tuning", facet.y = c("Smarthouse", "Treatment.1"), include.raw = "facet.x", alpha = 0.4, colour.column = "Method", colour.values = c("orange", "olivedrab"))
list
of the values for the smoothing parameters to be passed to a smoothing functionCreates a list
of the values for the smoothing parameters to be
passed to a smoothing function. Note that smoothing.methods
,
spline.types
, df
and lambdas
are combined to define the
set of smooths. The default settings are optimized for traitSmooth
so that,
if you want to change any of these from their default settings when using args4smoothing
with a function
other than traitSmooth
, then it is recommended that you specify all of them to ensure that the complete set
has been correctly specified. Otherwise, the default settings will be those shown here and these may be different to the
default settings shown for the function with which you are using args4smoothing
.
args4smoothing(smoothing.methods = "logarithmic", spline.types = c("NCSS","PS"), df = 5:7, lambdas = list(PS = round(10^c(-0.5, 0, 0.5, 1), digits = 3)), smoothing.segments = NULL, npspline.segments = NULL, na.x.action="exclude", na.y.action = "trimx", external.smooths = NULL, correctBoundaries = FALSE, combinations = "allvalid", ...)
args4smoothing(smoothing.methods = "logarithmic", spline.types = c("NCSS","PS"), df = 5:7, lambdas = list(PS = round(10^c(-0.5, 0, 0.5, 1), digits = 3)), smoothing.segments = NULL, npspline.segments = NULL, na.x.action="exclude", na.y.action = "trimx", external.smooths = NULL, correctBoundaries = FALSE, combinations = "allvalid", ...)
smoothing.methods |
A |
spline.types |
A |
df |
A |
lambdas |
A named |
smoothing.segments |
A named |
npspline.segments |
A |
na.x.action |
A |
na.y.action |
A |
external.smooths |
A The growth rates will be computed by differencing according to the settings of
|
correctBoundaries |
A |
combinations |
A The option The option |
... |
allows arguments to be passed to other functions; not used at present. |
A named list
.
Chris Brien
traitSmooth
and probeSmooths
.
args4smoothing(smoothing.methods = "direct", spline.types = "NCSS", df = NULL, lambdas = NULL, smoothing.segments = NULL, npspline.segments = NULL, combinations = "allvalid") args4smoothing(smoothing.methods = c("log","dir","log"), spline.types = c("NCSS","NCSS","PS"), df = c(4,5,NA), lambdas = c(NA,NA,0.36), combinations = "parallel") args4smoothing(smoothing.methods = "log", spline.types = "PS", df = NULL, lambdas = 0.36, combinations = "single")
args4smoothing(smoothing.methods = "direct", spline.types = "NCSS", df = NULL, lambdas = NULL, smoothing.segments = NULL, npspline.segments = NULL, combinations = "allvalid") args4smoothing(smoothing.methods = c("log","dir","log"), spline.types = c("NCSS","NCSS","PS"), df = c(4,5,NA), lambdas = c(NA,NA,0.36), combinations = "parallel") args4smoothing(smoothing.methods = "log", spline.types = "PS", df = NULL, lambdas = 0.36, combinations = "single")
smooths.frame
from a data.frame
, ensuring that the correct
columns are present.Creates a smooths.frame
from a data.frame
by adding the
class
smooths.frame
and a set of attributes
to it.
as.smooths.frame(data, individuals = NULL, times = NULL)
as.smooths.frame(data, individuals = NULL, times = NULL)
data |
A |
individuals |
A |
times |
A |
Chris Brien
validSmoothsFrame
, as.smooths.frame
dat <- read.table(header = TRUE, text = " Type TunePar TuneVal Tuning Method ID DAP PSA sPSA NCSS df 4 df-4 direct 045451-C 28 57.446 51.18456 NCSS df 4 df-4 direct 045451-C 30 89.306 87.67343 NCSS df 7 df-7 direct 045451-C 28 57.446 57.01589 NCSS df 7 df-7 direct 045451-C 30 89.306 87.01316 ") dat[1:7] <- lapply(dat[1:6], factor) dat <- as.smooths.frame(dat, individuals = "ID", times = "DAP") is.smooths.frame(dat) validSmoothsFrame(dat)
dat <- read.table(header = TRUE, text = " Type TunePar TuneVal Tuning Method ID DAP PSA sPSA NCSS df 4 df-4 direct 045451-C 28 57.446 51.18456 NCSS df 4 df-4 direct 045451-C 30 89.306 87.67343 NCSS df 7 df-7 direct 045451-C 28 57.446 57.01589 NCSS df 7 df-7 direct 045451-C 30 89.306 87.01316 ") dat[1:7] <- lapply(dat[1:6], factor) dat <- as.smooths.frame(dat, individuals = "ID", times = "DAP") is.smooths.frame(dat) validSmoothsFrame(dat)
Applies a function
to calculate a single value from
an individual's values for a response in a data.frame
in
long format.
It includes the ability to calculate the observation number
that is closest to the calculated value of the function and
the assocated values of a factor
or numeric
.
byIndv_ValueCalc(data, response, individuals = "Snapshot.ID.Tag", FUN = "max", which.obs = FALSE, which.values = NULL, addFUN2name = TRUE, sep.FUNname = ".", weights = NULL, na.rm=TRUE, sep.levels = ".", ...)
byIndv_ValueCalc(data, response, individuals = "Snapshot.ID.Tag", FUN = "max", which.obs = FALSE, which.values = NULL, addFUN2name = TRUE, sep.FUNname = ".", weights = NULL, na.rm=TRUE, sep.levels = ".", ...)
data |
A |
response |
A |
individuals |
A |
FUN |
A |
which.obs |
A |
which.values |
A |
addFUN2name |
A |
sep.FUNname |
A |
weights |
A |
na.rm |
A |
sep.levels |
A |
... |
allows for arguments to be passed to |
A data.frame
, with the same number of rows as there are
individuals
, containing a column for the individuals
and
a column with the values of the function for the individuals
.
It is also possible to determine observaton numbers or the values of
another column in data
for the response
values that are
closest to the FUN
results, using either or both of
which.obs
and which.values
. If which.obs
is
TRUE
, a column with observation numbers is included in the
data.frame
.
If which.values
is set to the name of a factor
or
a numeric
,a column containing the levels of that
factor
or the values of that numeric
is
included in the data.frame
.
The name of the column with the values of the function will be formed by
concatenating the response
and FUN
, separated by a full stop.
If which.obs
is TRUE
, the column name for the obervations
numbers will have .obs
added after FUN
into the column name
for the function values; if which.values
is specified,
the column name for these values will have a full stop followed by
which.values
added after FUN
into the column name
for the function values.
Chris Brien
byIndv4Intvl_ValueCalc
, byIndv4Times_GRsDiff
,
byIndv4Times_SplinesGRs
data(exampleData) sPSA.max.dat <- byIndv_ValueCalc(data=longi.dat, response = "PSA") AGR.max.dat <- byIndv_ValueCalc(data=longi.dat, response = "sPSA.AGR", FUN="max", which.values = "DAP", which.obs = TRUE) sPSA.dec1.dat <- byIndv_ValueCalc(data=longi.dat, response = "sPSA", FUN="quantile", which.values = "DAP", probs = 0.1)
data(exampleData) sPSA.max.dat <- byIndv_ValueCalc(data=longi.dat, response = "PSA") AGR.max.dat <- byIndv_ValueCalc(data=longi.dat, response = "sPSA.AGR", FUN="max", which.values = "DAP", which.obs = TRUE) sPSA.dec1.dat <- byIndv_ValueCalc(data=longi.dat, response = "sPSA", FUN="quantile", which.values = "DAP", probs = 0.1)
data.frame
in long format by taking weighted averages of
growth rates for times within the interval.Using previously calculated growth rates over time, calculates the Absolute Growth Rates for a specified interval using the weighted averages of AGRs for each time point in the interval (AGR) and the Relative Growth Rates for a specified interval using the weighted geometric means of RGRs for each time point in the interval (RGR).
byIndv4Intvl_GRsAvg(data, responses, individuals = "Snapshot.ID.Tag", times = "DAP", which.rates = c("AGR","RGR"), suffices.rates=c("AGR","RGR"), sep.rates = ".", start.time, end.time, suffix.interval, sep.suffix.interval = ".", sep.levels=".", na.rm=FALSE)
byIndv4Intvl_GRsAvg(data, responses, individuals = "Snapshot.ID.Tag", times = "DAP", which.rates = c("AGR","RGR"), suffices.rates=c("AGR","RGR"), sep.rates = ".", start.time, end.time, suffix.interval, sep.suffix.interval = ".", sep.levels=".", na.rm=FALSE)
data |
A |
responses |
A |
individuals |
A |
times |
A |
which.rates |
A |
suffices.rates |
A |
sep.rates |
A |
start.time |
A |
end.time |
A |
suffix.interval |
A |
sep.suffix.interval |
A |
sep.levels |
A |
na.rm |
A |
The AGR
for an interval is calculated as the weighted mean of the
AGRs for times within the interval. The RGR is calculated as the weighted
geometric mean of the RGRs for times within the interval; in fact the exponential is taken of the weighted means of the logs of the RGRs. The weights are
obtained from the times
. They are taken as the sum of half the time subintervals before and after each time, except for the end points; the end points are taken to be the subintervals at the start and end of the interval.
A data.frame
with the growth rates.
The name of each column is the concatenation of (i) one of
responses
, (ii) one of AGR
, PGR
or RGR
,
or the appropriate element of suffices.rates
, and (iii)
suffix.interval
, the three components being separated by
full stops.
Chris Brien
byIndv4Intvl_GRsDiff
, byIndv4Intvl_WaterUse
, splitValueCalculate
, getTimesSubset
, GrowthRates
, byIndv4Times_SplinesGRs
, splitContGRdiff
data(exampleData) longi.dat <- byIndv4Times_SplinesGRs(data = longi.dat, response="PSA", response.smoothed = "sPSA", individuals = "Snapshot.ID.Tag", times = "DAP", df = 4, rates.method = "deriv", which.rates = c("AGR", "RGR"), suffices.rates = c("AGRdv", "RGRdv")) sPSA.GR <- byIndv4Intvl_GRsAvg(data = longi.dat, response="sPSA", times = "DAP", which.rates = c("AGR","RGR"), suffices.rates = c("AGRdv","RGRdv"), start.time = 31, end.time = 35, suffix.interval = "31to35")
data(exampleData) longi.dat <- byIndv4Times_SplinesGRs(data = longi.dat, response="PSA", response.smoothed = "sPSA", individuals = "Snapshot.ID.Tag", times = "DAP", df = 4, rates.method = "deriv", which.rates = c("AGR", "RGR"), suffices.rates = c("AGRdv", "RGRdv")) sPSA.GR <- byIndv4Intvl_GRsAvg(data = longi.dat, response="sPSA", times = "DAP", which.rates = c("AGR","RGR"), suffices.rates = c("AGRdv","RGRdv"), start.time = 31, end.time = 35, suffix.interval = "31to35")
data.frame
in long format by differencing the values for
a response within the interval.Using the values of the responses, calculates the specified combination of the Absolute Growth Rates using differences (AGR), the Proportionate Growth Rates (PGR) and Relative Growth Rates using log differences (RGR) between two nominated time points.
byIndv4Intvl_GRsDiff(data, responses, individuals = "Snapshot.ID.Tag", times = "DAP", which.rates = c("AGR","PGR","RGR"), suffices.rates=NULL, sep.rates = ".", start.time, end.time, suffix.interval, sep.suffix.interval = ".")
byIndv4Intvl_GRsDiff(data, responses, individuals = "Snapshot.ID.Tag", times = "DAP", which.rates = c("AGR","PGR","RGR"), suffices.rates=NULL, sep.rates = ".", start.time, end.time, suffix.interval, sep.suffix.interval = ".")
data |
A |
responses |
A |
individuals |
A |
times |
A |
which.rates |
A |
suffices.rates |
A |
sep.rates |
A |
start.time |
A |
end.time |
A |
suffix.interval |
A |
sep.suffix.interval |
A |
The AGR
is calculated as the difference between the values of
response
at the end.time
and start.time
divided by the
difference between end.time
and start.time
.
The PGR is calculated as the ratio of response
at the end.time
to that at start.time
and the ratio raised to the power of the
reciprocal of the difference between end.time
and start.time
.
The RGR
is calculated as the log
of the PGR and so is equal to
the difference between the logarithms of response
at the end.time
and start.time
divided by the difference
between end.time
and start.time
.
A data.frame
with the growth rates.
The name of each column is the concatenation of (i) one of
responses
, (ii) one of AGR
, PGR
or RGR
,
or the appropriate element of suffices.rates
, and (iii)
suffix.interval
, the three components being separated by
full stops.
Chris Brien
byIndv4Intvl_GRsAvg
, byIndv4Intvl_WaterUse
, getTimesSubset
, GrowthRates
, byIndv4Times_SplinesGRs
, splitContGRdiff
data(exampleData) sPSA.GR <- byIndv4Intvl_GRsDiff(data = longi.dat, responses = "sPSA", times = "DAP", which.rates = c("AGR","RGR"), start.time = 31, end.time = 35, suffix.interval = "31to35")
data(exampleData) sPSA.GR <- byIndv4Intvl_GRsDiff(data = longi.dat, responses = "sPSA", times = "DAP", which.rates = c("AGR","RGR"), start.time = 31, end.time = 35, suffix.interval = "31to35")
function
of the values of
an individual for a response in a data.frame
in long format
over a specified time interval.Splits the values of a response into subsets corresponding
individuals and applies a function that calculates a single
value from each individual's observations during a specified
time interval. It includes the ability to calculate the
observation number that is closest to the calculated value of
the function and the assocated values of a factor
or
numeric
.
byIndv4Intvl_ValueCalc(data, response, individuals = "Snapshot.ID.Tag", times = "DAP", FUN = "max", which.obs = FALSE, which.values = NULL, addFUN2name = TRUE, sep.FUNname = ".", start.time=NULL, end.time=NULL, suffix.interval=NULL, sep.suffix.interval = ".", sep.levels=".", weights=NULL, na.rm=TRUE, ...)
byIndv4Intvl_ValueCalc(data, response, individuals = "Snapshot.ID.Tag", times = "DAP", FUN = "max", which.obs = FALSE, which.values = NULL, addFUN2name = TRUE, sep.FUNname = ".", start.time=NULL, end.time=NULL, suffix.interval=NULL, sep.suffix.interval = ".", sep.levels=".", weights=NULL, na.rm=TRUE, ...)
data |
A |
response |
A |
individuals |
A |
times |
A |
FUN |
A |
which.obs |
A |
which.values |
A |
addFUN2name |
A |
sep.FUNname |
A |
start.time |
A |
end.time |
A |
suffix.interval |
A |
sep.suffix.interval |
A |
sep.levels |
A |
weights |
A |
na.rm |
A |
... |
allows for arguments to be passed to |
A data.frame
, with the same number of rows as there are
individuals
, containing a column for the individuals
and
a column with the values of the function for the individuals
.
It is also possible to determine observaton numbers or the values of
another column in data
for the response
values that are
closest to the FUN
results, using either or both of
which.obs
and which.values
. If which.obs
is
TRUE
, a column with observation numbers is included in the
data.frame
.
If which.values
is set to the name of a factor
or
a numeric
, a column containing the levels of that
factor
or the values of that numeric
is
included in the data.frame
.
The name of the column with the values of the function will be result of
concatenating the response
, FUN
and, if it is not
NULL
, suffix.interval
, each separated by a full stop.
If which.obs
is TRUE
, the column name for the obervations
numbers will have .obs
added after FUN
into the column name
for the function values; if which.values
is specified,
the column name for these values will have a full stop followed by
which.values
added after FUN
into the column name
for the function values.
Chris Brien
byIndv4Intvl_GRsAvg
, byIndv4Intvl_GRsDiff
,
byIndv4Intvl_WaterUse
, splitValueCalculate
, getTimesSubset
data(exampleData) sPSA.max <- byIndv4Intvl_ValueCalc(data = longi.dat, response = "sPSA", times = "DAP", start.time = 31, end.time = 35, suffix.interval = "31to35") AGR.max.dat <- byIndv4Intvl_ValueCalc(data = longi.dat, response = "sPSA", times = "DAP", FUN="max", start.time = 31, end.time = 35, suffix.interval = "31to35", which.values = "DAP", which.obs = TRUE)
data(exampleData) sPSA.max <- byIndv4Intvl_ValueCalc(data = longi.dat, response = "sPSA", times = "DAP", start.time = 31, end.time = 35, suffix.interval = "31to35") AGR.max.dat <- byIndv4Intvl_ValueCalc(data = longi.dat, response = "sPSA", times = "DAP", FUN="max", start.time = 31, end.time = 35, suffix.interval = "31to35", which.values = "DAP", which.obs = TRUE)
data.frame
in long format.Calculates one or more of water use (WU), water use rate (WUR), and,
for a set of responses, water use indices (WUI)s over a specified time
interval for each individual in a data.frame
in long format.
byIndv4Intvl_WaterUse(data, water.use = "Water.Use", responses = NULL, individuals = "Snapshot.ID.Tag", times = "DAP", trait.types = c("WU", "WUR", "WUI"), suffix.rate = "R", suffix.index = "I", sep.water.traits = "", sep.responses = ".", start.time, end.time, suffix.interval = NULL, sep.suffix.interval = ".", na.rm = FALSE)
byIndv4Intvl_WaterUse(data, water.use = "Water.Use", responses = NULL, individuals = "Snapshot.ID.Tag", times = "DAP", trait.types = c("WU", "WUR", "WUI"), suffix.rate = "R", suffix.index = "I", sep.water.traits = "", sep.responses = ".", start.time, end.time, suffix.interval = NULL, sep.suffix.interval = ".", na.rm = FALSE)
data |
A |
water.use |
A |
responses |
A |
individuals |
A |
times |
A |
trait.types |
A |
suffix.rate |
A |
suffix.index |
A |
sep.water.traits |
A |
sep.responses |
A |
start.time |
A |
end.time |
A |
suffix.interval |
A |
sep.suffix.interval |
A |
na.rm |
A |
WU
is the water use and is the sum of the water use after start.time
until end.time
. Thus, the water use up to start.time
is not included.
WUR
is the Water Use Rate and is WU
divided by the difference
between end.time
and start.time
.
WUI
is the Water Use Index and is calculated as a response
difference
between the start.time and the end.time, which s then divided by the WU
.
A data.frame
containing the individuals
column, WU
and/or WUR
and, if requested, a WUI
for each
element of responses
. The names of WU
and WUR
will have
suffix.interval
appended, if it is not NULL
, separated by a
full stop (‘.’). The name of each WUI
will be the concatenation of an
element of responses
with WUI
and, if not NULL
,
suffix.interval
, the three components being separated by a
full stop (‘.’).
Chris Brien
byIndv4Intvl_GRsAvg
, byIndv4Intvl_GRsDiff
,
splitValueCalculate
, getTimesSubset
, GrowthRates
data(exampleData) WU.WUI_31_35 <- byIndv4Intvl_WaterUse(data = longi.dat, water.use = "WU", responses = "PSA", times = "DAP", trait.types = c("WUR","WUI"), suffix.rate = ".Rate", suffix.index = ".Index", start.time = 31, end.time = 35, suffix.interval = "31to35")
data(exampleData) WU.WUI_31_35 <- byIndv4Intvl_WaterUse(data = longi.dat, water.use = "WU", responses = "PSA", times = "DAP", trait.types = c("WUR","WUI"), suffix.rate = ".Rate", suffix.index = ".Index", start.time = 31, end.time = 35, suffix.interval = "31to35")
data.frame
, the growth rates calculated for consecutive times
for individuals in a data.frame
in long format by differencing
response values.Uses AGRdiff
, PGR
and
RGRdiff
to calculate growth rates continuously
over time for the response
by differencing pairs of pairs
of response
values and
stores the results in data
. The subsets are those values
with the same levels combinations of the factor
s listed in
individuals
.
If avail.time.diffs
is FALSE
, the differences between
consecutive time values are calculated. For this, it is assumed that
the same first times
value is present in data
for all
individuals
.
byIndv4Times_GRsDiff(data, responses, individuals = "Snapshot.ID.Tag", times = "DAP", which.rates = c("AGR","PGR","RGR"), suffices.rates=NULL, sep.rates = ".", avail.times.diffs = FALSE, ntimes2span = 2)
byIndv4Times_GRsDiff(data, responses, individuals = "Snapshot.ID.Tag", times = "DAP", which.rates = c("AGR","PGR","RGR"), suffices.rates=NULL, sep.rates = ".", avail.times.diffs = FALSE, ntimes2span = 2)
data |
A |
responses |
A |
individuals |
A |
times |
A |
which.rates |
A |
suffices.rates |
A |
sep.rates |
A |
avail.times.diffs |
A |
ntimes2span |
A |
A data.frame
containing data
to which has been
added i) a column for the differences between the times
,
if it is not already in data
, and (ii) columns with growth rates.
The name of the column for times
differences will be the value
of times
with ".diffs"
appended. The name for each of
the growth-rate columns will be either the value of response
with one of ".AGR"
, ".PGR"
or "RGR"
, or the
corresponding value from suffices.rates
appended. Each growth
rate will be positioned at observation
ceiling(ntimes2span + 1) / 2
relative to the two times from
which the growth rate is calculated.
Chris Brien
smoothSpline
, byIndv4Times_SplinesGRs
data(exampleData) longi.dat <- byIndv4Times_GRsDiff(data = longi.dat, response = "sPSA", individuals = "Snapshot.ID.Tag", times = "DAP", which.rates=c("AGR", "RGR"), avail.times.diffs = TRUE)
data(exampleData) longi.dat <- byIndv4Times_GRsDiff(data = longi.dat, response = "sPSA", individuals = "Snapshot.ID.Tag", times = "DAP", which.rates=c("AGR", "RGR"), avail.times.diffs = TRUE)
data.frame
in long format, computes,
for a single set of smoothing parameters, smooths of the
response, possibly along with growth rates calculated from the
smooths.Uses smoothSpline
to fit a spline to the values
of response
for each individual
and stores the fitted
values in data
. The degree of smoothing is controlled by the
tuning parameters df
and lambda
, related to the
penalty, and by npspline.segments
. The smoothing.method
provides for direct
and logarithmic
smoothing.
The Absolute and Relative Growth Rates ( AGR and RGR) can be computed
either using the first derivatives of the splines or by differencing
the smooths. If using the first derivative to obtain growth rates,
correctBoundaries
must be FALSE
. Derivatives other than the
first derivative can also be produced. The function
byIndv4Times_GRsDiff
is used to obtain growth rates by
differencing.
The handling of missing values in the observations is controlled via
na.x.action
and na.y.action
. If there are not
at least four distinct, nonmissing x-values, a warning is issued and
all smoothed values and derivatives are set to NA
.
The function probeSmoothing
can be used to investgate the effect
the smoothing parameters
(smoothing.method
, df
or
lambda
) on the smooth that results.
byIndv4Times_SplinesGRs(data, response, response.smoothed = NULL, individuals = "Snapshot.ID.Tag", times, smoothing.method = "direct", smoothing.segments = NULL, spline.type = "NCSS", df=NULL, lambda = NULL, npspline.segments = NULL, correctBoundaries = FALSE, rates.method = "differences", which.rates = c("AGR","RGR"), suffices.rates = NULL, sep.rates = ".", avail.times.diffs = FALSE, ntimes2span = 2, extra.derivs = NULL, suffices.extra.derivs=NULL, sep.levels = ".", na.x.action="exclude", na.y.action = "trimx", ...)
byIndv4Times_SplinesGRs(data, response, response.smoothed = NULL, individuals = "Snapshot.ID.Tag", times, smoothing.method = "direct", smoothing.segments = NULL, spline.type = "NCSS", df=NULL, lambda = NULL, npspline.segments = NULL, correctBoundaries = FALSE, rates.method = "differences", which.rates = c("AGR","RGR"), suffices.rates = NULL, sep.rates = ".", avail.times.diffs = FALSE, ntimes2span = 2, extra.derivs = NULL, suffices.extra.derivs=NULL, sep.levels = ".", na.x.action="exclude", na.y.action = "trimx", ...)
data |
A |
response |
A |
response.smoothed |
A |
individuals |
A |
times |
A |
smoothing.method |
A |
smoothing.segments |
A named |
spline.type |
A |
df |
A |
lambda |
A |
npspline.segments |
A |
correctBoundaries |
A |
rates.method |
A |
which.rates |
A |
suffices.rates |
A |
sep.rates |
A |
avail.times.diffs |
A |
ntimes2span |
A |
extra.derivs |
A |
suffices.extra.derivs |
A |
.
sep.levels |
A |
na.x.action |
A |
na.y.action |
A |
... |
allows for arguments to be passed to |
A data.frame
containing data
to which has been
added a column with the fitted smooth, the name of the column being
the value of response.smoothed
. If rates.method
is
not none
, columns for the growth rates listed in
which.rates
will be added to data
; the names each of
these columns will be the value of response.smoothed
with
the elements of which.rates
appended.
When rates.method
is derivatives
and
smoothing.method
is direct
, the AGR
is obtained
from the first derivative of the spline for each value of times
and the RGR
is calculated as the AGR
divided by the
value of the response.smoothed
for the corresponding time.
When rates.method
is derivatives
and
smoothing.method
is logarithmic
, the RGR
is
obtained from the first derivative of the spline and the AGR
is calculated as the RGR
multiplied by the corresponding
value of the response.smoothed
.
If extra.derivs
is not NULL
, the values for the
nominated derivatives will also be added to data
; the names
each of these columns will be the value of response.smoothed
with .dvf
appended, where f
is the order of the
derivative, or the value of response.smoothed
with the corresponding element of suffices.deriv
appended.
Any pre-existing smoothed and growth rate columns in data
will be
replaced. The ordering of the data.frame
for the times
values will be preserved as far as is possible; the main difficulty
is with the handling of missing values by the function merge
.
Thus, if missing values in times
are retained, they will occur at
the bottom of each subset of individuals
and the order will be
problematic when there are missing values in y
and
na.y.action
is set to omit
.
Chris Brien
Eilers, P.H.C and Marx, B.D. (2021) Practical smoothing: the joys of P-splines. Cambridge University Press, Cambridge.
Huang, C. (2001) Boundary corrected cubic smoothing splines. Journal of Statistical Computation and Simulation, 70, 107-121.
smoothSpline
, probeSmoothing
, byIndv4Times_GRsDiff
,
smooth.spline
, predict.smooth.spline
, split
data(exampleData) #smoothing with growth rates calculated using derivates longi.dat <- byIndv4Times_SplinesGRs(data = longi.dat, response="PSA", response.smoothed = "sPSA", times="DAP", df = 4, rates.method = "deriv", suffices.rates = c("AGRdv", "RGRdv")) #Use P-splines longi.dat <- byIndv4Times_SplinesGRs(data = longi.dat, response="PSA", response.smoothed = "sPSA", individuals = "Snapshot.ID.Tag", times="DAP", spline.type = "PS", lambda = 0.1, npspline.segments = 10, rates.method = "deriv", suffices.rates = c("AGRdv", "RGRdv")) #with segmented smoothing and no growth rates longi.dat <- byIndv4Times_SplinesGRs(data = longi.dat, response="PSA", response.smoothed = "sPSA", individuals = "Snapshot.ID.Tag", times="DAP", smoothing.segments = list(c(28,34), c(35,42)), df = 5, rates.method = "none")
data(exampleData) #smoothing with growth rates calculated using derivates longi.dat <- byIndv4Times_SplinesGRs(data = longi.dat, response="PSA", response.smoothed = "sPSA", times="DAP", df = 4, rates.method = "deriv", suffices.rates = c("AGRdv", "RGRdv")) #Use P-splines longi.dat <- byIndv4Times_SplinesGRs(data = longi.dat, response="PSA", response.smoothed = "sPSA", individuals = "Snapshot.ID.Tag", times="DAP", spline.type = "PS", lambda = 0.1, npspline.segments = 10, rates.method = "deriv", suffices.rates = c("AGRdv", "RGRdv")) #with segmented smoothing and no growth rates longi.dat <- byIndv4Times_SplinesGRs(data = longi.dat, response="PSA", response.smoothed = "sPSA", individuals = "Snapshot.ID.Tag", times="DAP", smoothing.segments = list(c(28,34), c(35,42)), df = 5, rates.method = "none")
Replaces the values in x
with the result of applying an
operation
to it and the value that is lag
positions
either before it or after it in x
, depending on whether
lag
is positive or negative. For positive lag
the first lag
values will be NA
, while for negative
lag
the last lag
values will be NA
.
When operation
is NULL
, the values are moved
lag
positions down the vector.
calcLagged(x, operation = NULL, lag = 1)
calcLagged(x, operation = NULL, lag = 1)
x |
A |
operation |
A |
lag |
A |
A vector
containing the result of applying operation
to
values in x
. For positive lag
the first lag
values will
be NA
, while for negative lag
the last lag
values will be NA
.
Chris Brien
data(exampleData) longi.dat$DAP.diffs <- calcLagged(longi.dat$xDAP, operation ="-")
data(exampleData) longi.dat$DAP.diffs <- calcLagged(longi.dat$xDAP, operation ="-")
For the column specified in imageTimes, having converted it to POSIXct
if not already converted, calculates for each value the number of intervalUnits
between the time and the startTime
. Then the number of timePositions
within the intervals
is calculated for the values in imageTimes
. The function difftimes
is used in doing the calculations, but the results are converted to numeric
. For example intervals
could correspond to the number of Days after Planting (DAP) and the timePositions
to the hour within each day.
calcTimes(data, imageTimes = NULL, timeFormat = "%Y-%m-%d %H:%M", intervals = "Time.after.Planting..d.", startTime = NULL, intervalUnit = "days", timePositions = NULL)
calcTimes(data, imageTimes = NULL, timeFormat = "%Y-%m-%d %H:%M", intervals = "Time.after.Planting..d.", startTime = NULL, intervalUnit = "days", timePositions = NULL)
data |
A |
imageTimes |
A |
timeFormat |
A |
intervals |
A |
startTime |
A |
intervalUnit |
A |
timePositions |
A |
A data.frame
, being the unchaged data data.frame
when
imageTimes
is NULL
or containing
either intervals and/or timePositions depending on which is not NULL
.
Chris Brien
data(exampleData) raw.dat <- calcTimes(data = raw.dat, imageTimes = "Snapshot.Time.Stamp", timePositions = "Hour")
data(exampleData) raw.dat <- calcTimes(data = raw.dat, imageTimes = "Snapshot.Time.Stamp", timePositions = "Hour")
Uses cumsum
to calculate the cumulative sum, ignoring the first element
if exclude.1st is TRUE
.
cumulate(x, exclude.1st = FALSE, na.rm = FALSE, ...)
cumulate(x, exclude.1st = FALSE, na.rm = FALSE, ...)
x |
A |
exclude.1st |
A |
na.rm |
A |
... |
allows passing of arguments to other functions; not used at present. |
A vector
containing the cumulative sum.
Chris Brien
data(exampleData) PSA.cum <- cumulate(longi.dat$PSA)
data(exampleData) PSA.cum <- cumulate(longi.dat$PSA)
Add the following factor
s and covariates to a date frame containing imaging data from the Plant Accelerator: Zone, xZone, SHZone, ZLane, ZMainunit, Subunit and xMainPosn. It checks that the numbers of levels of the factor
s are consistent with the observed numbers of carts and observations.
designFactors(data, insertName = NULL, designfactorMethod = "LanePosition", nzones = 6, nlanesperzone = 4, nmainunitsperlane = 11, nsubunitspermain = 2)
designFactors(data, insertName = NULL, designfactorMethod = "LanePosition", nzones = 6, nlanesperzone = 4, nmainunitsperlane = 11, nsubunitspermain = 2)
data |
A Smarthouse, Snapshot.ID.Tag, xDAP, and, if |
insertName |
A |
designfactorMethod |
A |
nzones |
A |
nlanesperzone |
A |
nmainunitsperlane |
A |
nsubunitspermain |
A |
The factor
s Zone, ZLane, ZMainunit and Subunit are derived for each Smarthouse based on the values of nzones
, nlanesperzone
, nmainunitsperlane
, nsubunitspermain
, Zone being the blocks in the split-unit design. Thus, the number of carts in each Smarthouse must be the product of these values and the number of observations must be the product of the numbers of smarthouse, carts and imagings for each cart. If this is not the case, it may be able to be achieved by including in data
rows for extra observations that have values for the Snapshot.ID.Tag, Smarthouse, Lane, Position and Time.after.Planting..d. and the remaining columns for these rows have missing values (NA
) Then SHZone is formed by combining Smarthouse and Zone and the covariates cZone, cMainPosn and cPosn calculated. The covariate cZone is calculated from Zone and cMainPosn is formed from the mean of cPosn for each main plot.
A data.frame
including the columns:
Smarthouse: factor
with levels for the Smarthouse
Zone: factor
dividing the Lanes into groups, usually of 4 lanes
cZone: numeric corresponding to Zone, centred by subtracting the mean of the unique positions
SHZone: factor
for the combinations of Smarthouse and Zone
ZLane: factor
for the lanes within a Zone
ZMainunit: factor
for the main units within a Zone
Subunit: factor
for the subunits
cMainPosn: numeric for the main-plot positions within a Lane, centred by subtracting the mean of the unique Positions
cPosn: numeric for the Positions within a Lane, centred by subtracting the mean of the unique Positions
Chris Brien
data(exampleData) longi.dat <- prepImageData(data = raw.dat, smarthouse.lev = 1) longi.dat <- designFactors(data = longi.dat, insertName = "Reps", nzones = 1, nlanesperzone = 1, nmainunitsperlane = 10, designfactorMethod="StandardOrder")
data(exampleData) longi.dat <- prepImageData(data = raw.dat, smarthouse.lev = 1) longi.dat <- designFactors(data = longi.dat, insertName = "Reps", nzones = 1, nlanesperzone = 1, nmainunitsperlane = 10, designfactorMethod="StandardOrder")
Imaging data for 20 of the plants that were imaged over 14 days from an experiment in a Smarthouse in the Plant Accelerator. Producing these files is illustrated in the Rice
vignette and the data is used as a small example in the growthPheno
manual.
data(exampleData)
data(exampleData)
Three data.frames
:
raw.dat
(280 rows by 33 columns) that contains the imaging data for 20 plants by 14 imaging days as produced by the image processing software;
longi.dat
(280 rows by 37 columns) that contains a modified version of the imaging data for the 20 plants by 14 imaging days in raw.dat
;
cart.dat
(20 rows by 14 columns) that contains data summarizing the growth features of the 20 plants produced from the data in longi.dat
.
response
in a data.frame
, and growth rates can be
computed using derivativesUses smooth.spline
to fit a natural cubic smoothing spline or JOPS
to fit a
P-spline to all the values of response
stored in data
.
The amount of smoothing can be controlled by tuning parameters, these being
related to the penalty. For a natural cubic smoothing spline, these are
df
or lambda
and, for a P-spline, it is lambda
.
For a P-spline, npspline.segments
also influences the smoothness of the fit.
The smoothing.method
provides for direct
and logarithmic
smoothing. The method of Huang (2001) for correcting the fitted spline for
estimation bias at the end-points will be applied when fitting using a
natural cubic smoothing spline if correctBoundaries
is TRUE
.
The derivatives of the fitted spline can also be obtained, and the
Absolute and Relative Growth Rates ( AGR and RGR) computed using them, provided
correctBoundaries
is FALSE
. Otherwise, growth rates can be
obtained by difference using byIndv4Times_GRsDiff
.
The handling of missing values in the observations is controlled via
na.x.action
and na.y.action
. If there are not
at least four distinct, nonmissing x-values, a warning is issued and
all smoothed values and derivatives are set to NA
.
The function probeSmoothing
can be used to investgate the effect
the smoothing parameters (smoothing.method
and df
or
lambda
) on the smooth that results.
fitSpline(data, response, response.smoothed, x, smoothing.method = "direct", spline.type = "NCSS", df = NULL, lambda = NULL, npspline.segments = NULL, correctBoundaries = FALSE, deriv = NULL, suffices.deriv = NULL, extra.rate = NULL, na.x.action = "exclude", na.y.action = "trimx", ...)
fitSpline(data, response, response.smoothed, x, smoothing.method = "direct", spline.type = "NCSS", df = NULL, lambda = NULL, npspline.segments = NULL, correctBoundaries = FALSE, deriv = NULL, suffices.deriv = NULL, extra.rate = NULL, na.x.action = "exclude", na.y.action = "trimx", ...)
data |
A |
response |
A |
response.smoothed |
A |
x |
A |
smoothing.method |
A |
spline.type |
A |
df |
A |
lambda |
A |
npspline.segments |
A |
correctBoundaries |
A |
deriv |
A |
suffices.deriv |
A |
.
extra.rate |
A named |
na.x.action |
A |
na.y.action |
A |
... |
allows for arguments to be passed to |
A list
with two components named predictions
and
fit.spline
.
The predictions
component is a data.frame
containing x
and the fitted smooth. The names of the columns will be the value of
x
and the value of response.smoothed
. The number of rows in
the data.frame
will be equal to the number of pairs that have neither
a missing x
or response
and the order of x
will be the
same as the order in data
. If deriv
is not NULL
,
columns containing the values of the derivative(s) will be added to the
data.frame
; the name each of these columns will be the value of
response.smoothed
with .dvf
appended, where f
is the
order of the derivative, or the value of response.smoothed
and the
corresponding element of suffices.deriv
appended. If RGR
is
not NULL
, the RGR is calculated as the ratio of value of the first
derivative of the fitted spline and the fitted value for the spline.
The fit.spline
component is a list
with components
x
:the distinct x values in increasing order;
y
:the fitted values, with boundary values possibly corrected, and corresponding to x
;
lev
:leverages, the diagonal values of the smoother matrix (NCSS only);
lambda
:the value of lambda (corresponding to spar
for NCSS - see smooth.spline
);
df
:the efective degrees of freedom;
npspline.segments
:the number of equally spaced segments used for smoothing method set to PS
;
uncorrected.fit
:the object returned by smooth.spline
for smoothing method
set to NCSS
or by JOPS::psNormal
for PS
.
Chris Brien
Eilers, P.H.C and Marx, B.D. (2021) Practical smoothing: the joys of P-splines. Cambridge University Press, Cambridge.
Huang, C. (2001) Boundary corrected cubic smoothing splines. Journal of Statistical Computation and Simulation, 70, 107-121.
splitSplines
, probeSmoothing
,
byIndv4Times_GRsDiff
, smooth.spline
, predict.smooth.spline
, JOPS.
data(exampleData) fit <- fitSpline(longi.dat, response="PSA", response.smoothed = "sPSA", x="xDAP", df = 4, deriv=c(1,2), suffices.deriv=c("AGRdv","Acc")) fit <- fitSpline(longi.dat, response="PSA", response.smoothed = "sPSA", x="xDAP", spline.type = "PS", lambda = 0.1, npspline.segments = 10, deriv=c(1,2), suffices.deriv=c("AGRdv","Acc")) fit <- fitSpline(longi.dat, response="PSA", response.smoothed = "sPSA", x="xDAP", df = 4, deriv=c(1), suffices.deriv=c("AGRdv"), extra.rate = c(RGR.dv = "RGR"))
data(exampleData) fit <- fitSpline(longi.dat, response="PSA", response.smoothed = "sPSA", x="xDAP", df = 4, deriv=c(1,2), suffices.deriv=c("AGRdv","Acc")) fit <- fitSpline(longi.dat, response="PSA", response.smoothed = "sPSA", x="xDAP", spline.type = "PS", lambda = 0.1, npspline.segments = 10, deriv=c(1,2), suffices.deriv=c("AGRdv","Acc")) fit <- fitSpline(longi.dat, response="PSA", response.smoothed = "sPSA", x="xDAP", df = 4, deriv=c(1), suffices.deriv=c("AGRdv"), extra.rate = c(RGR.dv = "RGR"))
responses
in data
that contains their values for the nominated timesForms a subset of each of the responses
in data
that contains their values for the
nominated times in a single column.
getTimesSubset(data, responses, individuals = "Snapshot.ID.Tag", times = "DAP", which.times, suffix = NULL, sep.suffix.times = ".", include.times = FALSE, include.individuals = FALSE)
getTimesSubset(data, responses, individuals = "Snapshot.ID.Tag", times = "DAP", which.times, suffix = NULL, sep.suffix.times = ".", include.times = FALSE, include.individuals = FALSE)
data |
A |
responses |
A |
individuals |
A |
times |
A |
which.times |
A |
suffix |
A |
sep.suffix.times |
A |
include.times |
A |
include.individuals |
A |
A data.frame
containing the subset of responses
ordered
by as many of the initial columns of data
as are required to uniquely
identify each row (see order
for more information). The names
of the columns for each of the responses
and for times
in the
subset are the concatenation of their names in data
and suffix
,
separated by a full stop.
Chris Brien
data(exampleData) sPSALast <- getTimesSubset("sPSA", data = longi.dat, times = "DAP", which.times = c(42), suffix = "last")
data(exampleData) sPSALast <- getTimesSubset("sPSA", data = longi.dat, times = "DAP", which.times = c(42), suffix = "last")
These functions have been renamed and deprecated in growthPheno
:
getDates -> getTimesSubset
anomPlot -> plotAnom
corrPlot -> plotCorrmatrix
imagetimesPlot -> plotImagetimes
longiPlot -> plotProfiles
probeDF -> probeSmooths
getDates(...) anomPlot(...) corrPlot(...) imagetimesPlot(...) longiPlot(...) probeDF(...)
getDates(...) anomPlot(...) corrPlot(...) imagetimesPlot(...) longiPlot(...) probeDF(...)
... |
absorbs arguments passed from the old functions of the style foo.bar(). |
Chris Brien
Calculates either the Absolute Growth Rate (AGR), Proportionate Growth
Rate (PGR) or Relative Growth Rate (RGR) between pairs of time points,
the second of which is lag
positions before the first.
in x
.
AGRdiff(x, time.diffs, lag=1) PGR(x, time.diffs, lag=1) RGRdiff(x, time.diffs, lag=1)
AGRdiff(x, time.diffs, lag=1) PGR(x, time.diffs, lag=1) RGRdiff(x, time.diffs, lag=1)
x |
A |
time.diffs |
a |
lag |
A |
The AGRdiff is calculated as the difference between a pair of values divided by the time.diffs
.
The PGR is calculated as the ratio of a value to a second value which is lag
values
ahead of the first in x
and the ratio raised to the
power of the reciprocal of time.diffs
.
The RGRdiff is calculated as the log
of the PGR and so is equal to the difference between
the logarithms of a pair of values divided by the time.diffs
.
The differences and ratios are obtained using calcLagged
with lag = 1
.
A numeric
containing the growth rates which is the same length as x
and in which the first lag
values NA
.
Chris Brien
byIndv4Intvl_GRsAvg
, byIndv4Intvl_GRsDiff
, byIndv4Times_GRsDiff
, byIndv4Times_SplinesGRs
, calcLagged
data(exampleData) longi.dat$PSA.AGR <- with(longi.dat, AGRdiff(PSA, time.diffs = DAP.diffs))
data(exampleData) longi.dat$PSA.AGR <- with(longi.dat, AGRdiff(PSA, time.diffs = DAP.diffs))
Uses readxl
to import a sheet of imaging data produced by the
Lemna Tec Scanalyzer. Basically, the data consists of imaging data obtained from a
set of pots or carts over time. There should be a column, which by default is called
Snapshot.ID.Tag
, containing a unique identifier for each cart and a column,
which by default is labelled Snapshot.Time.Stamp
, containing
the time of imaging for each observation in a row of the sheet. Also, if
startTime
is not NULL
, calcTimes
is called to
calculate, or recalculate if already present, timeAfterStart
from
imageTimes
by subtracting a supplied startTime
.
Using cameraType
, keepCameraType
, labsCamerasViews
and
prefix2suffix
, some flexibility is provided for renaming the columns with
imaging data. For example, if the column names are prefixed with 'RGB_SV1', 'RGB_SV2'
or 'RGB_TV', the 'RGB_' can be removed and the 'SV1', 'SV2' or 'TV' become suffices.
importExcel(file, sheet="raw data", sep = ",", cartId = "Snapshot.ID.Tag", imageTimes = "Snapshot.Time.Stamp", timeAfterStart = "Time.after.Planting..d.", cameraType = "RGB", keepCameraType = FALSE, labsCamerasViews = NULL, prefix2suffix = TRUE, startTime = NULL, timeFormat = "%Y-%m-%d %H:%M", plotImagetimes = TRUE, ...)
importExcel(file, sheet="raw data", sep = ",", cartId = "Snapshot.ID.Tag", imageTimes = "Snapshot.Time.Stamp", timeAfterStart = "Time.after.Planting..d.", cameraType = "RGB", keepCameraType = FALSE, labsCamerasViews = NULL, prefix2suffix = TRUE, startTime = NULL, timeFormat = "%Y-%m-%d %H:%M", plotImagetimes = TRUE, ...)
file |
A |
sheet |
A |
sep |
A |
cartId |
A |
imageTimes |
A |
timeAfterStart |
A |
cameraType |
A |
keepCameraType |
A |
labsCamerasViews |
A named |
prefix2suffix |
A |
startTime |
A |
timeFormat |
A |
plotImagetimes |
A |
... |
allows for arguments to be passed to |
A data.frame
containing the data.
Chris Brien
as.POSIXct
, calcTimes
, plotImagetimes
filename <- system.file("extdata/rawdata.xlsx", package = "growthPheno", mustWork = TRUE) raw.dat <- importExcel(file = filename, startTime = "2015-02-11 0:00 AM") camview.labels <- c("SF0", "SL0", "SU0", "TV0") names(camview.labels) <- c("RGB_Side_Far_0", "RGB_Side_Lower_0", "RGB_Side_Upper_0", "RGB_TV_0") filename <- system.file("extdata/raw19datarow.csv", package = "growthPheno", mustWork = TRUE) raw.19.dat <- suppressWarnings(importExcel(file = filename, cartId = "Snapshot.ID.Tags", startTime = "06/10/2017 0:00 AM", timeFormat = "%d/%m/%Y %H:M", labsCamerasViews = camview.labels, plotImagetimes = FALSE))
filename <- system.file("extdata/rawdata.xlsx", package = "growthPheno", mustWork = TRUE) raw.dat <- importExcel(file = filename, startTime = "2015-02-11 0:00 AM") camview.labels <- c("SF0", "SL0", "SU0", "TV0") names(camview.labels) <- c("RGB_Side_Far_0", "RGB_Side_Lower_0", "RGB_Side_Upper_0", "RGB_TV_0") filename <- system.file("extdata/raw19datarow.csv", package = "growthPheno", mustWork = TRUE) raw.19.dat <- suppressWarnings(importExcel(file = filename, cartId = "Snapshot.ID.Tags", startTime = "06/10/2017 0:00 AM", timeFormat = "%d/%m/%Y %H:M", labsCamerasViews = camview.labels, plotImagetimes = FALSE))
Using previously calculated growth rates over time, calculates the Absolute Growth Rates for a specified interval using the weighted averages of AGRs for each time point in the interval (AGR) and the Relative Growth Rates for a specified interval using the weighted geometric means of RGRs for each time point in the interval (RGR).
Note: this function is soft deprecated and may be removed in
future versions.
Use byIndv4Intvl_GRsAvg
.
intervalGRaverage(responses, individuals = "Snapshot.ID.Tag", which.rates = c("AGR","RGR"), suffices.rates=c("AGR","RGR"), times = "Days", start.time, end.time, suffix.interval, data, sep=".", na.rm=TRUE)
intervalGRaverage(responses, individuals = "Snapshot.ID.Tag", which.rates = c("AGR","RGR"), suffices.rates=c("AGR","RGR"), times = "Days", start.time, end.time, suffix.interval, data, sep=".", na.rm=TRUE)
responses |
A |
individuals |
A |
which.rates |
A |
suffices.rates |
A |
times |
A |
start.time |
A |
end.time |
A |
suffix.interval |
A |
data |
A |
sep |
A |
na.rm |
A |
The AGR
for an interval is calculated as the weighted mean of the
AGRs for times within the interval. The RGR is calculated as the weighted
geometric mean of the RGRs for times within the interval; in fact the exponential is taken of the weighted means of the logs of the RGRs. The weights are
obtained from the times
. They are taken as the sum of half the time subintervals before and after each time, except for the end points; the end points are taken to be the subintervals at the start and end of the interval.
A data.frame
with the growth rates.
The name of each column is the concatenation of (i) one of
responses
, (ii) one of AGR
, PGR
or RGR
,
or the appropriate element of suffices.rates
, and (iii)
suffix.interval
, the three components being separated by
full stops.
Chris Brien
intervalGRdiff
, intervalWUI
, splitValueCalculate
, getTimesSubset
, GrowthRates
, splitSplines
, splitContGRdiff
data(exampleData) longi.dat <- splitSplines(data = longi.dat, response = "PSA", response.smoothed = "sPSA", x="xDAP", individuals = "Snapshot.ID.Tag", df = 4, deriv=1, suffices.deriv = "AGRdv", extra.rate = c(RGRdv = "RGR")) sPSA.GR <- intervalGRaverage(data = longi.dat, responses = "sPSA", times = "DAP", which.rates = c("AGR","RGR"), suffices.rates = c("AGRdv","RGRdv"), start.time = 31, end.time = 35, suffix.interval = "31to35")
data(exampleData) longi.dat <- splitSplines(data = longi.dat, response = "PSA", response.smoothed = "sPSA", x="xDAP", individuals = "Snapshot.ID.Tag", df = 4, deriv=1, suffices.deriv = "AGRdv", extra.rate = c(RGRdv = "RGR")) sPSA.GR <- intervalGRaverage(data = longi.dat, responses = "sPSA", times = "DAP", which.rates = c("AGR","RGR"), suffices.rates = c("AGRdv","RGRdv"), start.time = 31, end.time = 35, suffix.interval = "31to35")
Using the values of the responses, calculates the specified combination of the Absolute Growth Rates using differences (AGR), the Proportionate Growth Rates (PGR) and Relative Growth Rates using log differences (RGR) between two nominated time points.
Note: this function is soft deprecated and may be removed in
future versions.
Use byIndv4Intvl_GRsDiff
.
intervalGRdiff(responses, individuals = "Snapshot.ID.Tag", which.rates = c("AGR","PGR","RGR"), suffices.rates=NULL, times = "Days", start.time, end.time, suffix.interval, data)
intervalGRdiff(responses, individuals = "Snapshot.ID.Tag", which.rates = c("AGR","PGR","RGR"), suffices.rates=NULL, times = "Days", start.time, end.time, suffix.interval, data)
responses |
A |
individuals |
A |
which.rates |
A |
suffices.rates |
A |
times |
A |
start.time |
A |
end.time |
A |
suffix.interval |
A |
data |
A |
The AGR
is calculated as the difference between the values of
response
at the end.time
and start.time
divided by the
difference between end.time
and start.time
.
The PGR is calculated as the ratio of response
at the end.time
to that at start.time
and the ratio raised to the power of the
reciprocal of the difference between end.time
and start.time
.
The RGR
is calculated as the log
of the PGR and so is equal to
the difference between the logarithms of response
at the end.time
and start.time
divided by the difference
between end.time
and start.time
.
A data.frame
with the growth rates.
The name of each column is the concatenation of (i) one of
responses
, (ii) one of AGR
, PGR
or RGR
,
or the appropriate element of suffices.rates
, and (iii)
suffix.interval
, the three components being separated by
full stops.
Chris Brien
intervalGRaverage
, intervalWUI
, getTimesSubset
, GrowthRates
, splitSplines
, splitContGRdiff
data(exampleData) sPSA.GR <- intervalGRdiff(responses = "sPSA", times = "DAP", which.rates = c("AGR","RGR"), start.time = 31, end.time = 35, suffix.interval = "31to35", data = longi.dat)
data(exampleData) sPSA.GR <- intervalGRdiff(responses = "sPSA", times = "DAP", which.rates = c("AGR","RGR"), start.time = 31, end.time = 35, suffix.interval = "31to35", data = longi.dat)
Principal Variable Analysis (PVA) (Cumming and Wooff, 2007) selects a subset from a set of the variables such that the variables in the subset are as uncorrelated as possible, in an effort to ensure that all aspects of the variation in the data are covered. Here, all observations in a specified time interval are used for calculation the correlations on which the selection is based.
## S3 method for class 'data.frame' intervalPVA(obj, responses, times = "Days", start.time, end.time, nvarselect = NULL, p.variance = 1, include = NULL, plot = TRUE, ...)
## S3 method for class 'data.frame' intervalPVA(obj, responses, times = "Days", start.time, end.time, nvarselect = NULL, p.variance = 1, include = NULL, plot = TRUE, ...)
obj |
A |
responses |
A |
times |
A |
start.time |
A |
end.time |
A |
nvarselect |
A |
p.variance |
A |
include |
A |
plot |
A |
... |
allows passing of arguments to other functions. |
The variable that is most correlated with the other variables is selected first for inclusion. The partial correlation for each of the remaining variables, given the first selected variable, is calculated and the most correlated of these variables is selects for inclusion next. Then the partial correlations are adjust for the second included variables. This process is repeated until the specified criteria have been satisfied. The possibilities are to:
the default (nvarselect = NULL
and p.variance = 1
) select all variables in
increasing order of amount of information they provide;
select exactly nvarselect
variables;
select just enough variables, up to a maximum of nvarselect
variables, to explain
at least p.variance
*100 per cent of the total variance.
A data.frame
giving the results of the variable selection.
It will contain the columns Variable
, Selected
,
h.partial
, Added.Propn
and Cumulative.Propn
.
Chris Brien
Cumming, J. A. and D. A. Wooff (2007) Dimension reduction via principal variables. Computational Statistics and Data Analysis, 52, 550–565.
data(exampleData) longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1) longi.dat <- within(longi.dat, { Max.Height <- pmax(Max.Dist.Above.Horizon.Line.SV1, Max.Dist.Above.Horizon.Line.SV2) Density <- PSA/Max.Height PSA.SV = (PSA.SV1 + PSA.SV2) / 2 Image.Biomass = PSA.SV * (PSA.TV^0.5) Centre.Mass <- (Center.Of.Mass.Y.SV1 + Center.Of.Mass.Y.SV2) / 2 Compactness.SV = (Compactness.SV1 + Compactness.SV2) / 2 }) responses <- c("PSA","PSA.SV","PSA.TV", "Image.Biomass", "Max.Height","Centre.Mass", "Density", "Compactness.TV", "Compactness.SV") results <- intervalPVA(longi.dat, responses, times = "DAP", start.time = "31", end.time = "31", p.variance=0.9, plot = FALSE)
data(exampleData) longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1) longi.dat <- within(longi.dat, { Max.Height <- pmax(Max.Dist.Above.Horizon.Line.SV1, Max.Dist.Above.Horizon.Line.SV2) Density <- PSA/Max.Height PSA.SV = (PSA.SV1 + PSA.SV2) / 2 Image.Biomass = PSA.SV * (PSA.TV^0.5) Centre.Mass <- (Center.Of.Mass.Y.SV1 + Center.Of.Mass.Y.SV2) / 2 Compactness.SV = (Compactness.SV1 + Compactness.SV2) / 2 }) responses <- c("PSA","PSA.SV","PSA.TV", "Image.Biomass", "Max.Height","Centre.Mass", "Density", "Compactness.TV", "Compactness.SV") results <- intervalPVA(longi.dat, responses, times = "DAP", start.time = "31", end.time = "31", p.variance=0.9, plot = FALSE)
Splits the values of a response into subsets corresponding
individuals and applies a function that calculates a single
value from each individual's observations during a specified
time interval. It includes the ability to calculate the
observation number that is closest to the calculated value of
the function and the assocated values of a factor
or
numeric
.
Note: this function is soft deprecated and may be removed in
future versions.
Use byIndv4Intvl_ValueCalc
.
intervalValueCalculate(response, weights=NULL, individuals = "Snapshot.ID.Tag", FUN = "max", which.obs = FALSE, which.values = NULL, times = "Days", start.time=NULL, end.time=NULL, suffix.interval=NULL, data, sep=".", na.rm=TRUE, ...)
intervalValueCalculate(response, weights=NULL, individuals = "Snapshot.ID.Tag", FUN = "max", which.obs = FALSE, which.values = NULL, times = "Days", start.time=NULL, end.time=NULL, suffix.interval=NULL, data, sep=".", na.rm=TRUE, ...)
response |
A |
weights |
A |
individuals |
A |
FUN |
A |
which.obs |
A |
which.values |
A |
times |
A |
start.time |
A |
end.time |
A |
suffix.interval |
A |
data |
A |
na.rm |
A |
sep |
A |
... |
allows for arguments to be passed to |
A data.frame
, with the same number of rows as there are
individuals
, containing a column for the individuals
and
a column with the values of the function for the individuals
.
It is also possible to determine observaton numbers or the values of
another column in data
for the response
values that are
closest to the FUN
results, using either or both of
which.obs
and which.values
. If which.obs
is
TRUE
, a column with observation numbers is included in the
data.frame
.
If which.values
is set to the name of a factor
or
a numeric
,a column containing the levels of that
factor
or the values of that numeric
is
included in the data.frame
.
The name of the column with the values of the function will be result of
concatenating the response
, FUN
and, if it is not
NULL
, suffix.interval
, each separated by a full stop.
If which.obs
is TRUE
, the column name for the obervations
numbers will have .obs
added after FUN
into the column name
for the function values; if which.values
is specified,
the column name for these values will have a full stop followed by
which.values
added after FUN
into the column name
for the function values.
Chris Brien
intervalGRaverage
, intervalGRdiff
, intervalWUI
, splitValueCalculate
, getTimesSubset
data(exampleData) sPSA.max <- intervalValueCalculate(response = "sPSA", times = "DAP", start.time = 31, end.time = 35, suffix.interval = "31to35", data = longi.dat) AGR.max.dat <- intervalValueCalculate(response = "sPSA.AGR", times = "DAP", FUN="max", start.time = 31, end.time = 35, suffix.interval = "31to35", which.values = "DAP", which.obs = TRUE, data=longi.dat)
data(exampleData) sPSA.max <- intervalValueCalculate(response = "sPSA", times = "DAP", start.time = 31, end.time = 35, suffix.interval = "31to35", data = longi.dat) AGR.max.dat <- intervalValueCalculate(response = "sPSA.AGR", times = "DAP", FUN="max", start.time = 31, end.time = 35, suffix.interval = "31to35", which.values = "DAP", which.obs = TRUE, data=longi.dat)
Calculates the Water Use Index (WUI) between two time points for a set of responses.
Note: this function is soft deprecated and may be removed in
future versions.
Use byIndv4Intvl_WaterUse
.
intervalWUI(responses, water.use = "Water.Use", individuals = "Snapshot.ID.Tag", times = "Days", start.time, end.time, suffix.interval = NULL, data, include.total.water = FALSE, na.rm = FALSE)
intervalWUI(responses, water.use = "Water.Use", individuals = "Snapshot.ID.Tag", times = "Days", start.time, end.time, suffix.interval = NULL, data, include.total.water = FALSE, na.rm = FALSE)
responses |
A |
water.use |
A |
individuals |
A |
times |
A |
start.time |
A |
end.time |
A |
suffix.interval |
A |
data |
A |
include.total.water |
A |
na.rm |
A |
The WUI is calculated as the difference between the values of a response
at the end.time
and start.time
divided by the sum of the water use
after start.time
until end.time
. Thus, the water use up to
start.time
is not included.
A data.frame
containing the WUIs, the name of each
column being the concatenation of one of responses
,
WUI
and, if not NULL
, suffix.interval
, the three
components being separated by a full stop. If the total water is to be
included, the name of the column will be the concatenation of
water.use
, Total
and the suffix, each separated by a full
stop(‘.’).
Chris Brien
intervalGRaverage
, intervalGRdiff
, splitValueCalculate
, getTimesSubset
,
GrowthRates
data(exampleData) PSA.WUI <- intervalWUI(response = "PSA", water.use = "WU", times = "DAP", start.time = 31, end.time = 35, suffix = "31to35", data = longi.dat, include.total.water = TRUE)
data(exampleData) PSA.WUI <- intervalWUI(response = "PSA", water.use = "WU", times = "DAP", start.time = 31, end.time = 35, suffix = "31to35", data = longi.dat, include.total.water = TRUE)
A single-line function
that tests whether an object is of class
smooths.frame
.
is.smooths.frame(object)
is.smooths.frame(object)
object |
An |
A logical
.
Chris Brien
validSmoothsFrame
, as.smooths.frame
dat <- read.table(header = TRUE, text = " Type TunePar TuneVal Tuning Method ID DAP PSA sPSA NCSS df 4 df-4 direct 045451-C 28 57.446 51.18456 NCSS df 4 df-4 direct 045451-C 30 89.306 87.67343 NCSS df 7 df-7 direct 045451-C 28 57.446 57.01589 NCSS df 7 df-7 direct 045451-C 30 89.306 87.01316 ") dat[1:7] <- lapply(dat[1:7], factor) dat <- as.smooths.frame(dat, individuals = "ID", times = "DAP") is.smooths.frame(dat) validSmoothsFrame(dat)
dat <- read.table(header = TRUE, text = " Type TunePar TuneVal Tuning Method ID DAP PSA sPSA NCSS df 4 df-4 direct 045451-C 28 57.446 51.18456 NCSS df 4 df-4 direct 045451-C 30 89.306 87.67343 NCSS df 7 df-7 direct 045451-C 28 57.446 57.01589 NCSS df 7 df-7 direct 045451-C 30 89.306 87.01316 ") dat[1:7] <- lapply(dat[1:7], factor) dat <- as.smooths.frame(dat, individuals = "ID", times = "DAP") is.smooths.frame(dat) validSmoothsFrame(dat)
Forms the prime traits by selecting a subset of the traits in a data.frame of
imaging data produced by the Lemna Tec Scanalyzer. The imaging traits to be retained
are specified using the traits
and labsCamerasViews
arguments. Some imaging
traits are divided by 1000 to convert them from pixels to kilopixels.
Also added are factor
s and explanatory variates that might be of use in an analysis.
longitudinalPrime(data, cartId = "Snapshot.ID.Tag", imageTimes = "Snapshot.Time.Stamp", timeAfterStart = "Time.after.Planting..d.", PSAcolumn = "Projected.Shoot.Area..pixels.", idcolumns = c("Genotype.ID","Treatment.1"), traits = list(all = c("Area", "Boundary.Points.To.Area.Ratio", "Caliper.Length", "Compactness", "Convex.Hull.Area"), side = c("Center.Of.Mass.Y", "Max.Dist.Above.Horizon.Line")), labsCamerasViews = list(all = c("SV1", "SV2", "TV"), side = c("SV1", "SV2")), smarthouse.lev = NULL, calcWaterLoss = TRUE, pixelsPERcm)
longitudinalPrime(data, cartId = "Snapshot.ID.Tag", imageTimes = "Snapshot.Time.Stamp", timeAfterStart = "Time.after.Planting..d.", PSAcolumn = "Projected.Shoot.Area..pixels.", idcolumns = c("Genotype.ID","Treatment.1"), traits = list(all = c("Area", "Boundary.Points.To.Area.Ratio", "Caliper.Length", "Compactness", "Convex.Hull.Area"), side = c("Center.Of.Mass.Y", "Max.Dist.Above.Horizon.Line")), labsCamerasViews = list(all = c("SV1", "SV2", "TV"), side = c("SV1", "SV2")), smarthouse.lev = NULL, calcWaterLoss = TRUE, pixelsPERcm)
data |
A Smarthouse, Lane, Position, Weight.Before, Weight.After, Water.Amount, Projected.Shoot.Area..pixels. The defaults for the arguments to Smarthouse, Lane, Position, Weight.Before, Weight.After, Water.Amount, Projected.Shoot.Area..pixels., Area.SV1, Area.SV2, Area.TV, Boundary.Points.To.Area.Ratio.SV1, Boundary.Points.To.Area.Ratio.SV2, Boundary.Points.To.Area.Ratio.TV, Caliper.Length.SV1, Caliper.Length.SV2, Caliper.Length.TV, Compactness.SV1, Compactness.SV2, Compactness.TV, Convex.Hull.Area.SV1, Convex.Hull.Area.SV2, Convex.Hull.Area.TV, Center.Of.Mass.Y.SV1, Center.Of.Mass.Y.SV2, Max.Dist.Above.Horizon.Line.SV1, Max.Dist.Above.Horizon.Line.SV2. |
cartId |
A |
imageTimes |
A |
timeAfterStart |
A |
PSAcolumn |
A |
idcolumns |
A |
traits |
A |
labsCamerasViews |
A |
smarthouse.lev |
A |
calcWaterLoss |
A |
pixelsPERcm |
A |
The columns are copied from data, except for those columns in the list under Value that have ‘(calculated)’ appended.
A data.frame
containing the columns specified by cartId
,
imageTimes
, timeAfterStart
, idcolumns
, traits
and
cameras
. The defaults will result in the following columns:
Smarthouse: factor
with levels for the Smarthouse
Lane: factor
for lane number in a smarthouse
Position: factor
for east/west position in a lane
Days: factor
for the number of Days After Planting (DAP)
cartId
: unique code for each cart
imageTimes
: time at which an image was taken in POSIXct format
Reps: factor
indexing the replicates for each combination of the factor
s in idcolumns
(calculated)
xPosn: numeric for the Positions within a Lane (calculated)
Hour: hour of the day, to 2 decimal places, at which the image was taken (calculated)
xDays: numeric for the DAP that is centred by subtracting the mean of the unique days (calculated)
idcolumns
: the columns listed in idcolumns
that have been converted to factor
s
Weight.Before: weight of the pot before watering (only if calcWaterLoss
is TRUE
)
Weight.After: weight of the pot after watering (only if calcWaterLoss
is TRUE
)
Water.Amount: the weight of the water added (= Water.After - Water.Before) (calculated)
Water.Loss: the difference between Weight.Before for the current imaging and the Weight.After for the previous imaging (calculated unless calcWaterLoss
is FALSE
)
Area: the Projected.Shoot.Area..pixels. divided by 1000 (calculated)
Area.SV1: the Projected.Shoot.Area from Side View 1 divided by 1000 (calculated)
Area.SV2: the Projected.Shoot.Area from Side View 2 divided by 1000 (calculated)
Area.TV: the Projected.Shoot.Area from Top View divided by 1000 (calculated)
Boundary.To.Area.Ratio.SV1
Boundary.To.Area.Ratio.SV2
Boundary.To.Area.Ratio.TV
Caliper.Length.SV1
Caliper.Length.SV2
Caliper.Length.TV
Compactness.SV1 from Side View 1
Compactness.SV2 from Side View 2
Compactness.TV: from Top View
Convex.Hull.Area.SV1: area of Side View 1 Convex Hull divided by 1000 (calculated)
Convex.Hull.Area.SV2: area of Side View 2 Convex Hull divided by 1000 (calculated)
Convex.Hull.TV: Convex.Hull.Area.TV divided by 1000 (calculated)
Center.Of.Mass.Y.SV1: Centre of Mass from Side View 1
Center.Of.Mass.Y.SV2: Centre of Mass from Side View 2
Max.Dist.Above.Horizon.Line.SV1: the Max.Dist.Above.Horizon.Line.SV1 converted to cm using pixelsPERcm
(calculated)
Max.Dist.Above.Horizon.Line.SV2: the Max.Dist.Above.Horizon.Line.SV2 converted to cm using pixelsPERcm
(calculated)
Chris Brien
data(exampleData) longiPrime.dat <- longitudinalPrime(data=raw.dat, smarthouse.lev=1) longiPrime.dat <- longitudinalPrime(data=raw.dat, smarthouse.lev=1, traits = list(a = "Area", c = "Compactness"), labsCamerasViews = list(all = c("SV1", "SV2", "TV"), t = "TV")) longiPrime.dat <- longitudinalPrime(data=raw.dat, smarthouse.lev=1, traits = c("Area.SV1", "Area.SV2", "Area.TV", "Compactness.TV"), labsCamerasViews = NULL) longiPrime.dat <- longitudinalPrime(data=raw.dat, smarthouse.lev=1, calcWaterLoss = FALSE, traits = list(img = c("Area", "Compactness"), H20 = c("Weight.Before","Weight.After", "Water.Amount")), labsCamerasViews = list(all = c("SV1", "SV2", "TV"), H2O = NULL))
data(exampleData) longiPrime.dat <- longitudinalPrime(data=raw.dat, smarthouse.lev=1) longiPrime.dat <- longitudinalPrime(data=raw.dat, smarthouse.lev=1, traits = list(a = "Area", c = "Compactness"), labsCamerasViews = list(all = c("SV1", "SV2", "TV"), t = "TV")) longiPrime.dat <- longitudinalPrime(data=raw.dat, smarthouse.lev=1, traits = c("Area.SV1", "Area.SV2", "Area.TV", "Compactness.TV"), labsCamerasViews = NULL) longiPrime.dat <- longitudinalPrime(data=raw.dat, smarthouse.lev=1, calcWaterLoss = FALSE, traits = list(img = c("Area", "Compactness"), H20 = c("Weight.Before","Weight.After", "Water.Amount")), labsCamerasViews = list(all = c("SV1", "SV2", "TV"), H2O = NULL))
Uses byIndv4Intvl_ValueCalc
and the function
anom
to identify anomalous individuals in longitudinal
data. The user can elect to print the anomalous individuals, a
profile plot without the anomalous individuals and/or a profile plot
with only the anomalous individuals. The plots are produced using
ggplot
. The plot can be facettd so that a grid of plots is
produced.
plotAnom(data, response="sPSA", individuals="Snapshot.ID.Tag", times = "DAP", x = NULL, breaks.spacing.x = -2, angle.x = 0, vertical.line=NULL, groupsFactor=NULL, lower=NULL, upper=NULL, start.time=NULL, end.time=NULL, suffix.interval=NULL, columns.retained=c("Snapshot.ID.Tag", "Smarthouse", "Lane", "Position", "Treatment.1", "Genotype.ID"), whichPrint=c("anomalous","innerPlot","outerPlot"), na.rm=TRUE, ...)
plotAnom(data, response="sPSA", individuals="Snapshot.ID.Tag", times = "DAP", x = NULL, breaks.spacing.x = -2, angle.x = 0, vertical.line=NULL, groupsFactor=NULL, lower=NULL, upper=NULL, start.time=NULL, end.time=NULL, suffix.interval=NULL, columns.retained=c("Snapshot.ID.Tag", "Smarthouse", "Lane", "Position", "Treatment.1", "Genotype.ID"), whichPrint=c("anomalous","innerPlot","outerPlot"), na.rm=TRUE, ...)
data |
A |
response |
A |
individuals |
A |
times |
A |
x |
A |
breaks.spacing.x |
A |
angle.x |
A |
vertical.line |
A |
groupsFactor |
A |
lower |
A |
upper |
A |
start.time |
A |
end.time |
A |
suffix.interval |
A |
columns.retained |
A |
whichPrint |
A |
na.rm |
A |
... |
allows for arguments to be passed to |
A list
with three components:
data
, a data frame resulting from the merge
of data
and the logical
identifying whether
or not an individual is anomalous;
innerPlot
, an object of class ggplot
storing the
profile plot of the individuals that are not anomalous;
outerPlot
, an object of class ggplot
storing the
profile plot of only the individuals that are anomalous.
The name of the column indicating anomalous individuals will be result of
concatenating the response
, anom
and, if it is not
NULL
, suffix.interval
, each separated by a full stop.
The ggplot
objects can be plotted using print
and can be
modified by adding ggplot
functions before printing. If there are
no observations to plot, NULL
will be returned for the plot.
Chris Brien
anom
, byIndv4Intvl_ValueCalc
, ggplot2
.
data(exampleData) anomalous <- plotAnom(longi.dat, response="sPSA.AGR", times = "xDAP", lower=2.5, start.time=40, vertical.line=29, breaks.spacing.x = 2, whichPrint=c("innerPlot"), y.title="sPSA AGR")
data(exampleData) anomalous <- plotAnom(longi.dat, response="sPSA.AGR", times = "xDAP", lower=2.5, start.time=40, vertical.line=29, breaks.spacing.x = 2, whichPrint=c("innerPlot"), y.title="sPSA AGR")
Having calculated the correlations a heat map indicating the magnitude of the
correlations is produced using ggplot
. In this heat map, the darker the red in
a cell then the closer the correlation is to -1, while the deeper the blue in the cell,
then the closer the correlation is to 1. A matrix plot of all pairwise
combinations of the variables can be produced. The matrix plot contains a scatter diagram
for each pair, as well as the value of the correlation coefficient. The argument
pairs.sets
can be used to restrict the pairs in the matrix plot to those
combinations within each set.
plotCorrmatrix(data, responses, which.plots = c("heatmap","matrixplot"), title = NULL, labels = NULL, labelSize = 4, pairs.sets = NULL, show.sig = FALSE, axis.text.size = 20, ggplotFuncs = NULL, printPlot = TRUE, ...)
plotCorrmatrix(data, responses, which.plots = c("heatmap","matrixplot"), title = NULL, labels = NULL, labelSize = 4, pairs.sets = NULL, show.sig = FALSE, axis.text.size = 20, ggplotFuncs = NULL, printPlot = TRUE, ...)
data |
A |
responses |
A |
which.plots |
A |
title |
Title for the plots. |
labels |
A |
labelSize |
A |
pairs.sets |
A |
show.sig |
A |
axis.text.size |
A |
ggplotFuncs |
A |
printPlot |
A |
... |
allows passing of arguments to other functions; not used at present. |
The correlations and their p-values are producced using rcorr
from the Hmisc
package. The heatmap
is produced using
ggplot
and the matrixplot is produced using GGally
.
The heatmap
plot, if produced, as an object of class "ggplot
", which
can be plotted using print
; otherwise NULL
is returned.
Chris Brien
rcorr
, GGally
, ggplot
.
data(exampleData) longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1) longi.dat <- within(longi.dat, { Max.Height <- pmax(Max.Dist.Above.Horizon.Line.SV1, Max.Dist.Above.Horizon.Line.SV2) Density <- PSA/Max.Height PSA.SV = (PSA.SV1 + PSA.SV2) / 2 Image.Biomass = PSA.SV * (PSA.TV^0.5) Centre.Mass <- (Center.Of.Mass.Y.SV1 + Center.Of.Mass.Y.SV2) / 2 Compactness.SV = (Compactness.SV1 + Compactness.SV2) / 2 }) responses <- c("PSA","PSA.SV","PSA.TV", "Image.Biomass", "Max.Height","Centre.Mass", "Density", "Compactness.TV", "Compactness.SV") plotCorrmatrix(longi.dat, responses, pairs.sets=list(c(1:4),c(5:7)))
data(exampleData) longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1) longi.dat <- within(longi.dat, { Max.Height <- pmax(Max.Dist.Above.Horizon.Line.SV1, Max.Dist.Above.Horizon.Line.SV2) Density <- PSA/Max.Height PSA.SV = (PSA.SV1 + PSA.SV2) / 2 Image.Biomass = PSA.SV * (PSA.TV^0.5) Centre.Mass <- (Center.Of.Mass.Y.SV1 + Center.Of.Mass.Y.SV2) / 2 Compactness.SV = (Compactness.SV1 + Compactness.SV2) / 2 }) responses <- c("PSA","PSA.SV","PSA.TV", "Image.Biomass", "Max.Height","Centre.Mass", "Density", "Compactness.TV", "Compactness.SV") plotCorrmatrix(longi.dat, responses, pairs.sets=list(c(1:4),c(5:7)))
Produces boxplots of the deviations of the observed values from the smoothed values over values of x.
plotDeviationsBoxes(data, observed, smoothed, x.factor, x.title = NULL, y.titles = NULL, facet.x = ".", facet.y = ".", facet.labeller = NULL, facet.scales = "fixed", angle.x = 0, deviations.plots = "absolute", ggplotFuncs = NULL, printPlot = TRUE, ...)
plotDeviationsBoxes(data, observed, smoothed, x.factor, x.title = NULL, y.titles = NULL, facet.x = ".", facet.y = ".", facet.labeller = NULL, facet.scales = "fixed", angle.x = 0, deviations.plots = "absolute", ggplotFuncs = NULL, printPlot = TRUE, ...)
data |
A |
observed |
A |
smoothed |
A |
x.factor |
|
x.title |
Title for the x-axis. If |
y.titles |
A |
facet.x |
A |
facet.y |
A |
facet.labeller |
A |
facet.scales |
A |
angle.x |
A |
deviations.plots |
A |
ggplotFuncs |
A |
printPlot |
A |
... |
allows passing of arguments to |
A list whose components are named absolute
and relative
; a
component will contain an object of class "ggplot
" when the plot has been
requested using the deviations.plots
argument and a NULL
otherwise.
The objects can be plotted using print
.
Chris Brien
plotMedianDeviations
, probeSmoothing
, ggplot
.
data(exampleData) plotDeviationsBoxes(longi.dat, observed = "PSA", smoothed = "sPSA", x.factor="DAP", facet.x.pf = ".", facet.y= ".", df =5)
data(exampleData) plotDeviationsBoxes(longi.dat, observed = "PSA", smoothed = "sPSA", x.factor="DAP", facet.x.pf = ".", facet.y= ".", df =5)
Uses ggplot
to produce a plot of the time position within an interval
against the interval. For example, one might plot the hour of the day carts
are imaged against the days after planting (or some other number of
days after an event). A line is produced for each value of groupVariable
and the colour is varied according to the value of the colourVariable
.
Each Smarthouse
is plotted separately. It aids in checking
whether delays occurred in imaging the plants.
plotImagetimes(data, intervals = "Time.after.Planting..d.", timePositions = "Hour", groupVariable = "Snapshot.ID.Tag", colourVariable = "Lane", ggplotFuncs = NULL, printPlot = TRUE)
plotImagetimes(data, intervals = "Time.after.Planting..d.", timePositions = "Hour", groupVariable = "Snapshot.ID.Tag", colourVariable = "Lane", ggplotFuncs = NULL, printPlot = TRUE)
data |
A |
intervals |
A |
timePositions |
A |
groupVariable |
A |
colourVariable |
A |
ggplotFuncs |
A |
printPlot |
A |
An object of class "ggplot
", which can be plotted using print
.
Chris Brien
ggplot
, calcTimes
.
data(exampleData) library(ggplot2) longi.dat <- calcTimes(longi.dat, imageTimes = "Snapshot.Time.Stamp", timePositions = "Hour") plotImagetimes(data = longi.dat, intervals = "DAP", timePositions = "Hour", ggplotFuncs=list(scale_colour_gradient(low="grey20", high="black"), geom_line(aes(group=Snapshot.ID.Tag, colour=Lane))))
data(exampleData) library(ggplot2) longi.dat <- calcTimes(longi.dat, imageTimes = "Snapshot.Time.Stamp", timePositions = "Hour") plotImagetimes(data = longi.dat, intervals = "DAP", timePositions = "Hour", ggplotFuncs=list(scale_colour_gradient(low="grey20", high="black"), geom_line(aes(group=Snapshot.ID.Tag, colour=Lane))))
Produce profile plots of longitudinal data for a response using ggplot
.
A line is drawn for the data for each individual
and the plot
can be faceted so that a grid of plots is produced. For each facet a line for
the medians over time can be added, along with the vaue of the outer whiskers
(median +/- 1.5 * IQR).
plotLongitudinal(data, x = "xDays+44.5", response = "Area", individuals = "Snapshot.ID.Tag", title = NULL, x.title = "Days", y.title = "Area (kpixels)", facet.x = ".", facet.y = ".", labeller = NULL, colour = "black", colour.column = NULL, colour.values = NULL, alpha = 0.1, addMediansWhiskers = FALSE, xname = "xDays", ggplotFuncs = NULL, printPlot = TRUE)
plotLongitudinal(data, x = "xDays+44.5", response = "Area", individuals = "Snapshot.ID.Tag", title = NULL, x.title = "Days", y.title = "Area (kpixels)", facet.x = ".", facet.y = ".", labeller = NULL, colour = "black", colour.column = NULL, colour.values = NULL, alpha = 0.1, addMediansWhiskers = FALSE, xname = "xDays", ggplotFuncs = NULL, printPlot = TRUE)
data |
A |
x |
A |
response |
A |
individuals |
A |
x.title |
Title for the x-axis. |
y.title |
Title for the y-axis. |
title |
Title for the plot. |
facet.x |
A |
facet.y |
A |
labeller |
A |
colour |
A |
colour.column |
A |
colour.values |
A |
alpha |
A |
addMediansWhiskers |
A |
xname |
A |
ggplotFuncs |
A |
printPlot |
A |
An object of class "ggplot
", which can be plotted using
print
.
Chris Brien
ggplot
, labeller
.
data(exampleData) plotLongitudinal(data = longi.dat, x = "xDAP", response = "sPSA") plt <- plotLongitudinal(data = longi.dat, x = "xDAP", response = "sPSA", x.title = "DAP", y.title = "sPSA (kpixels)", facet.x = "Treatment.1", facet.y = "Smarthouse", printPlot=FALSE) plt <- plt + ggplot2::geom_vline(xintercept=29, linetype="longdash", size=1) + ggplot2::scale_x_continuous(breaks=seq(28, 42, by=2)) + ggplot2::scale_y_continuous(limits=c(0,750)) print(plt) plotLongitudinal(data = longi.dat, x="xDAP", response = "sPSA", x.title = "DAP", y.title = "sPSA (kpixels)", facet.x = "Treatment.1", facet.y = "Smarthouse", ggplotFuncs = list(ggplot2::geom_vline(xintercept=29, linetype="longdash", size=1), ggplot2::scale_x_continuous(breaks=seq(28, 42, by=2)), ggplot2::scale_y_continuous(limits=c(0,750))))
data(exampleData) plotLongitudinal(data = longi.dat, x = "xDAP", response = "sPSA") plt <- plotLongitudinal(data = longi.dat, x = "xDAP", response = "sPSA", x.title = "DAP", y.title = "sPSA (kpixels)", facet.x = "Treatment.1", facet.y = "Smarthouse", printPlot=FALSE) plt <- plt + ggplot2::geom_vline(xintercept=29, linetype="longdash", size=1) + ggplot2::scale_x_continuous(breaks=seq(28, 42, by=2)) + ggplot2::scale_y_continuous(limits=c(0,750)) print(plt) plotLongitudinal(data = longi.dat, x="xDAP", response = "sPSA", x.title = "DAP", y.title = "sPSA (kpixels)", facet.x = "Treatment.1", facet.y = "Smarthouse", ggplotFuncs = list(ggplot2::geom_vline(xintercept=29, linetype="longdash", size=1), ggplot2::scale_x_continuous(breaks=seq(28, 42, by=2)), ggplot2::scale_y_continuous(limits=c(0,750))))
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 which.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.
Note: this function is soft deprecated and may be removed in
future versions.
Use plotSmoothsMedianDevns
.
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, printPlot = TRUE, ...)
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, printPlot = TRUE, ...)
data |
A |
. The naming of the
columns for smoothed traits should follow the convention that a name is
made up, in the order sepcified, of (i) a response.smoothed
,
(ii) the trait.type
if not just a response
trait type, a
smoothing.method
or an extra.smooths
and,
(iii) if a smoothing.method
, a df.
Each component should be separated by a period (.).
response |
A |
response.smoothed |
A |
x |
A |
xname |
A |
individuals |
A |
x.title |
A |
y.titles |
A |
facet.x |
A |
facet.y |
A |
labeller |
A |
trait.types |
A |
propn.types |
A |
propn.note |
A |
alpha.med.devn |
A |
smoothing.methods |
A |
df |
A |
extra.smooths |
A |
ggplotFuncsMedDevn |
A |
printPlot |
A |
... |
allows passing of arguments to |
A list
that consists of two components: (i) a componenent named
plots
that stores a list
of the median deviations plots,
one for each trait.types
; (ii) a component named med.dev.dat
that stores the
data.frame
containing the median deviations that have been plotted.
Each plot in the plots
list
is in an object of class
"ggplot
", which can be plotted using print
.
Chris Brien
plotDeviationsBoxes
, probeSmoothing
, ggplot
.
data(exampleData) vline <- list(ggplot2::geom_vline(xintercept=29, linetype="longdash", size=1), ggplot2::scale_x_continuous(breaks=seq(28, 42, by=2))) traits <- probeSmoothing(data = longi.dat, xname = "xDAP", times.factor = "DAP", response = "PSA", response.smoothed = "sPSA", df = c(4:7), facet.x = ".", facet.y = ".", which.plots = "none", propn.types = NULL) med <- plotMedianDeviations(data = traits, response = "PSA", response.smoothed = "sPSA", x="xDAP", xname = "xDAP", df = c(4,7), x.title = "DAP", facet.x = ".", facet.y = ".", trait.types = "response", propn.types = 0.05, ggplotFuncsMedDevn = vline)
data(exampleData) vline <- list(ggplot2::geom_vline(xintercept=29, linetype="longdash", size=1), ggplot2::scale_x_continuous(breaks=seq(28, 42, by=2))) traits <- probeSmoothing(data = longi.dat, xname = "xDAP", times.factor = "DAP", response = "PSA", response.smoothed = "sPSA", df = c(4:7), facet.x = ".", facet.y = ".", which.plots = "none", propn.types = NULL) med <- plotMedianDeviations(data = traits, response = "PSA", response.smoothed = "sPSA", x="xDAP", xname = "xDAP", df = c(4,7), x.title = "DAP", facet.x = ".", facet.y = ".", trait.types = "response", propn.types = 0.05, ggplotFuncsMedDevn = vline)
Produce profile plots of longitudinal data for a response using ggplot
.
A line is drawn for the data for each individual
and the plot
can be faceted so that a grid of plots is produced. For each facet a line for
the medians over time can be added, along with the vaue of the outer whiskers
(median +/- 1.5 * IQR).
plotProfiles(data, response = "PSA", individuals = "Snapshot.ID.Tag", times = "DAP", x = NULL, title = NULL, x.title = "DAP", y.title = "PSA (kpixels)", facet.x = ".", facet.y = ".", labeller = NULL, scales = "fixed", breaks.spacing.x = -2, angle.x = 0, colour = "black", colour.column = NULL, colour.values = NULL, alpha = 0.1, addMediansWhiskers = FALSE, ggplotFuncs = NULL, printPlot = TRUE)
plotProfiles(data, response = "PSA", individuals = "Snapshot.ID.Tag", times = "DAP", x = NULL, title = NULL, x.title = "DAP", y.title = "PSA (kpixels)", facet.x = ".", facet.y = ".", labeller = NULL, scales = "fixed", breaks.spacing.x = -2, angle.x = 0, colour = "black", colour.column = NULL, colour.values = NULL, alpha = 0.1, addMediansWhiskers = FALSE, ggplotFuncs = NULL, printPlot = TRUE)
data |
A |
response |
A |
individuals |
A |
times |
A |
x |
A |
x.title |
Title for the x-axis. |
y.title |
Title for the y-axis. |
title |
Title for the plot. |
facet.x |
A |
facet.y |
A |
labeller |
A |
scales |
A |
breaks.spacing.x |
A |
angle.x |
A |
colour |
A |
colour.column |
A |
colour.values |
A |
alpha |
A |
addMediansWhiskers |
A |
ggplotFuncs |
A |
printPlot |
A |
An object of class "ggplot
", which can be plotted using
print
.
Chris Brien
ggplot
, labeller
.
data(exampleData) plotProfiles(data = longi.dat, response = "sPSA", times = "DAP") plt <- plotProfiles(data = longi.dat, response = "sPSA", y.title = "sPSA (kpixels)", facet.x = "Treatment.1", facet.y = "Smarthouse", breaks.spacing.x = 2, printPlot=FALSE) plt <- plt + ggplot2::geom_vline(xintercept=29, linetype="longdash", linewidth=1) + ggplot2::scale_y_continuous(limits=c(0,750)) print(plt) plotProfiles(data = longi.dat, response = "sPSA", times = "DAP", x.title = "DAP", y.title = "sPSA (kpixels)", facet.x = "Treatment.1", facet.y = "Smarthouse", ggplotFuncs = list(ggplot2::geom_vline(xintercept=29, linetype="longdash", size=1), ggplot2::scale_x_continuous(breaks=seq(28, 42, by=2)), ggplot2::scale_y_continuous(limits=c(0,750))))
data(exampleData) plotProfiles(data = longi.dat, response = "sPSA", times = "DAP") plt <- plotProfiles(data = longi.dat, response = "sPSA", y.title = "sPSA (kpixels)", facet.x = "Treatment.1", facet.y = "Smarthouse", breaks.spacing.x = 2, printPlot=FALSE) plt <- plt + ggplot2::geom_vline(xintercept=29, linetype="longdash", linewidth=1) + ggplot2::scale_y_continuous(limits=c(0,750)) print(plt) plotProfiles(data = longi.dat, response = "sPSA", times = "DAP", x.title = "DAP", y.title = "sPSA (kpixels)", facet.x = "Treatment.1", facet.y = "Smarthouse", ggplotFuncs = list(ggplot2::geom_vline(xintercept=29, linetype="longdash", size=1), ggplot2::scale_x_continuous(breaks=seq(28, 42, by=2)), ggplot2::scale_y_continuous(limits=c(0,750))))
Plots the smoothed values for an observed response
and, optionally, the unsmoothed
observed response
using plotProfiles
. Depending on the setting of
trait.types
(response
, AGR
or RGR
), the computed traits of the
Absolute Growth Rates (AGR) and/or the Relative Growth Rates (RGR) are plotted. This
function will also calculate and produce, using plotDeviationsBoxes
, boxplots
of the deviations of the supplied smoothed values from the observed response values for the
traits and for combinations of the different smoothing parameters and for subsets of
non-smoothing-factor
combinations. The observed and smoothed values are
supplied in long format i.e. with the values for each set of smoothing parameters stacked
one under the other in the supplied smooths.frame
. Such data can be generated
using probeSmooths
; to prevent probeSmooths
producing the
plots, which it is does using plotSmoothsComparison
, plotDeviationsBoxes
and plotSmoothsMedianDevns
, set which.plots
to none
.
The smoothing parameters include spline.types
, df
, lambdas
and
smoothing.methods
(see probeSmooths
).
Multiple plots, possibly each having multiple facets, are produced using ggplot2
.
The layout of these plots is controlled via the arguments plots.by
,
facet.x
and facet.y
. The basic principle is that the number of levels
combinations of the smoothing-parameter factor
s Type
, TunePar
,
TuneVal
, Tuning
(the combination of (TunePar
and TuneVal
), and
Method
that are included in plots.by
, facet.x
and
facet.y
must be the same as those covered by the combinations of the values
supplied to spline.types
, df
, lambdas
and Method
and incorporated
into the smooths.frame
input to plotSmoothsComparison
via the
data
argument. This ensures that smooths from different parameter sets are not
pooled into the same plot. The factor
s other than the smoothing-parameter
factor
s can be supplied to the plots.by
and facet
arguments.
The following profiles plots can be produced: (i) separate plots of the
smoothed traits for each combination of the smoothing parameters
(include Type
, Tuning
and Method
in plots.by
);
(ii) as for (i), with the corresponding plot for the unsmoothed trait
preceeding the plots for the smoothed trait (also set include.raw
to
alone
); (iii) profiles plots that compare a smoothed trait for all
combinations of the values of the smoothing parameters, arranging the plots
side-by-side or one above the other (include Type
, Tuning
and
Method
in facet.x
and/or facet.y
- to include the
unsmoothed trait set include.raw
to one of facet.x
or
facet.y
; (iv) as for (iii), except that separate plots are
produced for each combination of the levels of the factor
s
in plot.by
and each plot compares the smoothed traits for the
smoothing-parameter factor
s included in facet.x
and/or facet.y
(set both plots.by
and one or more of
facet.x
and facet.y
).
plotSmoothsComparison(data, response, response.smoothed = NULL, individuals = "Snapshot.ID.Tag", times = "DAP", trait.types = c("response", "AGR", "RGR"), x.title = NULL, y.titles = NULL, profile.plot.args = args4profile_plot(plots.by = NULL, facet.x = ".", facet.y = ".", include.raw = "no"), printPlot = TRUE, ...)
plotSmoothsComparison(data, response, response.smoothed = NULL, individuals = "Snapshot.ID.Tag", times = "DAP", trait.types = c("response", "AGR", "RGR"), x.title = NULL, y.titles = NULL, profile.plot.args = args4profile_plot(plots.by = NULL, facet.x = ".", facet.y = ".", include.raw = "no"), printPlot = TRUE, ...)
data |
A |
response |
A |
response.smoothed |
A |
times |
A |
individuals |
A |
trait.types |
A |
x.title |
Title for the x-axis, used for all plots. If |
y.titles |
A |
profile.plot.args |
A named |
printPlot |
A |
... |
allows passing of arguments to |
A multilevel list
that contains the ggplot
objects for the plots produced. The first-level list
has a component for each trait.types
and each of these is a
second-level list
that contains the trait
profile plots and for a trait
. It may contain components labelled
Unsmoothed
, all
or for one of the levels of the
factor
s in plots.by
; each of these third-level
ist
s contains a ggplot
object that can
be plotted using print
.
Chris Brien
traitSmooth
, probeSmooths
, args4profile_plot
, plotDeviationsBoxes
, plotSmoothsMedianDevns
, ggplot2
.
data(exampleData) vline <- list(ggplot2::geom_vline(xintercept=29, linetype="longdash", size=1)) traits <- probeSmooths(data = longi.dat, response = "PSA", response.smoothed = "sPSA", times = "DAP", #only df is changed from the probeSmooth default smoothing.args = args4smoothing(smoothing.methods = "direct", spline.types = "NCSS", df = c(4,7), lambdas = NULL), which.plots = "none") plotSmoothsComparison(data = traits, response = "PSA", response.smoothed = "sPSA", times = "DAP", x.title = "DAP", #only facet.x is changed from the probeSmooth default profile.plot.args = args4profile_plot(plots.by = NULL, facet.x = "Tuning", facet.y = ".", include.raw = "no", ggplotFuncs = vline))
data(exampleData) vline <- list(ggplot2::geom_vline(xintercept=29, linetype="longdash", size=1)) traits <- probeSmooths(data = longi.dat, response = "PSA", response.smoothed = "sPSA", times = "DAP", #only df is changed from the probeSmooth default smoothing.args = args4smoothing(smoothing.methods = "direct", spline.types = "NCSS", df = c(4,7), lambdas = NULL), which.plots = "none") plotSmoothsComparison(data = traits, response = "PSA", response.smoothed = "sPSA", times = "DAP", x.title = "DAP", #only facet.x is changed from the probeSmooth default profile.plot.args = args4profile_plot(plots.by = NULL, facet.x = "Tuning", facet.y = ".", include.raw = "no", ggplotFuncs = vline))
Calculates and produces, using plotDeviationsBoxes
, boxplots
of the deviations of the supplied smoothed values from the observed response values for the
traits and for combinations of the different smoothing parameters and for subsets of
non-smoothing-factor
combinations. Which traits are plotted is controlled by
trait.types
and may include the (response
and the computed traits of the
Absolute Growth Rates (AGR) and/or the Relative Growth Rates (RGR). The observed and smoothed
values are supplied in long format i.e. with the values for each set of smoothing parameters
stacked one under the other in the supplied smooths.frame
. Such data can be
generated using probeSmooths
.
Multiple plots, possibly each having multiple facets, are produced using ggplot2
.
The layout of these plots is controlled via the arguments plots.by
,
facet.x
and facet.y
. The basic principle is that the number of levels
combinations of the smoothing-parameter factor
s Type
, TunePar
,
TuneVal
, Tuning
(the combination of (TunePar
and TuneVal
), and
Method
that are included in plots.by
, facet.x
and facet.y
must be the same as those covered by the combinations of the values incorporated
into the smooths.frame
input to plotSmoothsDevnBoxplots
via the
data
argument. This ensures that smooths from different parameter sets are not
pooled into the same plot. The factor
s other than the smoothing-parameter
factor
s can be supplied to the plots.by
and facet
arguments.
plotSmoothsDevnBoxplots(data, response, response.smoothed = NULL, individuals = "Snapshot.ID.Tag", times = "DAP", trait.types = c("response", "AGR", "RGR"), which.plots = "absolute.boxplots", x.title = NULL, y.titles = NULL, devnboxes.plot.args = args4devnboxes_plot(plots.by = NULL, facet.x = ".", facet.y = "."), printPlot = TRUE, ...)
plotSmoothsDevnBoxplots(data, response, response.smoothed = NULL, individuals = "Snapshot.ID.Tag", times = "DAP", trait.types = c("response", "AGR", "RGR"), which.plots = "absolute.boxplots", x.title = NULL, y.titles = NULL, devnboxes.plot.args = args4devnboxes_plot(plots.by = NULL, facet.x = ".", facet.y = "."), printPlot = TRUE, ...)
data |
A |
response |
A |
response.smoothed |
A |
times |
A |
individuals |
A |
trait.types |
A |
which.plots |
A |
x.title |
Title for the x-axis, used for all plots. If |
y.titles |
A |
devnboxes.plot.args |
A named |
printPlot |
A |
... |
allows passing of arguments to |
A multilevel list
that contains the ggplot
objects for the plots produced. The first-level list
has a component for each trait.types
and each of these is a
second-level list
with contains the deviations boxplots
for a response
. Each plot is in an object of class
ggplot
, which can be plotted using print
.
Chris Brien
traitSmooth
, probeSmooths
, args4profile_plot
, plotDeviationsBoxes
, plotSmoothsMedianDevns
, ggplot
.
data(exampleData) traits <- probeSmooths(data = longi.dat, response = "PSA", response.smoothed = "sPSA", times = "DAP", #only df is changed from the probeSmooth default smoothing.args = args4smoothing(smoothing.methods = "direct", spline.types = "NCSS", df = c(4,7), lambdas = NULL), which.plots = "none") plotSmoothsDevnBoxplots(data = traits, response = "PSA", response.smoothed = "sPSA", times = "DAP", x.title = "DAP", #only facet.x is changed from the probeSmooth default devnboxes.plot.args = args4devnboxes_plot(plots.by = NULL, facet.x = "Tuning", facet.y = "."))
data(exampleData) traits <- probeSmooths(data = longi.dat, response = "PSA", response.smoothed = "sPSA", times = "DAP", #only df is changed from the probeSmooth default smoothing.args = args4smoothing(smoothing.methods = "direct", spline.types = "NCSS", df = c(4,7), lambdas = NULL), which.plots = "none") plotSmoothsDevnBoxplots(data = traits, response = "PSA", response.smoothed = "sPSA", times = "DAP", x.title = "DAP", #only facet.x is changed from the probeSmooth default devnboxes.plot.args = args4devnboxes_plot(plots.by = NULL, facet.x = "Tuning", facet.y = "."))
data.frame
in long format.Calculates and plots the medians of the deviations of the supplied smoothed values from the
supplied observed values for traits and combinations of different smoothing parameters,
possibly for subsets of non-smoothing-factor
combinations. The observed and smoothed values are supplied in
long format i.e. with the values for each set of smoothing parameters stacked one under the other
in the supplied data.frame
. Such data can be generated using probeSmooths
;
to prevent probeSmooths
producing the plots, which it is does using
plotSmoothsComparison
, plotDeviationsBoxes
and
plotSmoothsMedianDevns
, set which.plots
to none
.
The smoothing parameters include spline.types
, df
, lambdas
and
smoothing.methods
(see probeSmooths
).
Multiple plots, possibly each having multiple facets, are produced using ggplot2
.
The layout of these plots is controlled via the smoothing-parameter factor
s
Type
, Tuning
(the combination of TunePar
and TuneVal
) and
Method
that can be supplied to the arguments plots.by
,
plots.group
, facet.x
and facet.y
. These plots
and
facet
arguments can also include factor
s other than the
smoothing-parameter factor
s, that are also associated with the data.
The basic principle is that the number of levels combinations of the smoothing-parameter
factor
s included in the plots
and facet
arguments must be the same as those covered by the combinations of the values supplied to
spline.types
, df
, lambdas
and Method
and incorporated into the
smooths.frame
input to plotSmoothsMedianDevns
via the data
argument.
This ensures that smooths from different parameter sets are not pooled in a single plot.
Envelopes of the median value of a trait for each factor
combination can be added.
plotSmoothsMedianDevns(data, response, response.smoothed = NULL, individuals = "Snapshot.ID.Tag", times = "DAP", trait.types = c("response", "AGR", "RGR"), x.title = NULL, y.titles = NULL, meddevn.plot.args = args4meddevn_plot(plots.by = NULL, plots.group = NULL, facet.x = ".", facet.y = ".", propn.note = TRUE, propn.types = c(0.1, 0.5, 0.75)), printPlot = TRUE, ...)
plotSmoothsMedianDevns(data, response, response.smoothed = NULL, individuals = "Snapshot.ID.Tag", times = "DAP", trait.types = c("response", "AGR", "RGR"), x.title = NULL, y.titles = NULL, meddevn.plot.args = args4meddevn_plot(plots.by = NULL, plots.group = NULL, facet.x = ".", facet.y = ".", propn.note = TRUE, propn.types = c(0.1, 0.5, 0.75)), printPlot = TRUE, ...)
data |
A |
response |
A |
response.smoothed |
A |
individuals |
A |
times |
A |
trait.types |
A |
x.title |
Title for the x-axis. If |
y.titles |
A |
meddevn.plot.args |
A named |
printPlot |
A |
... |
allows passing of arguments to other functions; not used at present. |
A list
that consists of two components: (i) a componenent named
plots
that stores a two-level list
of the median deviations
plots; the first-level list
has a component for each
trait.types
and each of these list
(s) is a second-level
list
that contains the set of plots specified by plots.by
(if plots.by
is NULL
, a single plot is stored); (ii) a component named
med.dev.dat
that stores the data.frame
containing the
median deviations that have been plotted. Each plot in the plots
list
is in an object of class ggplot
, which can be
plotted using print
.
Chris Brien
traitSmooth
, probeSmooths
, args4meddevn_plot
, plotSmoothsComparison
, plotDeviationsBoxes
, ggplot
.
data(exampleData) vline <- list(ggplot2::geom_vline(xintercept=29, linetype="longdash", size=1)) traits <- probeSmooths(data = longi.dat, response = "PSA", response.smoothed = "sPSA", times = "DAP", get.rates = FALSE, trait.types = "response", smoothing.args = args4smoothing(smoothing.methods = "direct", spline.types = "NCSS", df = c(4,7), lambdas = NULL), which.plots = "none") med <- plotSmoothsMedianDevns(data = traits, response = "PSA", response.smoothed = "sPSA", times = "DAP", trait.types = "response", meddevn.plot.args = args4meddevn_plot(plots.by = NULL, plots.group = "Tuning", facet.x = ".", facet.y = ".", propn.types = 0.02, ggplotFuncs = vline))
data(exampleData) vline <- list(ggplot2::geom_vline(xintercept=29, linetype="longdash", size=1)) traits <- probeSmooths(data = longi.dat, response = "PSA", response.smoothed = "sPSA", times = "DAP", get.rates = FALSE, trait.types = "response", smoothing.args = args4smoothing(smoothing.methods = "direct", spline.types = "NCSS", df = c(4,7), lambdas = NULL), which.plots = "none") med <- plotSmoothsMedianDevns(data = traits, response = "PSA", response.smoothed = "sPSA", times = "DAP", trait.types = "response", meddevn.plot.args = args4meddevn_plot(plots.by = NULL, plots.group = "Tuning", facet.x = ".", facet.y = ".", propn.types = 0.02, ggplotFuncs = vline))
Forms the prime traits by selecting a subset of the traits in a data.frame of
imaging data produced by the Lemna Tec Scanalyzer. The imaging traits to be retained
are specified using the traits
and labsCamerasViews
arguments. Some imaging
traits are divided by 1000 to convert them from pixels to kilopixels.
Also added are factor
s and explanatory variates that might be of use in an
analysis of the data.
prepImageData(data, cartId = "Snapshot.ID.Tag", imageTimes = "Snapshot.Time.Stamp", timeAfterStart = "Time.after.Planting..d.", PSAcolumn = "Projected.Shoot.Area..pixels.", idcolumns = c("Genotype.ID","Treatment.1"), traits = list(all = c("Area", "Boundary.Points.To.Area.Ratio", "Caliper.Length", "Compactness", "Convex.Hull.Area"), side = c("Center.Of.Mass.Y", "Max.Dist.Above.Horizon.Line")), labsCamerasViews = list(all = c("SV1", "SV2", "TV"), side = c("SV1", "SV2")), smarthouse.lev = NULL, calcWaterUse = TRUE)
prepImageData(data, cartId = "Snapshot.ID.Tag", imageTimes = "Snapshot.Time.Stamp", timeAfterStart = "Time.after.Planting..d.", PSAcolumn = "Projected.Shoot.Area..pixels.", idcolumns = c("Genotype.ID","Treatment.1"), traits = list(all = c("Area", "Boundary.Points.To.Area.Ratio", "Caliper.Length", "Compactness", "Convex.Hull.Area"), side = c("Center.Of.Mass.Y", "Max.Dist.Above.Horizon.Line")), labsCamerasViews = list(all = c("SV1", "SV2", "TV"), side = c("SV1", "SV2")), smarthouse.lev = NULL, calcWaterUse = TRUE)
data |
A Smarthouse, Lane, Position, Weight.Before, Weight.After, Water.Amount, Projected.Shoot.Area..pixels. The defaults for the arguments to Smarthouse, Lane, Position, Weight.Before, Weight.After, Water.Amount, Projected.Shoot.Area..pixels., Area.SV1, Area.SV2, Area.TV, Boundary.Points.To.Area.Ratio.SV1, Boundary.Points.To.Area.Ratio.SV2, Boundary.Points.To.Area.Ratio.TV, Caliper.Length.SV1, Caliper.Length.SV2, Caliper.Length.TV, Compactness.SV1, Compactness.SV2, Compactness.TV, Convex.Hull.Area.SV1, Convex.Hull.Area.SV2, Convex.Hull.Area.TV, Center.Of.Mass.Y.SV1, Center.Of.Mass.Y.SV2, Max.Dist.Above.Horizon.Line.SV1, Max.Dist.Above.Horizon.Line.SV2. |
cartId |
A |
imageTimes |
A |
timeAfterStart |
A |
PSAcolumn |
A |
idcolumns |
A |
traits |
A |
labsCamerasViews |
A |
smarthouse.lev |
A |
calcWaterUse |
A |
The columns are copied from data
, except for those columns that are calculated from the columns in data
; those columns that are calculated have ‘(calculated)’ appended in the list under Value.
A data.frame
containing the columns specified by cartId
,
imageTimes
, timeAfterStart
, idcolumns
, traits
and
cameras
. The defaults will result in the following columns:
Smarthouse: factor
with levels for the Smarthouse
Lane: factor
for lane number in a smarthouse
Position: factor
for east/west position in a lane
DAP: factor
for the number of Days After Planting
xDAP: numeric for the DAP (calculated)
cartId
: unique code for each cart
imageTimes
: time at which an image was taken in POSIXct format
Hour: hour of the day, to 2 decimal places, at which the image was taken (calculated)
Reps: factor
indexing the replicates for each combination of the factor
s in idcolumns
(calculated)
idcolumns
: the columns listed in idcolumns
that have been converted to factor
s
Weight.Before: weight of the pot before watering (only if calcWaterUse
is TRUE
)
Weight.After: weight of the pot after watering (only if calcWaterUse
is TRUE
)
Water.Amount: the weight of the water added (= Water.After - Water.Before) (calculated)
WU: the water use calculated as the difference between Weight.Before for the current imaging and the Weight.After for the previous imaging (calculated unless calcWaterUse
is FALSE
)
PSA: the Projected.Shoot.Area..pixels. divided by 1000 (calculated)
PSA.SV1: the Projected.Shoot.Area from Side View 1 divided by 1000 (calculated)
PSA.SV2: the Projected.Shoot.Area from Side View 2 divided by 1000 (calculated)
PSA.TV: the Projected.Shoot.Area from Top View divided by 1000 (calculated)
Boundary.To.PSA.Ratio.SV1
Boundary.To.PSA.Ratio.SV2
Boundary.To.PSA.Ratio.TV
Caliper.Length.SV1
Caliper.Length.SV2
Caliper.Length.TV
Compactness.SV1 from Side View 1
Compactness.SV2 from Side View 2
Compactness.TV: from Top View
Convex.Hull.PSA.SV1: area of Side View 1 Convex Hull divided by 1000 (calculated)
Convex.Hull.PSA.SV2: area of Side View 2 Convex Hull divided by 1000 (calculated)
Convex.Hull.PSA.TV: Convex.Hull.Area.TV divided by 1000 (calculated)
Center.Of.Mass.Y.SV1: Centre of Mass from Side View 1
Center.Of.Mass.Y.SV2: Centre of Mass from Side View 2
Max.Dist.Above.Horizon.Line.SV1: the Max.Dist.Above.Horizon.Line.SV1 divided by 1000 (calculated)
Max.Dist.Above.Horizon.Line.SV2: the Max.Dist.Above.Horizon.Line.SV2 divided by 1000 (calculated)
Chris Brien
data(exampleData) longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1) longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1, traits = list(a = "Area", c = "Compactness"), labsCamerasViews = list(all = c("SV1", "SV2", "TV"), t = "TV")) longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1, traits = c("Area.SV1", "Area.SV2", "Area.TV", "Compactness.TV"), labsCamerasViews = NULL) longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1, calcWaterUse = FALSE, traits = list(img = c("Area", "Compactness"), H20 = c("Weight.Before","Weight.After", "Water.Amount")), labsCamerasViews = list(all = c("SV1", "SV2", "TV"), H2O = NULL))
data(exampleData) longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1) longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1, traits = list(a = "Area", c = "Compactness"), labsCamerasViews = list(all = c("SV1", "SV2", "TV"), t = "TV")) longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1, traits = c("Area.SV1", "Area.SV2", "Area.TV", "Compactness.TV"), labsCamerasViews = NULL) longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1, calcWaterUse = FALSE, traits = list(img = c("Area", "Compactness"), H20 = c("Weight.Before","Weight.After", "Water.Amount")), labsCamerasViews = list(all = c("SV1", "SV2", "TV"), H2O = NULL))
Takes a response
and, for each individual
, uses
splitSplines
to smooth its values for each individual
using the degrees of freedom values in df
.
Provided get.rates
is TRUE
,
both the Absolute Growth Rates (AGR) and the Relative Growth Rates (RGR)
are calculated for each smooth, either using differences or first
derivatives. A combination of the unsmoothed and smoothed values,
as well as the AGR and RGR, can be plotted for each value in
smoothing methods
in combination with df
. Note that the
arguments that modify the plots apply to all
plots that are produced. The handling of missing values is controlled
via na.x.action
and na.y.action
Note: this function is soft deprecated and may be removed in
future versions.
Use probeSmooths
.
probeSmoothing(data, response = "Area", response.smoothed = NULL, x = NULL, xname="xDays", times.factor = "Days", individuals="Snapshot.ID.Tag", na.x.action="exclude", na.y.action = "exclude", df, smoothing.methods = "direct", correctBoundaries = FALSE, get.rates = TRUE, rates.method="differences", facet.x = "Treatment.1", facet.y = "Smarthouse", labeller = NULL, x.title = NULL, colour = "black", colour.column=NULL, colour.values=NULL, alpha = 0.1, trait.types = c("response", "AGR", "RGR"), propn.types = c(0.1, 0.5, 0.75), propn.note = TRUE, which.plots = "smoothedonly", deviations.plots = "none", alpha.med.devn = 0.5, ggplotFuncs = NULL, ggplotFuncsMedDevn = NULL, ...)
probeSmoothing(data, response = "Area", response.smoothed = NULL, x = NULL, xname="xDays", times.factor = "Days", individuals="Snapshot.ID.Tag", na.x.action="exclude", na.y.action = "exclude", df, smoothing.methods = "direct", correctBoundaries = FALSE, get.rates = TRUE, rates.method="differences", facet.x = "Treatment.1", facet.y = "Smarthouse", labeller = NULL, x.title = NULL, colour = "black", colour.column=NULL, colour.values=NULL, alpha = 0.1, trait.types = c("response", "AGR", "RGR"), propn.types = c(0.1, 0.5, 0.75), propn.note = TRUE, which.plots = "smoothedonly", deviations.plots = "none", alpha.med.devn = 0.5, ggplotFuncs = NULL, ggplotFuncsMedDevn = NULL, ...)
data |
A |
response |
A |
response.smoothed |
A |
x |
A |
xname |
A |
times.factor |
A |
individuals |
A |
na.x.action |
A |
na.y.action |
A |
df |
A |
smoothing.methods |
A |
correctBoundaries |
A |
get.rates |
A |
rates.method |
A |
facet.x |
A |
facet.y |
A |
labeller |
A |
x.title |
Title for the x-axis. If |
colour |
A |
colour.column |
A |
colour.values |
A |
alpha |
A |
trait.types |
A |
propn.types |
A |
propn.note |
A |
which.plots |
A |
deviations.plots |
A |
alpha.med.devn |
A |
ggplotFuncs |
A |
ggplotFuncsMedDevn |
A |
... |
allows passing of arguments to |
A data.frame
containing individuals
,
times.factor
, facet.x
, facet.y
, xname
,
response
, and, for each df
, the smoothed
response, the AGR and the RGR. It is returned invisibly. The names of
the new data are constructed by joining elements separated by full
stops (.
). In all cases, the last element is the value of
df
. For the smoothed response, the other elements are
response
and "smooth"
; for AGR and RGR, the other elements
are the name of the smoothed response and either "AGR"
or
"RGR"
.
Chris Brien
splitSplines
, splitContGRdiff
, smooth.spline
, ggplot
.
data(exampleData) vline <- list(ggplot2::geom_vline(xintercept=29, linetype="longdash", size=1), ggplot2::scale_x_continuous(breaks=seq(28, 42, by=2))) probeSmoothing(data = longi.dat, response = "PSA", df = c(4,7), xname = "xDAP", times = "DAP", ggplotFuncs=vline)
data(exampleData) vline <- list(ggplot2::geom_vline(xintercept=29, linetype="longdash", size=1), ggplot2::scale_x_continuous(breaks=seq(28, 42, by=2))) probeSmoothing(data = longi.dat, response = "PSA", df = c(4,7), xname = "xDAP", times = "DAP", ggplotFuncs=vline)
data.frame
in long format, computes and compares, for
sets of smoothing parameters, smooths of the response, possibly along with
growth rates calculated from the smooths.Takes an observed response
and, for each individual
, uses
byIndv4Times_SplinesGRs
to smooth its values employing the smoothing
parameters specified by (i) spline.types
, (ii) the tuning
parameters, being the degrees of freedom values in df
or the
smoothing penalties in lambdas
, and (iii) the
smoothing.methods
. The values of these, and other, smoothing
arguments are set using the helper function
args4smoothing
.
Provided get.rates
is TRUE
or includes raw
and/or
smoothed
and depending on the setting
of trait.types
, the Absolute Growth Rates (AGR) and/or the
Relative Growth Rates (RGR) are calculated for each individual from the
unsmoothed, observed response
and from the smooths of the
response
, using either differences or first derivatives, as
specified by rates.method
.
Generally, profile plots for the traits (a response, an AGR or an RGR)
specified in traits.types
are produced if which.plots
is
profiles
; if which.plots
specifies one or more deviations
plots, then those deviations plots will also be produced, these being
based on the unsmoothed data from which the smoothed data has been
subtracted. The layout of the plots is controlled via combinations of
one or more of the smoothing-parameter factor
s Type
,
TunePar
, TuneVal
, Tuning
(the combination
of TunePar
and TuneVal
) and Method
, as well as
other factor
s associated with the data
.
The factor
s that are to be used for the profile plots
are supplied via the argument profile.plot.args
using the helper function args4profile_plot
and for the
and deviations boxplots using the helper function
args4devnboxes_plot
. These helper functions set
plots.by
, facet.x
, and facet.y
. For the plots of
the medians of the deviations, the factor
s are supplied via
the argument meddevn.plot.args
using the helper function
args4meddevn_plot
to set plots.by
, facet.x
,
facet.y
and plots.group
. Here, the basic principle is that
the number of levels combinations of the smoothing-parameter
factor
s included in the set of plots
and
facets
arguments to one of these helper functions must be the same
as those covered by the combinations of the values supplied to
spline.types
, df
, lambdas
and smoothing.methods
and incorporated into the smooths.frame
, such as is
returned by probeSmooths
. This ensures that smooths
from different parameter sets are not pooled together in a single plot.
It is also possible to include factor
s that are not
smoothing-parameter factor
s in the plots
amd
facets
arguments.
The following profiles plots can be produced using
args4profile_plot
: (i) separate plots of the
smoothed traits for each combination of the smoothing parameters
(include Type
, Tuning
and Method
in plots.by
);
(ii) as for (i), with the corresponding plot for the unsmoothed trait
preceeding the plots for the smoothed trait (also set include.raw
to
alone
); (iii) profiles plots that compare a smoothed trait for all
combinations of the values of the smoothing parameters, arranging the plots
side-by-side or one above the other (include Type
, Tuning
and
Method
in facet.x
and/or facet.y
- to include the
unsmoothed trait set include.raw
to one of facet.x
or
facet.y
; (iv) as for (iii), except that separate plots are
produced for each combination of the levels of the factor
s
in plot.by
and each plot compares the smoothed traits for the
smoothing-parameter factor
s included in facet.x
and/or facet.y
(set both plots.by
and one or more of
facet.x
and facet.y
).
Deviation plots that can be produced are the absolute and relative deviations
boxplots and plots of medians deviations (see which.plots
).
The handling of missing values is controlled via na.x.action
and
na.y.action
supplied to the helper function args4smoothing
.
The probeSmooths
arguments are grouped according to function in the following order:
Data description arguments: data, response, response.smoothed, individuals, times, keep.columns, trait.types, get.rates, rates.method, ntimes2span.
Smoothing arguments: smoothing.args (see args4smoothing
).
General plot control: x.title, y.titles, facet.labeller, which.plots.
Profile plots (pf) features: profile.plot.args (see args4profile_plot
)
Median-deviations (med) plots features: meddevn.plot.args (see args4meddevn_plot
)
Deviations boxplots (box) features: devnboxes.plot.args (see args4devnboxes_plot
)
probeSmooths(data, response = "PSA", response.smoothed = NULL, individuals="Snapshot.ID.Tag", times = "DAP", keep.columns = NULL, get.rates = TRUE, rates.method="differences", ntimes2span = NULL, trait.types = c("response", "AGR", "RGR"), smoothing.args = args4smoothing(smoothing.methods = "direct", spline.types = "NCSS", df = NULL, lambdas = NULL), x.title = NULL, y.titles = NULL, which.plots = "profiles", profile.plot.args = args4profile_plot(plots.by = NULL, facet.x = ".", facet.y = ".", include.raw = "no"), meddevn.plot.args = args4meddevn_plot(plots.by = NULL, plots.group = NULL, facet.x = ".", facet.y = ".", propn.note = TRUE, propn.types = c(0.1, 0.5, 0.75)), devnboxes.plot.args = args4devnboxes_plot(plots.by = NULL, facet.x = ".", facet.y = ".", which.plots = "none"), ...)
probeSmooths(data, response = "PSA", response.smoothed = NULL, individuals="Snapshot.ID.Tag", times = "DAP", keep.columns = NULL, get.rates = TRUE, rates.method="differences", ntimes2span = NULL, trait.types = c("response", "AGR", "RGR"), smoothing.args = args4smoothing(smoothing.methods = "direct", spline.types = "NCSS", df = NULL, lambdas = NULL), x.title = NULL, y.titles = NULL, which.plots = "profiles", profile.plot.args = args4profile_plot(plots.by = NULL, facet.x = ".", facet.y = ".", include.raw = "no"), meddevn.plot.args = args4meddevn_plot(plots.by = NULL, plots.group = NULL, facet.x = ".", facet.y = ".", propn.note = TRUE, propn.types = c(0.1, 0.5, 0.75)), devnboxes.plot.args = args4devnboxes_plot(plots.by = NULL, facet.x = ".", facet.y = ".", which.plots = "none"), ...)
data |
A |
response |
A |
response.smoothed |
A |
individuals |
A |
times |
A |
keep.columns |
A |
get.rates |
A |
rates.method |
A |
ntimes2span |
A |
trait.types |
A |
smoothing.args |
A |
x.title |
Title for the x-axis, used for all plots. If |
y.titles |
A |
which.plots |
A Boxplots of the absolute deviations are specified by
The option |
profile.plot.args |
A named |
meddevn.plot.args |
A named |
devnboxes.plot.args |
A named |
... |
allows passing of arguments to |
A smooths.frame
that contains the unsmoothed and smoothed data
in long format. That is, all the values for either an unsmoothed or a
smoothed trait are in a single column. The smooths for a trait for the
different combinatons of the smoothing parameters are placed in rows one
below the other. The columns that are included in the smooths.frame
are Type
, TunePar
, TuneVal
, Tuning
and Method
,
as well as those specified by individuals
, times
, response
, and
response.smoothed
. and any included in the keep.columns
, plots
and facet
arguments.
If trait.types
includes AGR
or RGR
, then the included growth
rate(s) of the response
and response.smoothed
must be present, unless
get.rates
is TRUE or includes raw
and/or smoothed
. In this case,
the growth rates specified by trait.types
will be calculated for the responses
nominated by get.rates
and the differences between the times
used in calculating the rates will be computed and added. Then, the names of the
growth rates are formed from response
and response.smoothed
by
appending .AGR
and .RGR
as appropriate; the name of the column with
the times
differences will be formed by appending .diffs
to the
value of times
. The external.smooths
will also be included.
A smooths.frame
has the attributes described in
smooths.frame
.
Columns in the supplied data.frame
that have not been used in
probeSmooths
will not be included in the returned smooths.frame
.
If they might be needed subsequently, such as when extra plots are produced, they
can be included in the smooths.frame
by listing them in a
character
vector for the keep.columns
argument.
The smooths.frame
is returned invisibly.
Chris Brien
args4smoothing
, , args4meddevn_plot
, args4profile_plot
,
traitSmooth
, smoothSpline
, byIndv4Times_SplinesGRs
, byIndv4Times_GRsDiff
,
smooth.spline
, psNormal
, plotSmoothsComparison
, plotSmoothsMedianDevns
, ggplot
.
data(exampleData) longi.dat <- longi.dat[1:140,] #reduce to a smaller data set vline <- list(ggplot2::geom_vline(xintercept=29, linetype="longdash", linewidth=1)) yfacets <- c("Smarthouse", "Treatment.1") probeSmooths(data = longi.dat, response = "PSA", response.smoothed = "sPSA", individuals = "Snapshot.ID.Tag",times = "DAP", smoothing.args = args4smoothing(df = c(4,7), lambda = list(PS = c(0.316,10))), profile.plot.args = args4profile_plot(plots.by = NULL, facet.x = "Tuning", facet.y = c("Smarthouse", "Treatment.1"), include.raw = "no", alpha = 0.4, colour.column = "Method", colour.values = c("orange", "olivedrab"), ggplotFuncs = vline)) #An example that supplies three smoothing schemes to be compared data(tomato.dat) probeSmooths(data = tomato.dat, response = "PSA", response.smoothed = "sPSA", times = "DAP", smoothing.args = args4smoothing(spline.types = c( "N", "NCS", "P"), df = c( 4, 6, NA), lambdas = c( NA, NA, 1), smoothing.methods = c("dir", "log", "log"), combinations = "parallel"), which.plots = "medians.deviations", meddevn.plot.args = args4meddevn_plot(plots.by = NULL, plots.group = c("Type", "Tuning", "Method"), facet.x = ".", facet.y = ".", propn.note = FALSE, propn.types = NULL))
data(exampleData) longi.dat <- longi.dat[1:140,] #reduce to a smaller data set vline <- list(ggplot2::geom_vline(xintercept=29, linetype="longdash", linewidth=1)) yfacets <- c("Smarthouse", "Treatment.1") probeSmooths(data = longi.dat, response = "PSA", response.smoothed = "sPSA", individuals = "Snapshot.ID.Tag",times = "DAP", smoothing.args = args4smoothing(df = c(4,7), lambda = list(PS = c(0.316,10))), profile.plot.args = args4profile_plot(plots.by = NULL, facet.x = "Tuning", facet.y = c("Smarthouse", "Treatment.1"), include.raw = "no", alpha = 0.4, colour.column = "Method", colour.values = c("orange", "olivedrab"), ggplotFuncs = vline)) #An example that supplies three smoothing schemes to be compared data(tomato.dat) probeSmooths(data = tomato.dat, response = "PSA", response.smoothed = "sPSA", times = "DAP", smoothing.args = args4smoothing(spline.types = c( "N", "NCS", "P"), df = c( 4, 6, NA), lambdas = c( NA, NA, 1), smoothing.methods = c("dir", "log", "log"), combinations = "parallel"), which.plots = "medians.deviations", meddevn.plot.args = args4meddevn_plot(plots.by = NULL, plots.group = c("Type", "Tuning", "Method"), facet.x = ".", facet.y = ".", propn.note = FALSE, propn.types = NULL))
Principal Variable Analysis (PVA) (Cumming and Wooff, 2007) selects a subset from a set of the variables such that the variables in the subset are as uncorrelated as possible, in an effort to ensure that all aspects of the variation in the data are covered.
PVA(obj, ...)
PVA(obj, ...)
obj |
A |
... |
allows passing of arguments to other functions |
PVA
is the generic function for the PVA
method.
Use methods("PVA") to get all the methods for the PVA generic.
PVA.data.frame
is a method for a data.frame
.
PVA.matrix
is a method for a matrix
.
A data.frame
giving the results of the variable selection.
It will contain the columns Variable
, Selected
,
h.partial
, Added.Propn
and Cumulative.Propn
.
Chris Brien
Cumming, J. A. and D. A. Wooff (2007) Dimension reduction via principal variables. Computational Statistics and Data Analysis, 52, 550–565.
PVA.data.frame
, PVA.matrix
, intervalPVA
, rcontrib
Principal Variable Analysis (PVA) (Cumming and Wooff, 2007) selects a subset from a set of the variables such that the variables in the subset are as uncorrelated as possible, in an effort to ensure that all aspects of the variation in the data are covered.
## S3 method for class 'data.frame' PVA(obj, responses, nvarselect = NULL, p.variance = 1, include = NULL, plot = TRUE, ...)
## S3 method for class 'data.frame' PVA(obj, responses, nvarselect = NULL, p.variance = 1, include = NULL, plot = TRUE, ...)
obj |
A |
responses |
A |
nvarselect |
A |
p.variance |
A |
include |
A |
plot |
A |
... |
allows passing of arguments to other functions |
The variable that is most correlated with the other variables is selected first for inclusion. The partial correlation for each of the remaining variables, given the first selected variable, is calculated and the most correlated of these variables is selects for inclusion next. Then the partial correlations are adjust for the second included variables. This process is repeated until the specified criteria have been satisfied. The possibilities are:
the default (nvarselect = NULL
and p.variance = 1
), which selects all
variables in increasing order of amount of information they provide;
to select exactly nvarselect
variables;
to select just enough variables, up to a maximum of nvarselect
variables, to explain
at least p.variance
*100 per cent of the total variance.
A data.frame
giving the results of the variable selection.
It will contain the columns Variable
, Selected
,
h.partial
, Added.Propn
and Cumulative.Propn
.
Chris Brien
Cumming, J. A. and D. A. Wooff (2007) Dimension reduction via principal variables. Computational Statistics and Data Analysis, 52, 550–565.
PVA
, PVA.matrix
, intervalPVA.data.frame
, rcontrib
data(exampleData) longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1) longi.dat <- within(longi.dat, { Max.Height <- pmax(Max.Dist.Above.Horizon.Line.SV1, Max.Dist.Above.Horizon.Line.SV2) Density <- PSA/Max.Height PSA.SV = (PSA.SV1 + PSA.SV2) / 2 Image.Biomass = PSA.SV * (PSA.TV^0.5) Centre.Mass <- (Center.Of.Mass.Y.SV1 + Center.Of.Mass.Y.SV2) / 2 Compactness.SV = (Compactness.SV1 + Compactness.SV2) / 2 }) responses <- c("PSA","PSA.SV","PSA.TV", "Image.Biomass", "Max.Height","Centre.Mass", "Density", "Compactness.TV", "Compactness.SV") results <- PVA(longi.dat, responses, p.variance=0.9, plot = FALSE)
data(exampleData) longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1) longi.dat <- within(longi.dat, { Max.Height <- pmax(Max.Dist.Above.Horizon.Line.SV1, Max.Dist.Above.Horizon.Line.SV2) Density <- PSA/Max.Height PSA.SV = (PSA.SV1 + PSA.SV2) / 2 Image.Biomass = PSA.SV * (PSA.TV^0.5) Centre.Mass <- (Center.Of.Mass.Y.SV1 + Center.Of.Mass.Y.SV2) / 2 Compactness.SV = (Compactness.SV1 + Compactness.SV2) / 2 }) responses <- c("PSA","PSA.SV","PSA.TV", "Image.Biomass", "Max.Height","Centre.Mass", "Density", "Compactness.TV", "Compactness.SV") results <- PVA(longi.dat, responses, p.variance=0.9, plot = FALSE)
Principal Variable Analysis (PVA) (Cumming and Wooff, 2007) selects a subset from a set of the variables such that the variables in the subset are as uncorrelated as possible, in an effort to ensure that all aspects of the variation in the data are covered.
## S3 method for class 'matrix' PVA(obj, responses, nvarselect = NULL, p.variance = 1, include = NULL, plot = TRUE, ...)
## S3 method for class 'matrix' PVA(obj, responses, nvarselect = NULL, p.variance = 1, include = NULL, plot = TRUE, ...)
obj |
A |
responses |
A |
nvarselect |
A |
p.variance |
A |
include |
A |
plot |
A |
... |
allows passing of arguments to other functions |
The variable that is most correlated with the other variables is selected first for inclusion. The partial correlation for each of the remaining variables, given the first selected variable, is calculated and the most correlated of these variables is selects for inclusion next. Then the partial correlations are adjust for the second included variables. This process is repeated until the specified criteria have been satisfied. The possibilities are:
the default (nvarselect = NULL
and p.variance = 1
), which selects all
variables in increasing order of amount of information they provide;
to select exactly nvarselect
variables;
to select just enough variables, up to a maximum of nvarselect
variables, to explain
at least p.variance
*100 per cent of the total variance.
A data.frame
giving the results of the variable selection.
It will contain the columns Variable
, Selected
,
h.partial
, Added.Propn
and Cumulative.Propn
.
Chris Brien
Cumming, J. A. and D. A. Wooff (2007) Dimension reduction via principal variables. Computational Statistics and Data Analysis, 52, 550–565.
PVA
, PVA.data.frame
, intervalPVA.data.frame
, rcontrib
data(exampleData) longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1) longi.dat <- within(longi.dat, { Max.Height <- pmax(Max.Dist.Above.Horizon.Line.SV1, Max.Dist.Above.Horizon.Line.SV2) Density <- PSA/Max.Height PSA.SV = (PSA.SV1 + PSA.SV2) / 2 Image.Biomass = PSA.SV * (PSA.TV^0.5) Centre.Mass <- (Center.Of.Mass.Y.SV1 + Center.Of.Mass.Y.SV2) / 2 Compactness.SV = (Compactness.SV1 + Compactness.SV2) / 2 }) responses <- c("PSA","PSA.SV","PSA.TV", "Image.Biomass", "Max.Height","Centre.Mass", "Density", "Compactness.TV", "Compactness.SV") R <- Hmisc::rcorr(as.matrix(longi.dat[responses]))$r results <- PVA(R, responses, p.variance=0.9, plot = FALSE)
data(exampleData) longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1) longi.dat <- within(longi.dat, { Max.Height <- pmax(Max.Dist.Above.Horizon.Line.SV1, Max.Dist.Above.Horizon.Line.SV2) Density <- PSA/Max.Height PSA.SV = (PSA.SV1 + PSA.SV2) / 2 Image.Biomass = PSA.SV * (PSA.TV^0.5) Centre.Mass <- (Center.Of.Mass.Y.SV1 + Center.Of.Mass.Y.SV2) / 2 Compactness.SV = (Compactness.SV1 + Compactness.SV2) / 2 }) responses <- c("PSA","PSA.SV","PSA.TV", "Image.Biomass", "Max.Height","Centre.Mass", "Density", "Compactness.TV", "Compactness.SV") R <- Hmisc::rcorr(as.matrix(longi.dat[responses]))$r results <- PVA(R, responses, p.variance=0.9, plot = FALSE)
A measure of how correlated a variable is with those in a set is given by the
square root of the sum of squares of the correlation coefficients between the
variables and the other variables in the set (Cumming and Wooff, 2007). Here, the partial
correlation between the subset of the variables listed in response
that
are not listed in include
is calculated from the partial correlation matrix
for the subset, adjusting for those variables in include
. This is useful
for manually deciding which of the variables not in include
should next be
added to it.
rcontrib(obj, ...)
rcontrib(obj, ...)
obj |
A |
... |
allows passing of arguments to other functions |
rcontrib
is the generic function for the rcontrib
method.
Use methods("rcontrib") to get all the methods for the rcontrib generic.
rcontrib.data.frame
is a method for a data.frame
.
rcontrib.matrix
is a method for a matrix
.
A numeric
giving the correlation measures.
Chris Brien
Cumming, J. A. and D. A. Wooff (2007) Dimension reduction via principal variables. Computational Statistics and Data Analysis, 52, 550–565.
A measure of how correlated a variable is with those in a set is given by the
square root of the sum of squares of the correlation coefficients between the
variables and the other variables in the set (Cumming and Wooff, 2007). Here, the partial
correlation between the subset of the variables listed in response
that
are not listed in include
is calculated from the partial correlation matrix
for the subset, adjusting for those variables in include
. This is useful
for manually deciding which of the variables not in include
should next be
added to it.
## S3 method for class 'data.frame' rcontrib(obj, responses, include = NULL, ...)
## S3 method for class 'data.frame' rcontrib(obj, responses, include = NULL, ...)
obj |
A |
responses |
A |
include |
A |
... |
allows passing of arguments to other functions. |
A numeric
giving the correlation measures.
Chris Brien
Cumming, J. A. and D. A. Wooff (2007) Dimension reduction via principal variables. Computational Statistics and Data Analysis, 52, 550–565.
rcontrib
, rcontrib.matrix
, PVA
, intervalPVA.data.frame
data(exampleData) longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1) longi.dat <- within(longi.dat, { Max.Height <- pmax(Max.Dist.Above.Horizon.Line.SV1, Max.Dist.Above.Horizon.Line.SV2) Density <- PSA/Max.Height PSA.SV = (PSA.SV1 + PSA.SV2) / 2 Image.Biomass = PSA.SV * (PSA.TV^0.5) Centre.Mass <- (Center.Of.Mass.Y.SV1 + Center.Of.Mass.Y.SV2) / 2 Compactness.SV = (Compactness.SV1 + Compactness.SV2) / 2 }) responses <- c("PSA","PSA.SV","PSA.TV", "Image.Biomass", "Max.Height","Centre.Mass", "Density", "Compactness.TV", "Compactness.SV") h <- rcontrib(longi.dat, responses, include = "PSA")
data(exampleData) longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1) longi.dat <- within(longi.dat, { Max.Height <- pmax(Max.Dist.Above.Horizon.Line.SV1, Max.Dist.Above.Horizon.Line.SV2) Density <- PSA/Max.Height PSA.SV = (PSA.SV1 + PSA.SV2) / 2 Image.Biomass = PSA.SV * (PSA.TV^0.5) Centre.Mass <- (Center.Of.Mass.Y.SV1 + Center.Of.Mass.Y.SV2) / 2 Compactness.SV = (Compactness.SV1 + Compactness.SV2) / 2 }) responses <- c("PSA","PSA.SV","PSA.TV", "Image.Biomass", "Max.Height","Centre.Mass", "Density", "Compactness.TV", "Compactness.SV") h <- rcontrib(longi.dat, responses, include = "PSA")
A measure of how correlated a variable is with those in a set is given by the
square root of the sum of squares of the correlation coefficients between the
variables and the other variables in the set (Cumming and Wooff, 2007). Here, the partial
correlation between the subset of the variables listed in response
that
are not listed in include
is calculated from the partial correlation matrix
for the subset, adjusting for those variables in include
. This is useful
for manually deciding which of the variables not in include
should next be
added to it.
## S3 method for class 'matrix' rcontrib(obj, responses, include = NULL, ...)
## S3 method for class 'matrix' rcontrib(obj, responses, include = NULL, ...)
obj |
A |
responses |
A |
include |
A |
... |
allows passing of arguments to other functions. |
A numeric
giving the correlation measures.
Chris Brien
Cumming, J. A. and D. A. Wooff (2007) Dimension reduction via principal variables. Computational Statistics and Data Analysis, 52, 550–565.
rcontrib
, rcontrib.data.frame
, PVA
, intervalPVA.data.frame
data(exampleData) longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1) longi.dat <- within(longi.dat, { Max.Height <- pmax(Max.Dist.Above.Horizon.Line.SV1, Max.Dist.Above.Horizon.Line.SV2) Density <- PSA/Max.Height PSA.SV = (PSA.SV1 + PSA.SV2) / 2 Image.Biomass = PSA.SV * (PSA.TV^0.5) Centre.Mass <- (Center.Of.Mass.Y.SV1 + Center.Of.Mass.Y.SV2) / 2 Compactness.SV = (Compactness.SV1 + Compactness.SV2) / 2 }) responses <- c("PSA","PSA.SV","PSA.TV", "Image.Biomass", "Max.Height","Centre.Mass", "Density", "Compactness.TV", "Compactness.SV") R <- Hmisc::rcorr(as.matrix(longi.dat[responses]))$r h <- rcontrib(R, responses, include = "PSA")
data(exampleData) longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1) longi.dat <- within(longi.dat, { Max.Height <- pmax(Max.Dist.Above.Horizon.Line.SV1, Max.Dist.Above.Horizon.Line.SV2) Density <- PSA/Max.Height PSA.SV = (PSA.SV1 + PSA.SV2) / 2 Image.Biomass = PSA.SV * (PSA.TV^0.5) Centre.Mass <- (Center.Of.Mass.Y.SV1 + Center.Of.Mass.Y.SV2) / 2 Compactness.SV = (Compactness.SV1 + Compactness.SV2) / 2 }) responses <- c("PSA","PSA.SV","PSA.TV", "Image.Biomass", "Max.Height","Centre.Mass", "Density", "Compactness.TV", "Compactness.SV") R <- Hmisc::rcorr(as.matrix(longi.dat[responses]))$r h <- rcontrib(R, responses, include = "PSA")
The data is the full set of Lanes and Positions from an experiment in a Smarthouse at the Plant Accelerator in Adelaide. It is used in the growthPheno-package
as an executable example to illustrate the use of growthPheno
. The experiment and data collection are described in Al-Tamimi et al. (2016) and the data is derived from the data.frame
in the file 00-raw.0254.dat.rda
that is available from Al-Tamimi et al. (2017); halpf od the unprred data is in RiceRaw.dat
.
data(RicePrepped.dat)
data(RicePrepped.dat)
A data.frame containing 14784 observations on 32 variables. The names of the columns in the data.frame are:
Column | Name | Class | Description |
1 | Smarthouse | factor | the Smarthouse in which a cart occurs. |
2 | Snapshot.ID.Tag | character | a unique identifier for each cart in the experiment. |
3 | xDAP | numeric | the numbers of days after planting on which the current |
data was observed. | |||
4 | DAST | factor | the numbers of days after the salting treatment on which |
the current data was observed. | |||
5 | xDAST | numeric | the numbers of days after the salting treatment on which |
the current data was observed. | |||
6 | cDAST | numeric | a centered numeric covariate for DAST. |
7 | DAST.diffs | numeric | the number of days between this and the previous |
observations (all one for this experiment). | |||
8 | Lane | factor | the Lane in the 24 Lane x 24 Positions grid. |
9 | Position | factor | the Position in the 24 Lane x 24 Positions grid. |
10 | cPosn | numeric | a centered numeric covaariate for Positions. |
11 | cMainPosn | numeric | a centered numeric covaariate for Main plots. |
12 | Zone | factor | the Zone of 4 Lanes to which the current cart belonged. |
13 | cZone | numeric | a centered numeric covariate for Zone. |
14 | SHZone | factor | the Zone numbered across the two Smarthouses. |
15 | ZLane | factor | the number of the Lane within a Zone. |
16 | ZMainunit | factor | the number of the Main plot within a Zone. |
17 | Subunit | factor | the number of a Cart within a Main plot. |
18 | Reps | numeric | the replicate number of each Genotype-Salinity combination. |
19 | Genotype | factor | the number assigned to the 298 Genotypes in the experiment. |
20 | Salinity | factor | the Salinity treatment (Control, Salt) allocated to a Cart. |
21 | PSA | numeric | the Projected shoot area (kpixels). |
22 | PSA.AGR | numeric | the Absolute Growth Rate for the Projected shoot area (kpixels/day). |
23 | PSA.RGR | numeric | the Relative Growth Rate for the Projected shoot area (per day). |
24 | Tr | numeric | the amount of water (g) transpired by a plant. |
25 | TrR | numeric | the rate of water transpireation (g/day) for a plant. |
26 | PSA.TUE | numeric | the Transpiration Use Efficiency for PSA (kpixels / day) |
for a plant. | |||
27 | sPSA | numeric | the smoothed Projected shoot area (kpixels). |
29 | sPSA.AGR | numeric | the smoothed Absolute Growth Rate for the Projected shoot |
area (kpixels/day). | |||
29 | sPSA.RGR | numeric | the smoothed Relative Growth Rate for the Projected shoot |
area (per day). | |||
30 | sTr | numeric | the smoothed amount of water (g) transpired by a plant. |
31 | sTrR | numeric | the smoothed rate of water transpireation (g/day) for a plant. |
32 | sPSA.TUE | numeric | the smoothed Transpiration Use Efficiency for PSA (kpixels / day) |
for a plant. | |||
Al-Tamimi N, Brien C, Oakey H, Berger B, Saade S, Ho YS, Schmockel SM, Tester M, Negrao S. (2017) Data from: Salinity tolerance loci revealed in rice using high-throughput non-invasive phenotyping. Retrieved from: doi:10.5061/dryad.3118j.
Al-Tamimi, N, Brien, C.J., Oakey, H., Berger, B., Saade, S., Ho, Y. S., Schmockel, S. M., Tester, M. and Negrao, S. (2016) New salinity tolerance loci revealed in rice using high-throughput non-invasive phenotyping. Nature Communications, 7, 13342. Retrieved from doi:10.1038/ncomms13342.
The data is half (the first 12 of 24 Lanes) of that from an experiment in a Smarthouse at the Plant Accelerator in Adelaide. It is used in the growthPheno-package
as an executable example to illustrate the use of growthPheno
. The experiment and data collection are described in Al-Tamimi et al. (2016) and the data is derived from the data.frame
in the file 00-raw.0255.dat.rda
that is available from Al-Tamimi et al. (2017).
data(RiceRaw.dat)
data(RiceRaw.dat)
A data.frame containing 7392 observations on 33 variables.
Al-Tamimi N, Brien C, Oakey H, Berger B, Saade S, Ho YS, Schmockel SM, Tester M, Negrao S: Data from: Salinity tolerance loci revealed in rice using high-throughput non-invasive phenotyping. Retrieved from: doi:10.5061/dryad.3118j.
Al-Tamimi, N, Brien, C.J., Oakey, H., Berger, B., Saade, S., Ho, Y. S., Schmockel, S. M., Tester, M. and Negrao, S. (2016) New salinity tolerance loci revealed in rice using high-throughput non-invasive phenotyping. Nature Communications, 7, 13342. Retrieved from doi:10.1038/ncomms13342.
A data.frame
of S3-class smooths.frame
that stores the
smooths of one or more responses for several sets of smoothing parameters.
as.smooths.frame
is function that converts a
data.frame
to an object of this class.
is.smooths.frame
is the membership function for this class; it tests
that an object has class smooths.frame
.
validSmoothsFrame
can be used to test the validity of a
smooths.frame
.
A data.frame
that is also inherits the S3-class
smooths.frame
. It contains the results of smoothing a response
over time from a set of individuals
, the data being arranged in long
format both with respect to the times and the smoothing-parameter values used in
the smoothing. That is, each response occupies a single column. The
smooths.frame
must include the columns Type
, TunePar
,
TuneVal
, Tuning
(the combination of TunePar
and
TuneVal
) and Method
, and the columns that would be nominated using
the probeSmooths
arguments individuals
, the plots
and
facet
arguments, times
, response
, response.smoothed
, and,
if requested, the AGR and the RGR of the response
and response.smoothed
.
The names of the growth rates should be formed from response
and
response.smoothed
by adding .AGR
and .RGR
to both of them.
The function probeSmooths
produces a smooths.frame
for a response.
A smooths.frame
has the following attributes:
individuals
, the character
giving the name of the
factor
that define the subsets of the data
for which each subset corresponds to the response
values for
an individual;
n
, the number of unique individuals
;
times
, the character
giving the name of the
numeric
, or factor
with numeric levels, that
contains the values of the predictor variable plotted on the x-axis;
t
, the number of unique values in the times
;
nschemes
, the number of unique combinations of the
smoothing-parameter values in the smoothsframe
.
Chris Brien
probeSmooths
, is.smooths.frame
,
as.smooths.frame
, validSmoothsFrame
, args4smoothing
dat <- read.table(header = TRUE, text = " Type TunePar TuneVal Tuning Method ID DAP PSA sPSA NCSS df 4 df-4 direct 045451-C 28 57.446 51.18456 NCSS df 4 df-4 direct 045451-C 30 89.306 87.67343 NCSS df 7 df-7 direct 045451-C 28 57.446 57.01589 NCSS df 7 df-7 direct 045451-C 30 89.306 87.01316 ") dat[1:7] <- lapply(dat[1:6], factor) dat <- as.smooths.frame(dat, individuals = "ID", times = "DAP") is.smooths.frame(dat) validSmoothsFrame(dat) data(exampleData) vline <- list(ggplot2::geom_vline(xintercept=29, linetype="longdash", size=1)) smths <- probeSmooths(data = longi.dat, response = "PSA", response.smoothed = "sPSA", times = "DAP", smoothing.args = args4smoothing(smoothing.methods = "direct", spline.types = "NCSS", df = c(4,7), lambdas = NULL), profile.plot.args = args4profile_plot(plots.by = NULL, facet.x = "Tuning", facet.y = "Treatment.1", include.raw = "no", ggplotFuncs = vline)) is.smooths.frame(smths) validSmoothsFrame(smths)
dat <- read.table(header = TRUE, text = " Type TunePar TuneVal Tuning Method ID DAP PSA sPSA NCSS df 4 df-4 direct 045451-C 28 57.446 51.18456 NCSS df 4 df-4 direct 045451-C 30 89.306 87.67343 NCSS df 7 df-7 direct 045451-C 28 57.446 57.01589 NCSS df 7 df-7 direct 045451-C 30 89.306 87.01316 ") dat[1:7] <- lapply(dat[1:6], factor) dat <- as.smooths.frame(dat, individuals = "ID", times = "DAP") is.smooths.frame(dat) validSmoothsFrame(dat) data(exampleData) vline <- list(ggplot2::geom_vline(xintercept=29, linetype="longdash", size=1)) smths <- probeSmooths(data = longi.dat, response = "PSA", response.smoothed = "sPSA", times = "DAP", smoothing.args = args4smoothing(smoothing.methods = "direct", spline.types = "NCSS", df = c(4,7), lambdas = NULL), profile.plot.args = args4profile_plot(plots.by = NULL, facet.x = "Tuning", facet.y = "Treatment.1", include.raw = "no", ggplotFuncs = vline)) is.smooths.frame(smths) validSmoothsFrame(smths)
response
and an x
in a data.frame
,
optionally computing growth rates using derivatives.Uses smooth.spline
to fit a natural cubic smoothing spline or JOPS
to fit a
P-spline to all the values of response
stored in data
.
The amount of smoothing can be controlled by tuning parameters, these being
related to the penalty. For a natural cubic smoothing spline, these are
df
or lambda
and, for a P-spline, it is lambda
.
For a P-spline, npspline.segments
also influences the smoothness of the fit.
The smoothing.method
provides for direct
and logarithmic
smoothing. The method of Huang (2001) for correcting the fitted spline for
estimation bias at the end-points will be applied when fitting using a
natural cubic smoothing spline if correctBoundaries
is TRUE
.
The derivatives of the fitted spline can also be obtained, and the
Absolute and Relative Growth Rates ( AGR and RGR) computed using them, provided
correctBoundaries
is FALSE
. Otherwise, growth rates can be
obtained by difference using byIndv4Times_GRsDiff
.
The handling of missing values in the observations is controlled via
na.x.action
and na.y.action
. If there are not
at least four distinct, nonmissing x-values, a warning is issued and
all smoothed values and derivatives are set to NA
.
The function probeSmooths
can be used to investgate the effect
the smoothing parameters (smoothing.method
and df
or
lambda
) on the smooth that results.
smoothSpline(data, response, response.smoothed = NULL, x, smoothing.method = "direct", spline.type = "NCSS", df = NULL, lambda = NULL, npspline.segments = NULL, correctBoundaries = FALSE, rates = NULL, suffices.rates = NULL, sep.rates = ".", extra.derivs = NULL, suffices.extra.derivs=NULL, na.x.action = "exclude", na.y.action = "trimx", ...)
smoothSpline(data, response, response.smoothed = NULL, x, smoothing.method = "direct", spline.type = "NCSS", df = NULL, lambda = NULL, npspline.segments = NULL, correctBoundaries = FALSE, rates = NULL, suffices.rates = NULL, sep.rates = ".", extra.derivs = NULL, suffices.extra.derivs=NULL, na.x.action = "exclude", na.y.action = "trimx", ...)
data |
A |
response |
A |
response.smoothed |
A |
x |
A |
smoothing.method |
A |
spline.type |
A |
df |
A |
lambda |
A |
npspline.segments |
A |
correctBoundaries |
A |
rates |
A |
suffices.rates |
A |
sep.rates |
A |
extra.derivs |
A |
suffices.extra.derivs |
A |
.
na.x.action |
A |
na.y.action |
A |
... |
allows for arguments to be passed to |
A list
with two components named predictions
and
fit.spline
.
The predictions
component is a data.frame
containing x
and the fitted smooth. The names of the columns will be the value of
x
and the value of response.smoothed
. The number of rows in
the data.frame
will be equal to the number of pairs that have neither
a missing x
or response
and the order of x
will be the
same as the order in data
. If deriv
is not NULL
,
columns containing the values of the derivative(s) will be added to the
data.frame
; the name each of these columns will be the value of
response.smoothed
with .dvf
appended, where f
is the
order of the derivative, or the value of response.smoothed
and the
corresponding element of suffices.deriv
appended. If RGR
is
not NULL
, the RGR is calculated as the ratio of value of the first
derivative of the fitted spline and the fitted value for the spline.
The fit.spline
component is a list
with components
x
:the distinct x values in increasing order;
y
:the fitted values, with boundary values possibly corrected, and corresponding to x
;
lev
:leverages, the diagonal values of the smoother matrix (NCSS only);
lambda
:the value of lambda (corresponding to spar
for NCSS - see smooth.spline
);
df
:the efective degrees of freedom;
npspline.segments
:the number of equally spaced segments used for smoothing method set to PS
;
uncorrected.fit
:the object returned by smooth.spline
for smoothing method
set to NCSS
or by JOPS::psNormal
for PS
.
Chris Brien
Eilers, P.H.C and Marx, B.D. (2021) Practical smoothing: the joys of P-splines. Cambridge University Press, Cambridge.
Huang, C. (2001) Boundary corrected cubic smoothing splines. Journal of Statistical Computation and Simulation, 70, 107-121.
byIndv4Times_SplinesGRs
, probeSmoothing
,
byIndv4Times_GRsDiff
, smooth.spline
, predict.smooth.spline
, JOPS.
data(exampleData) fit <- smoothSpline(longi.dat, response="PSA", response.smoothed = "sPSA", x="xDAP", df = 4, rates = c("AGR", "RGR")) fit <- smoothSpline(longi.dat, response="PSA", response.smoothed = "sPSA", x="xDAP", df = 4, rates = "AGR", suffices.rates = "AGRdv", extra.derivs = 2, suffices.extra.derivs = "Acc") fit <- smoothSpline(longi.dat, response="PSA", response.smoothed = "sPSA", x="xDAP", spline.type = "PS", lambda = 0.1, npspline.segments = 10, rates = "AGR", suffices.rates = "AGRdv", extra.derivs = 2, suffices.extra.derivs = "Acc") fit <- smoothSpline(longi.dat, response="PSA", response.smoothed = "sPSA", x="xDAP", df = 4, rates = "AGR", suffices.rates = "AGRdv")
data(exampleData) fit <- smoothSpline(longi.dat, response="PSA", response.smoothed = "sPSA", x="xDAP", df = 4, rates = c("AGR", "RGR")) fit <- smoothSpline(longi.dat, response="PSA", response.smoothed = "sPSA", x="xDAP", df = 4, rates = "AGR", suffices.rates = "AGRdv", extra.derivs = 2, suffices.extra.derivs = "Acc") fit <- smoothSpline(longi.dat, response="PSA", response.smoothed = "sPSA", x="xDAP", spline.type = "PS", lambda = 0.1, npspline.segments = 10, rates = "AGR", suffices.rates = "AGRdv", extra.derivs = 2, suffices.extra.derivs = "Acc") fit <- smoothSpline(longi.dat, response="PSA", response.smoothed = "sPSA", x="xDAP", df = 4, rates = "AGR", suffices.rates = "AGRdv")
data.frame
, the growth rates for individuals calculated
continuously over time by differencing response values.Uses AGRdiff
, PGR
and
RGRdiff
to calculate growth rates continuously
over time for the response
by differencing pairs of pairs
of response
values and
stores the results in data
. The subsets are those values
with the same levels combinations of the factor
s listed in
individuals
.
Note: this function is soft deprecated and may be removed in
future versions.
Use byIndv4Times_GRsDiff
.
splitContGRdiff(data, responses, individuals = "Snapshot.ID.Tag", INDICES = NULL, which.rates = c("AGR","PGR","RGR"), suffices.rates=NULL, times.factor = "Days", avail.times.diffs = FALSE, ntimes2span = 2)
splitContGRdiff(data, responses, individuals = "Snapshot.ID.Tag", INDICES = NULL, which.rates = c("AGR","PGR","RGR"), suffices.rates=NULL, times.factor = "Days", avail.times.diffs = FALSE, ntimes2span = 2)
data |
A |
responses |
A |
individuals |
A |
INDICES |
A pseudonym for |
which.rates |
A |
times.factor |
A |
avail.times.diffs |
A |
ntimes2span |
A |
suffices.rates |
A |
A data.frame
containing data
to which has been
added 9i) a column for the differences between the times
,
if it is not already in data
, and (ii) columns with growth rates.
The name of the column for times
differences will be the
times
with ".diffs"
appended. The name for each of the
growth-rate columns will be either the value of response
with
one of ".AGR"
, ".PGR"
or "RGR"
, or the
corresponding value from suffices.rates
appended. Each growth
rate will be positioned at observation
ceiling(ntimes2span + 1) / 2
relative to the two times from
which the growth rate is calculated.
Chris Brien
data(exampleData) longi.dat <- splitContGRdiff(data = longi.dat, response="sPSA", times.factor = "DAP", individuals = "Snapshot.ID.Tag", which.rates=c("AGR", "RGR"), avail.times.diffs = TRUE)
data(exampleData) longi.dat <- splitContGRdiff(data = longi.dat, response="sPSA", times.factor = "DAP", individuals = "Snapshot.ID.Tag", which.rates=c("AGR", "RGR"), avail.times.diffs = TRUE)
data.frame
in long formatUses fitSpline
to fit a spline to a subset of the values
of response
and stores the fitted values in data
.
The subsets are those values with the same levels combinations
of the factor
s listed in individuals
. The degree of smoothing
is controlled by the tuning parameters df
and lambda
,
related to the penalty, and by npspline.segments
. The smoothing.method
provides for direct
and logarithmic
smoothing.
The derivatives of the fitted spline can also be obtained, and the
Absolute and Relative Growth Rates ( AGR and RGR) computed using them, provided
correctBoundaries
is FALSE
. Otherwise, growth rates can be
obtained by difference using splitContGRdiff
.
The handling of missing values in the observations is controlled via
na.x.action
and na.y.action
. If there are not
at least four distinct, nonmissing x-values, a warning is issued and
all smoothed values and derivatives are set to NA
.
The function probeSmoothing
can be used to investgate the effect
the smoothing parameters (smoothing.method
, df
or
lambda
) on the smooth that results.
Note: this function is soft deprecated and may be removed in
future versions.
Use byIndv4Times_SplinesGRs
.
splitSplines(data, response, response.smoothed = NULL, x, individuals = "Snapshot.ID.Tag", INDICES = NULL, smoothing.method = "direct", smoothing.segments = NULL, spline.type = "NCSS", df=NULL, lambda = NULL, npspline.segments = NULL, correctBoundaries = FALSE, deriv = NULL, suffices.deriv = NULL, extra.rate = NULL, sep = ".", na.x.action="exclude", na.y.action = "exclude", ...)
splitSplines(data, response, response.smoothed = NULL, x, individuals = "Snapshot.ID.Tag", INDICES = NULL, smoothing.method = "direct", smoothing.segments = NULL, spline.type = "NCSS", df=NULL, lambda = NULL, npspline.segments = NULL, correctBoundaries = FALSE, deriv = NULL, suffices.deriv = NULL, extra.rate = NULL, sep = ".", na.x.action="exclude", na.y.action = "exclude", ...)
data |
A |
response |
A |
response.smoothed |
A |
x |
A |
individuals |
A |
INDICES |
A pseudonym for |
smoothing.method |
A |
smoothing.segments |
A named |
spline.type |
A |
df |
A |
lambda |
A |
npspline.segments |
A |
correctBoundaries |
A |
deriv |
A |
suffices.deriv |
A |
extra.rate |
A named |
sep |
A |
na.x.action |
A |
na.y.action |
A |
... |
allows for arguments to be passed to |
A data.frame
containing data
to which has been
added a column with the fitted smooth, the name of the column being
response.smoothed
. If deriv
is not NULL
,
columns containing the values of the derivative(s) will be added
to data
; the name each of these columns will be the value of
response.smoothed
with .dvf
appended, where f
is the order of the derivative, or the value of response.smoothed
with the corresponding element of suffices.deriv
appended.
If RGR
is not NULL
, the RGR is calculated as the ratio
of value of the first derivative of the fitted spline and the fitted
value for the spline.
Any pre-existing smoothed and derivative columns in data
will be
replaced. The ordering of the data.frame
for the x
values will be preserved as far as is possible; the main difficulty
is with the handling of missing values by the function merge
.
Thus, if missing values in x
are retained, they will occur at
the bottom of each subset of individuals
and the order will be
problematic when there are missing values in y
and
na.y.action
is set to omit
.
Chris Brien
Eilers, P.H.C and Marx, B.D. (2021) Practical smoothing: the joys of P-splines. Cambridge University Press, Cambridge.
Huang, C. (2001) Boundary corrected cubic smoothing splines. Journal of Statistical Computation and Simulation, 70, 107-121.
fitSpline
, probeSmoothing
, splitContGRdiff
,
smooth.spline
, predict.smooth.spline
, split
data(exampleData) #smoothing with growth rates calculated using derivates longi.dat <- splitSplines(longi.dat, response="PSA", x="xDAP", individuals = "Snapshot.ID.Tag", df = 4, deriv=1, suffices.deriv="AGRdv", extra.rate = c(RGRdv = "RGR")) #Use P-splines longi.dat <- splitSplines(longi.dat, response="PSA", x="xDAP", individuals = "Snapshot.ID.Tag", spline.type = "PS", lambda = 0.1, npspline.segments = 10, deriv=1, suffices.deriv="AGRdv", extra.rate = c(RGRdv = "RGR")) #with segmented smoothing longi.dat <- splitSplines(longi.dat, response="PSA", x="xDAP", individuals = "Snapshot.ID.Tag", smoothing.segments = list(c(28,34), c(35,42)), df = 5)
data(exampleData) #smoothing with growth rates calculated using derivates longi.dat <- splitSplines(longi.dat, response="PSA", x="xDAP", individuals = "Snapshot.ID.Tag", df = 4, deriv=1, suffices.deriv="AGRdv", extra.rate = c(RGRdv = "RGR")) #Use P-splines longi.dat <- splitSplines(longi.dat, response="PSA", x="xDAP", individuals = "Snapshot.ID.Tag", spline.type = "PS", lambda = 0.1, npspline.segments = 10, deriv=1, suffices.deriv="AGRdv", extra.rate = c(RGRdv = "RGR")) #with segmented smoothing longi.dat <- splitSplines(longi.dat, response="PSA", x="xDAP", individuals = "Snapshot.ID.Tag", smoothing.segments = list(c(28,34), c(35,42)), df = 5)
Splits the values of a response into subsets corresponding
individuals and applies a function that calculates a single
value from each individual's observations.
It includes the ability to calculate the observation number
that is closest to the calculated value of the function and
the assocated values of a factor
or numeric
.
Note: this function is soft deprecated and may be removed in
future versions.
Use byIndv_ValueCalc
.
splitValueCalculate(response, weights=NULL, individuals = "Snapshot.ID.Tag", FUN = "max", which.obs = FALSE, which.values = NULL, data, na.rm=TRUE, sep=".", ...)
splitValueCalculate(response, weights=NULL, individuals = "Snapshot.ID.Tag", FUN = "max", which.obs = FALSE, which.values = NULL, data, na.rm=TRUE, sep=".", ...)
response |
A |
weights |
A |
individuals |
A |
FUN |
A |
which.obs |
A |
which.values |
A |
data |
A |
na.rm |
A |
sep |
A |
... |
allows for arguments to be passed to |
A data.frame
, with the same number of rows as there are
individuals
, containing a column for the individuals
and
a column with the values of the function for the individuals
.
It is also possible to determine observaton numbers or the values of
another column in data
for the response
values that are
closest to the FUN
results, using either or both of
which.obs
and which.values
. If which.obs
is
TRUE
, a column with observation numbers is included in the
data.frame
.
If which.values
is set to the name of a factor
or
a numeric
,a column containing the levels of that
factor
or the values of that numeric
is
included in the data.frame
.
The name of the column with the values of the function will be formed by
concatenating the response
and FUN
, separated by a full stop.
If which.obs
is TRUE
, the column name for the obervations
numbers will have .obs
added after FUN
into the column name
for the function values; if which.values
is specified,
the column name for these values will have a full stop followed by
which.values
added after FUN
into the column name
for the function values.
Chris Brien
intervalValueCalculate
, splitContGRdiff
,
splitSplines
data(exampleData) sPSA.max.dat <- splitValueCalculate("sPSA", data = longi.dat) AGR.max.dat <- splitValueCalculate("sPSA.AGR", FUN="max", data=longi.dat, which.values = "DAP", which.obs = TRUE) sPSA.dec1.dat <- splitValueCalculate("sPSA", FUN="quantile", data=longi.dat, which.values = "DAP", probs = 0.1)
data(exampleData) sPSA.max.dat <- splitValueCalculate("sPSA", data = longi.dat) AGR.max.dat <- splitValueCalculate("sPSA.AGR", FUN="max", data=longi.dat, which.values = "DAP", which.obs = TRUE) sPSA.dec1.dat <- splitValueCalculate("sPSA", FUN="quantile", data=longi.dat, which.values = "DAP", probs = 0.1)
The data is from an experiment in a Smarthouse in the Plant Accelerator and is decribed by Watts-Williams et al. (2019). The experiment involves 32 plants, each placed in a pot in a cart, and the carts were assigned 8 treatments using a randomized complete-block design. The main response is Projected Shoot Area (PSA for short), being the sum of the plant pixels from three images. The eight treatments were the combinations of 4 Zinc (Zn) levels by two Arbuscular Mycorrhiza Fungi (AMF) levls. Each plant was imaged on 35 different days after planting (DAPs). It is used to explore the analysis of growth dynamics.
data(tomato.dat)
data(tomato.dat)
A data.frame containing 1120 observations on 16 variables. The names of the columns in the data.frame are:
Column | Name | Class | Description |
1 | Lane | factor | the Lane in the 2 Lane x 16 Positions grid. |
2 | Position | factor | the Position in the 2 Lane x 16 Positions grid. |
3 | DAP | factor | the numbers of days after planting on which the current |
data was observed. | |||
4 | Snapshot.ID.Tag | character | a unique identifier for each cart in the experiment. |
5 | cDAP | numeric | a centered numeric covariate for DAP. |
6 | DAP.diffs | numeric | the number of days between this and the previous |
observations (all one for this experiment). | |||
7 | cPosn | numeric | a centered numeric covaariate for Positions. |
8 | Block | factor | the block of the randomized complete-block design to |
which the current cart belonged. | |||
9 | Cart | factor | the number of the cart within a block. |
10 | AMF | factor | the AMF treatment (- AMF, +AMF) assigned to the |
cart. | |||
11 | Zn | factor | the Zinc level (0, 10, 40, 90) assigned to the cart. |
12 | Treatments | factor | the combined factor formed from AMF and Zn with |
levels: (-,0; -,10; -,40; -,90; +,0; +,10; +,40; +,90). | |||
12 | Weight.After | numeric | the weight of the cart after watering. |
13 | Water.Amount | numeric | the weight of the water added to the cart. |
14 | WU | numeric | the weight of the water used since the previous watering. |
15 | PSA | numeric | the Projected Shoot Area, being the total number of |
plant pixels in three plant images. |
Watts-Williams SJ, Jewell N, Brien C, Berger B, Garnett T, Cavagnaro TR (2019) Using high-throughput phenotyping to explore growth responses to mycorrhizal fungi and zinc in three plant species. Plant Phenomics, 2019, 12.
Extract one or more sets of features from traits observed over time, the result being traits that have a single value for each individual. The sets of features are:
single times – the value for each individual for a single time.
(uses getTimesSubset
)
growth rates for a time interval – the average growth rate (AGR
and/or RGR) over a time interval for each individual.
(uses byIndv4Intvl_GRsDiff
or byIndv4Intvl_GRsAvg
)
water use traits for a time interval – the total water use (WU),
the water use rate (WUR) and the water use index (WUI) over a time
interval for each individual. (uses byIndv4Intvl_WaterUse
)
growth rates for the imaging period overall – the average growth rate (AGR
and/or RGR) over the whole imaging period for each individual.
(uses byIndv4Intvl_GRsDiff
or byIndv4Intvl_GRsAvg
)
water use traits for the imaging period overall – the total water use (WU),
the water use rate (WUR) and the water use index (WUI) for the whole imaging
period for each individual. (uses byIndv4Intvl_WaterUse
)
totals for the imaging period overall – the total over the whole imaging
period of a trait for each individual. (uses byIndv4Intvl_ValueCalc
)
maximum for the imaging period overall – the maximum value over the whole
imaging period, and the time at which it occurred, for each individual.
(uses byIndv4Intvl_ValueCalc
)
The Tomato
vignette illustrates the use of traitSmooth
and
traitExtractFeatures
to carry out the SET procedure for the example
presented in Brien et al. (2020).
Use vignette("Tomato", package = "growthPheno")
to access it.
traitExtractFeatures(data, individuals = "Snapshot.ID.Tag", times = "DAP", starts.intvl = NULL, stops.intvl = NULL, suffices.intvl = NULL, responses4intvl.rates = NULL, growth.rates = NULL, growth.rates.method = "differences", suffices.growth.rates = NULL, water.use4intvl.traits = NULL, responses4water = NULL, water.trait.types = c("WU", "WUR", "WUI"), suffix.water.rate = "R", suffix.water.index = "I", responses4singletimes = NULL, times.single = NULL, responses4overall.rates = NULL, water.use4overall.water = NULL, responses4overall.water = NULL, responses4overall.totals = NULL, responses4overall.max = NULL, intvl.overall = NULL, suffix.overall = NULL, sep.times.intvl = "to", sep.suffix.times = ".", sep.growth.rates = ".", sep.water.traits = "", mergedata = NULL, ...)
traitExtractFeatures(data, individuals = "Snapshot.ID.Tag", times = "DAP", starts.intvl = NULL, stops.intvl = NULL, suffices.intvl = NULL, responses4intvl.rates = NULL, growth.rates = NULL, growth.rates.method = "differences", suffices.growth.rates = NULL, water.use4intvl.traits = NULL, responses4water = NULL, water.trait.types = c("WU", "WUR", "WUI"), suffix.water.rate = "R", suffix.water.index = "I", responses4singletimes = NULL, times.single = NULL, responses4overall.rates = NULL, water.use4overall.water = NULL, responses4overall.water = NULL, responses4overall.totals = NULL, responses4overall.max = NULL, intvl.overall = NULL, suffix.overall = NULL, sep.times.intvl = "to", sep.suffix.times = ".", sep.growth.rates = ".", sep.water.traits = "", mergedata = NULL, ...)
data |
A |
individuals |
A |
times |
A |
starts.intvl |
A |
stops.intvl |
A |
suffices.intvl |
A |
responses4intvl.rates |
A |
growth.rates.method |
A |
growth.rates |
A |
suffices.growth.rates |
A |
water.use4intvl.traits |
A |
responses4water |
A See the |
water.trait.types |
A |
suffix.water.rate |
A |
suffix.water.index |
A |
responses4singletimes |
A |
times.single |
A |
responses4overall.rates |
A |
water.use4overall.water |
A |
responses4overall.water |
A |
responses4overall.totals |
A |
responses4overall.max |
A |
intvl.overall |
A |
suffix.overall |
A |
sep.times.intvl |
A |
sep.suffix.times |
A |
sep.growth.rates |
A |
sep.water.traits |
A |
mergedata |
A |
... |
allows passing of arguments to other functions; not used at present. |
A data.frame
that contains an individuals
column and a
column for each extracted trait, in addition to any columns in mergedata
.
The number of rows in the data.frame
will equal the number of
unique element of the individuals
column in data
, except when
there are extra values in the individuals
column in data
. If the
latter applies, then the number of rows will equal the number of unique
values in the combined individuals
columns from mergedata
and
data
.
The names of the columns produced by the function are constructed as follows:
single times – A name for a single-time trait is formed by appending
a full stop to an element of responses4singletimes
, followed by the value of
times
at which the values were observed.
growth rates for a time interval – The name for an interval growth
rate is constructed by concatenating the relevant element of responses4intvl.rates
,
growth.rates
and a suffix for the time interval, each separated by a full
stop. The interval suffix is formed by joining its starts.intvl
and
stops.intvl
values, separating them by the value of sep.times.intvl
.
growth rates for the whole imaging period – The name for an interval growth
rate is constructed by concatenating the relevant element of responses4intvl.rates
,
growth.rates
and suffix.overall
, each separated by a full
stop.
water use traits for a time interval – Construction of the names for
the three water traits begins with the value of water.use4intvl.traits
. The rate (WUR)
has either R
or the value of suffix.water.rate
added to the value of
water.use4intvl.traits
. Similarly the index (WUI) has either I
or the value of
suffix.water.index
added to it. The WUI also has the element of
responses4water
used in calculating the WUI prefixed to its name.
All three water use traits have a suffix for the interval appended to their names.
This suffix is contructed by joining its starts.intvl
and stops.intvl
,
separated by the value of sep.times.intvl
.
water use traits for the whole imaging period – Construction of the names for
the three water traits begins with the value of water.use4intvl.traits
. The rate (WUR)
has either R
or the value of suffix.water.rate
added to the value of
water.use4intvl.traits
. Similarly the index (WUI) has either I
or the value of
suffix.water.index
added to it. The WUI also has the element of
responses4water
used in calculating the WUI prefixed to its name.
All three water use traits have suffix.overall
appended to their names.
the total for the whole of imaging period – The name for whole-of-imaging
total is formed by combining an element ofresponses4overall.totals
with suffix.overall
,
separating them by a full stop.
maximum for the whole of imaging period – The name of the column with the
maximum values will be the result of concatenating the responses4overall.max
, "max"
and suffix.overall
, each separated by a full stop. The name of the column with
the value of times
at which the maximum occurred will be the result of
concatenating the responses4overall.max
, "max"
and the value of times
,
each separated by a full stop.
The data.frame
is returned invisibly.
Chris Brien
Brien, C., Jewell, N., Garnett, T., Watts-Williams, S. J., & Berger, B. (2020). Smoothing and extraction of traits in the growth analysis of noninvasive phenotypic data. Plant Methods, 16, 36. doi:10.1186/s13007-020-00577-6.
getTimesSubset
, byIndv4Intvl_GRsAvg
,
byIndv4Intvl_GRsDiff
, byIndv4Intvl_WaterUse
, byIndv_ValueCalc
.
#Load dat data(tomato.dat) #Define DAP constants DAP.endpts <- c(18,22,27,33,39,43,51) nDAP.endpts <- length(DAP.endpts) DAP.starts <- DAP.endpts[-nDAP.endpts] DAP.stops <- DAP.endpts[-1] DAP.segs <- list(c(DAP.endpts[1]-1, 39), c(40, DAP.endpts[nDAP.endpts])) #Add PSA rates and smooth PSA, also producing sPSA rates tom.dat <- byIndv4Times_SplinesGRs(data = tomato.dat, response = "PSA", response.smoothed = "sPSA", times = "DAP", rates.method = "differences", smoothing.method = "log", spline.type = "PS", lambda = 1, smoothing.segments = DAP.segs) #Smooth WU tom.dat <- byIndv4Times_SplinesGRs(data = tom.dat, response = "WU", response.smoothed = "sWU", rates.method = "none", times = "DAP", smoothing.method = "direct", spline.type = "PS", lambda = 10^(-0.5), smoothing.segments = DAP.segs) #Extract single-valued traits for each individual indv.cols <- c("Snapshot.ID.Tag", "Lane", "Position", "Block", "Cart", "AMF", "Zn") indv.dat <- subset(tom.dat, subset = DAP == DAP.endpts[1], select = indv.cols) indv.dat <- traitExtractFeatures(data = tom.dat, starts.intvl = DAP.starts, stops.intvl = DAP.stops, responses4singletimes = "sPSA", responses4intvl.rates = "sPSA", growth.rates = c("AGR", "RGR"), water.use4intvl.traits = "sWU", responses4water = "sPSA", responses4overall.totals = "sWU", responses4overall.max = "sPSA.AGR", mergedata = indv.dat)
#Load dat data(tomato.dat) #Define DAP constants DAP.endpts <- c(18,22,27,33,39,43,51) nDAP.endpts <- length(DAP.endpts) DAP.starts <- DAP.endpts[-nDAP.endpts] DAP.stops <- DAP.endpts[-1] DAP.segs <- list(c(DAP.endpts[1]-1, 39), c(40, DAP.endpts[nDAP.endpts])) #Add PSA rates and smooth PSA, also producing sPSA rates tom.dat <- byIndv4Times_SplinesGRs(data = tomato.dat, response = "PSA", response.smoothed = "sPSA", times = "DAP", rates.method = "differences", smoothing.method = "log", spline.type = "PS", lambda = 1, smoothing.segments = DAP.segs) #Smooth WU tom.dat <- byIndv4Times_SplinesGRs(data = tom.dat, response = "WU", response.smoothed = "sWU", rates.method = "none", times = "DAP", smoothing.method = "direct", spline.type = "PS", lambda = 10^(-0.5), smoothing.segments = DAP.segs) #Extract single-valued traits for each individual indv.cols <- c("Snapshot.ID.Tag", "Lane", "Position", "Block", "Cart", "AMF", "Zn") indv.dat <- subset(tom.dat, subset = DAP == DAP.endpts[1], select = indv.cols) indv.dat <- traitExtractFeatures(data = tom.dat, starts.intvl = DAP.starts, stops.intvl = DAP.stops, responses4singletimes = "sPSA", responses4intvl.rates = "sPSA", growth.rates = c("AGR", "RGR"), water.use4intvl.traits = "sWU", responses4water = "sPSA", responses4overall.totals = "sWU", responses4overall.max = "sPSA.AGR", mergedata = indv.dat)
data.frame
.Takes a response
that has been observed for a set of
individuals
over a number times
and carries out one or more of the following steps:
Produces response.smoothed
using splines for a set of
smoothing parameter settings and, optionally, computes growth
rates either as differences or derivatives.
(see smoothing.args
below and args4smoothing
)
This step is bypassed if a data.frame
that is also of
class smooths.frame
is supplied to data
.
Produces profile plots of response.smoothed
and its
growth rates that compare the smooths; also, boxplots of the
deviations of the observed from smoothed data can be obtained.
(see profile.plot.args
below and args4profile_plot
)
Whether these plots are produced is controlled via which.plots
or
whether profile.plot.args
is set to NULL
.
Produces plots of the medians of the deviations of
the observed response
, and its growth rates, from response.smoothed
,
and its growth rates. These aid in the assessment of the different smooths.
(see meddevn.plot.args
below and args4meddevn_plot
)
Whether these plots are produced is controlled via which.plots
or
whether meddevn.plot.args
is set to NULL
.
Produces boxplots of the absolute or relative deviations
of the observed response
, and its growth rates, from response.smoothed
,
and its growth rates. These aid in the assessment of the different smooths.
(see devnboxes.plot.args
below and args4devnboxes_plot
)
Whether these plots are produced is controlled via which.plots
or
whether devnboxes.plot.args
is set to NULL
.
Extract a single, favoured response.smoothed
,
and its growth rates, for a chosen set of smoothing parameter settings.
(see chosen.smooth.args
below and args4chosen_smooth
)
This step will be omitted if chosen.smooth.args
is NULL
.
Produces profile plots of the chosen smooth and its growth rates.
(see chosen.plot.args
below and args4chosen_plot
)
Whether these plots are produced is controlled by whether
chosen.plot.args
is set to NULL
.
Each of the 'args4
' functions has a set of defaults that will be used if
the corresponding argument, ending in '.args
', is omitted. The defaults
have been optimized for traitSmooth
.
Input to the function can be either a data.frame
, that contains data to
be smoothed, or a smooths.frame
, that contains data that has been smoothed.
The function can be run (i) without saving any output, (ii) saving the complete set
of smooths in a data.frame
that is also of class smooths.frame
,
(iii) saving a subset of the smooths in a supplied smooths.frame
, or
(iv) saving a single smooth in a data.frame
, which can be merged
with a pre-existing data.frame
such as the data.frame
that contains the unsmoothed data.
The Tomato
vignette illustrates the use of traitSmooth
and
traitExtractFeatures
to carry out the SET procedure for the example
presented in Brien et al. (2020).
Use vignette("Tomato", package = "growthPheno")
to access it.
traitSmooth(data, response, response.smoothed, individuals, times, keep.columns = NULL, get.rates = TRUE, rates.method="differences", ntimes2span = NULL, trait.types = c("response", "AGR", "RGR"), smoothing.args = args4smoothing(), x.title = NULL, y.titles = NULL, which.plots = c("profiles", "medians.deviations"), profile.plot.args = args4profile_plot(), meddevn.plot.args = args4meddevn_plot(), devnboxes.plot.args = args4devnboxes_plot(), chosen.smooth.args = args4chosen_smooth(), chosen.plot.args = args4chosen_plot(), mergedata = NULL, ...)
traitSmooth(data, response, response.smoothed, individuals, times, keep.columns = NULL, get.rates = TRUE, rates.method="differences", ntimes2span = NULL, trait.types = c("response", "AGR", "RGR"), smoothing.args = args4smoothing(), x.title = NULL, y.titles = NULL, which.plots = c("profiles", "medians.deviations"), profile.plot.args = args4profile_plot(), meddevn.plot.args = args4meddevn_plot(), devnboxes.plot.args = args4devnboxes_plot(), chosen.smooth.args = args4chosen_smooth(), chosen.plot.args = args4chosen_plot(), mergedata = NULL, ...)
data |
A |
response |
A |
response.smoothed |
A |
individuals |
A |
times |
A |
keep.columns |
A |
get.rates |
A |
rates.method |
A |
ntimes2span |
A |
trait.types |
A |
smoothing.args |
A |
x.title |
Title for the x-axis, used for all plots. If |
y.titles |
A |
which.plots |
A |
profile.plot.args |
A named |
meddevn.plot.args |
A named |
devnboxes.plot.args |
A named |
chosen.smooth.args |
A named |
chosen.plot.args |
A named |
mergedata |
A |
... |
allows arguments to be passed to |
This function is a wrapper function for probeSmooths
,
plotSmoothsComparison
, plotSmoothsComparison
and plotDeviationsBoxes
. It uses the helper functions
args4smoothing
, args4profile_plot
and
args4meddevn_plot
to se arguments that control the smoothing
and plotting.
It takes a response
that has been observed for a set of
individuals
over a number times
and produces
response.smoothed
, using probeSmooths
, for a default
set of smoothing parameter settings (see args4smoothing
for the defaults). The settings can be varied from the defaults by
specifying alternate values for the smoothing parameters, the parameters
being the type of spline (spline.types
), the degrees of freedom
(df
) or smoothing penalty (lambdas
) and smoothing.methods
.
There are also several other smoothing arguments that can be manipulated to
affect the smooth (for details see args4smoothing
).
The secondary traits of the absolute growth rate (AGR
) and relative
growth rate (RGR
) are calculated from the two primary traits, the
response
and response.smoothed
.
Generally, profile plots for the traits (a response, an AGR or an RGR)
specified in traits.types
are produced if which.plots
is
profiles
; if which.plots
specifies one or more deviations
plots, then those deviations plots will also be produced, these being
based on the unsmoothed data from which the smoothed data has been
subtracted. The layout of the plots is controlled via combinations of
one or more of the smoothing-parameter factor
s Type
,
TunePar
, TuneVal
, Tuning
(the combination
of TunePar
and TuneVal
) and Method
, as well as
other factor
s associated with the data
.
The factor
s that are to be used for the profile plots and
deviations boxplots are supplied via the argument profile.plot.args
using the helper function args4profile_plot
to set
plots.by
, facet.x
, and facet.y
; for the plots of
the medians of the deviations, the factor
s are supplied via
the argument meddevn.plot.args
using the helper function
args4meddevn_plot
to set plots.by
, facet.x
,
facet.y
and plots.group
. Here, the basic principle is that
the number of levels combinations of the smoothing-parameter
factor
s included in the set of plots
and
facets
arguments to one of these helper functions must be the same
as those covered by the combinations of the values supplied to
spline.types
, df
, lambdas
and smoothing.methods
and incorporated into the smooths.frame
, such as is
returned by probeSmooths
. This ensures that smooths
from different parameter sets are not pooled together in a single plot.
It is also possible to include factor
s that are not
smoothing-parameter factor
s in the plots
amd
facets
arguments.
The following profiles plots can be produced using
args4profile_plot
: (i) separate plots of the
smoothed traits for each combination of the smoothing parameters
(include Type
, Tuning
and Method
in plots.by
);
(ii) as for (i), with the corresponding plot for the unsmoothed trait
preceeding the plots for the smoothed trait (also set include.raw
to
alone
); (iii) profiles plots that compare a smoothed trait for all
combinations of the values of the smoothing parameters, arranging the plots
side-by-side or one above the other (include Type
, Tuning
and
Method
in facet.x
and/or facet.y
- to include the
unsmoothed trait set include.raw
to one of facet.x
or
facet.y
; (iv) as for (iii), except that separate plots are
produced for each combination of the levels of the factor
s
in plot.by
and each plot compares the smoothed traits for the
smoothing-parameter factor
s included in facet.x
and/or facet.y
(set both plots.by
and one or more of
facet.x
and facet.y
).
Deviation plots that can be produced are the absolute and relative deviations
boxplots and plots of medians deviations (see which.plots
).
By default, the single smooth for an arbitrarily chosen combination of the
smoothing parameters is returned by the function. The smooth for a single
combination other than default combination can be nominated for return
using the chosen.smooth.args
argument. This combination must involve
only the supplied values of the smoothing parameters. The values for
response
, the response.smoothed
and their AGR
s
and RGR
s are are added to data
, after any pre-existing
columns of these have been removed from data
. Profile plots of
the three smoothed traits are produced using plotProfiles
.
However, if chosen.smooth.args
is NULL
, all of the smooths will be
returned in a smooths.frame
, and plots for the single
combination of the smoothing parameters will not be produced.
A smooths.frame
or a data.frame
that contains
the unsmoothed and smoothed data in long format. That is, all the values for
either an unsmoothed or a smoothed trait are in a single column.
A smooths.frame
will be returned when (i) chosen.smooth.args
is NULL
and there is more than one smooth specified by the smoothing
parameter arguments, or (ii) chosen.smooth.args
is not NULL
but
mergedata
is NULL
. It will contain the smooths for a trait for the
different combinatons of the smoothing parameters, the values for the different
smooths being placed in rows one below the other. The columns that are included
in the smooths.frame
are Type
, TunePar
,
TuneVal
, Tuning
and Method
, as well as those specified by
individuals
, times
, response
, and response.smoothed
,
and any included in the keep.columns
, plots
and facet
arguments when the smooths were produced. The AGR
or RGR
for the
response
and response.smoothed
, if obtained, will also be
included. A smooths.frame
has the attributes described in
smooths.frame
.
A data.frame
will be returned when (i) chosen.smooth.args
and mergedata
are not NULL
or (ii) chosen.smooth.args
is
NULL
, data
is not a smooths.frame
and there is only one
smooth specified by the smoothing parameter arguments. In either case, if
mergedata
is not NULL
, the chosen smooth or the single smooth
will be merged with the data.frame
specified by mergedata
.
When there is a single smooth and both mergedata
and
chosen.smooth.args
are NULL
, the data.frame
will
include the columns individuals
, times
, response
, and
response.smoothed
, and any included in the keep.columns
,
plots
and facet
arguments, as well as any growth rates calculated
as a result of get.rates
and trait.type
.
The smooths.frame
/data.frame
is returned invisibly.
Chris Brien
Brien, C., Jewell, N., Garnett, T., Watts-Williams, S. J., & Berger, B. (2020). Smoothing and extraction of traits in the growth analysis of noninvasive phenotypic data. Plant Methods, 16, 36. doi:10.1186/s13007-020-00577-6.
args4smoothing
, args4meddevn_plot
, args4profile_plot
,
args4chosen_smooth
, args4chosen_plot
, probeSmooths
plotSmoothsComparison
and plotSmoothsMedianDevns
, ggplot
.
data(exampleData) longi.dat <- longi.dat[1:140,] #reduce to a smaller data set vline <- list(ggplot2::geom_vline(xintercept=29, linetype="longdash", linewidth=1)) yfacets <- c("Smarthouse", "Treatment.1") smth.dat <- traitSmooth(data = longi.dat, response = "PSA", response.smoothed = "sPSA", individuals = "Snapshot.ID.Tag",times = "DAP", keep.columns = yfacets, smoothing.args = args4smoothing(df = c(5,7), lambda = list(PS = c(0.316,10))), profile.plot.args = args4profile_plot(facet.y = yfacets, ggplotFuncs = vline), chosen.plot.args = args4chosen_plot(facet.y = yfacets, ggplotFuncs = vline))
data(exampleData) longi.dat <- longi.dat[1:140,] #reduce to a smaller data set vline <- list(ggplot2::geom_vline(xintercept=29, linetype="longdash", linewidth=1)) yfacets <- c("Smarthouse", "Treatment.1") smth.dat <- traitSmooth(data = longi.dat, response = "PSA", response.smoothed = "sPSA", individuals = "Snapshot.ID.Tag",times = "DAP", keep.columns = yfacets, smoothing.args = args4smoothing(df = c(5,7), lambda = list(PS = c(0.316,10))), profile.plot.args = args4profile_plot(facet.y = yfacets, ggplotFuncs = vline), chosen.plot.args = args4chosen_plot(facet.y = yfacets, ggplotFuncs = vline))
Takes pairs of values for a set of responses indexed by a two-level
treatment.factor
and calculates, for each of pair,
the result of applying a binary operation
to their values
for the two levels of the treatment.factor
. The level of the
treatment.factor
designated the control
will be
on the right of the binary operator and the value for the other
level will be on the left.
twoLevelOpcreate(data, responses, treatment.factor = "Treatment.1", suffices.treatment = c("Cont","Salt"), control = 1, columns.suffixed = NULL, operations = "/", suffices.results="OST", columns.retained = c("Snapshot.ID.Tag","Smarthouse","Lane", "Zone","cZone","SHZone","ZLane", "ZMainunit","cMainPosn", "Genotype.ID"), by = c("Smarthouse","Zone","ZMainunit"))
twoLevelOpcreate(data, responses, treatment.factor = "Treatment.1", suffices.treatment = c("Cont","Salt"), control = 1, columns.suffixed = NULL, operations = "/", suffices.results="OST", columns.retained = c("Snapshot.ID.Tag","Smarthouse","Lane", "Zone","cZone","SHZone","ZLane", "ZMainunit","cMainPosn", "Genotype.ID"), by = c("Smarthouse","Zone","ZMainunit"))
data |
A |
responses |
A |
treatment.factor |
A |
suffices.treatment |
A |
control |
A |
columns.suffixed |
A |
operations |
A |
suffices.results |
A |
columns.retained |
A |
by |
A |
A data.frame
containing the following columns and the values of the :
those from data
nominated in columns.retained
;
those containing the treated values of the columns whose names
are specified in responses
; the treated values are
those having the other level of treatment.factor
to
that specified by control
;
those containing the control
values of the columns whose
names are specified in responses
; the control values are
those having the level of treatment.factor
specified
by control
;
those containing the values calculated using the binary
operations
; the names of these columns will be
constructed from responses
by appending
suffices.results
to them.
Chris Brien
data(exampleData) responses <- c("sPSA.AGR","sPSA.RGR") cols.retained <- c("Snapshot.ID.Tag","Smarthouse","Lane","Position", "DAP","Snapshot.Time.Stamp", "Hour", "xDAP", "Zone","cZone","SHZone","ZLane","ZMainunit", "cMainPosn", "Genotype.ID") longi.SIIT.dat <- twoLevelOpcreate(data = longi.dat, responses = responses, suffices.treatment=c("C","S"), operations = c("-", "/"), suffices.results = c("diff", "SIIT"), columns.retained = cols.retained, by = c("Smarthouse","Zone","ZMainunit","DAP")) longi.SIIT.dat <- with(longi.SIIT.dat, longi.SIIT.dat[order(Smarthouse,Zone,ZMainunit,DAP),])
data(exampleData) responses <- c("sPSA.AGR","sPSA.RGR") cols.retained <- c("Snapshot.ID.Tag","Smarthouse","Lane","Position", "DAP","Snapshot.Time.Stamp", "Hour", "xDAP", "Zone","cZone","SHZone","ZLane","ZMainunit", "cMainPosn", "Genotype.ID") longi.SIIT.dat <- twoLevelOpcreate(data = longi.dat, responses = responses, suffices.treatment=c("C","S"), operations = c("-", "/"), suffices.results = c("diff", "SIIT"), columns.retained = cols.retained, by = c("Smarthouse","Zone","ZMainunit","DAP")) longi.SIIT.dat <- with(longi.SIIT.dat, longi.SIIT.dat[order(Smarthouse,Zone,ZMainunit,DAP),])
smooths.frame
.Checks that an object
is a smooths.frame
of S3-class data.frame
that contains the columns
Type
, TunePar
, TuneVal
, Tuning
,
Method
, as well as the columns specified by the
atttributes of the object
, namely individuals
and times
.
validSmoothsFrame(object)
validSmoothsFrame(object)
object |
TRUE
or a character
describing why the object
is not a valid smooths.frame
.
Chris Brien
is.smooths.frame
, as.smooths.frame
dat <- read.table(header = TRUE, text = " Type TunePar TuneVal Tuning Method ID DAP PSA sPSA NCSS df 4 df-4 direct 045451-C 28 57.446 51.18456 NCSS df 4 df-4 direct 045451-C 30 89.306 87.67343 NCSS df 7 df-7 direct 045451-C 28 57.446 57.01589 NCSS df 7 df-7 direct 045451-C 30 89.306 87.01316 ") dat[1:7] <- lapply(dat[1:6], factor) dat <- as.smooths.frame(dat, individuals = "ID", times = "DAP") is.smooths.frame(dat) validSmoothsFrame(dat)
dat <- read.table(header = TRUE, text = " Type TunePar TuneVal Tuning Method ID DAP PSA sPSA NCSS df 4 df-4 direct 045451-C 28 57.446 51.18456 NCSS df 4 df-4 direct 045451-C 30 89.306 87.67343 NCSS df 7 df-7 direct 045451-C 28 57.446 57.01589 NCSS df 7 df-7 direct 045451-C 30 89.306 87.01316 ") dat[1:7] <- lapply(dat[1:6], factor) dat <- as.smooths.frame(dat, individuals = "ID", times = "DAP") is.smooths.frame(dat) validSmoothsFrame(dat)
Calculates the Water Use Index, returning NA
if the water use is zero.
WUI(response, water)
WUI(response, water)
response |
A |
water |
A |
A numeric
containing the response divided by the water, unless water is
zero in which case NA
is returned.
Chris Brien
data(exampleData) PSA.WUE <- with(longi.dat, WUI(PSA.AGR, WU))
data(exampleData) PSA.WUE <- with(longi.dat, WUI(PSA.AGR, WU))