| Version: | 3.1.18 | 
| Date: | 2025-10-19 | 
| Title: | Functional Analysis of Phenotypic Growth Data to Smooth and Extract Traits | 
| Depends: | R (≥ 3.5.0) | 
| Imports: | dae, dplyr, GGally, ggplot2, grDevices, Hmisc, JOPS, methods, RColorBrewer, readxl, reshape, stats, stringi, utils | 
| Suggests: | testthat, nlme, R.rsp, scales | 
| VignetteBuilder: | R.rsp | 
| 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/. | 
| License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] | 
| URL: | http://chris.brien.name/ | 
| BugReports: | https://github.com/briencj/growthPheno/issues | 
| RoxygenNote: | 5.0.1 | 
| NeedsCompilation: | no | 
| Packaged: | 2025-10-19 01:07:52 UTC; briencj | 
| Author: | Chris Brien | 
| Maintainer: | Chris Brien <chris.brien@adelaide.edu.au> | 
| Repository: | CRAN | 
| Date/Publication: | 2025-10-19 05:30:02 UTC | 
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/>.
Version: 3.1.18
Date: 2025-10-19
Index
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 listof the values for the options of | 
| profile plots for the chosen smooth. | |
| args4chosen_smooth | Creates a listof the values for the smoothing | 
| parameters for which a smooth is to be extracted. | |
| args4meddevn_plot | Creates a listof the values for the options of | 
| median deviations plots for smooths. | |
| args4profile_plot | Creates a listof the values for the options of | 
| profile plots for comparing smooths. | |
| args4smoothing | Creates a listof 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 images are taken | |
| against the days after planting (or some other | |
| number of days after an event). | |
| 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.framein 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.framein | |
| 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.framein | |
| long format by differencing the values for | |
| a response within the interval. | |
| byIndv4Intvl_ValueCalc | Calculates a single value that is a functionof | 
| the values of an individual for a response in a | |
| data.framein 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.framein long format. | |
| byIndv4Times_GRsDiff | Adds to a 'data.frame', the growth rates | 
| calculated for consecutive times for individuals in | |
| the data.framein long format by differencing | |
| response values. | |
| byIndv4Times_WaterUse | Adds, to a data.frame, water use traits calculated | 
| for consecutive times for individuals in a data.frame | |
| in long format by differencing response values. | |
| byIndv4Times_periodicRates  | Adds the necessary times and rates values to a | 
| data.frame to make a set of periodic, or equally spaced, | |
| rates. | |
| byIndv4Times_SplinesGRs | For a response in a data.framein 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 functionto calculate a single value from | 
| an individual's values for a response in a data.framein | |
| long format. | |
| smoothSpline | Fit a spline to smooth the relationship between a | 
| responseand anxin adata.frame, | |
| optionally computing growth rates using derivatives. | |
| probeSmooths | For a response in a data.framein 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.framefrom adata.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. | |
Overview
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 \times Positions. That is, the minimum set of columns is an individuals, a times and one or more primary trait columns. 
Author(s)
Chris Brien [aut, cre] (<https://orcid.org/0000-0003-0581-1817>)
Maintainer: Chris Brien <chris.brien@adelaide.edu.au>
References
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.
See Also
Calculates growth rates (AGR, PGR, RGRdiff) between pairs of values in a vector
Description
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.
Usage
AGRdiff(x, time.diffs, lag=1)
PGR(x, time.diffs, lag=1)
RGRdiff(x, time.diffs, lag=1)Arguments
| x | A  | 
| time.diffs | a  | 
| lag | A  | 
Details
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.
Value
A numeric containing the growth rates which is the same length as x 
and in which the first lag values NA.
Author(s)
Chris Brien
See Also
byIndv4Intvl_GRsAvg, byIndv4Intvl_GRsDiff, byIndv4Times_GRsDiff, byIndv4Times_SplinesGRs, 
calcLagged
Examples
data(exampleData)
longi.dat$PSA.AGR <- with(longi.dat, AGRdiff(PSA, time.diffs = DAP.diffs))
Selects a subset of variables using Principal Variable Analysis (PVA)
Description
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.
Usage
PVA(obj, ...)Arguments
| obj | A  | 
| ... | allows passing of arguments to other functions | 
Details
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.
Value
A data.frame giving the results of the variable selection. 
It will contain the columns Variable, Selected, 
h.partial, Added.Propn and Cumulative.Propn.
Author(s)
Chris Brien
References
Cumming, J. A. and D. A. Wooff (2007) Dimension reduction via principal variables. Computational Statistics and Data Analysis, 52, 550–565.
See Also
PVA.data.frame, PVA.matrix, intervalPVA, rcontrib
Selects a subset of variables stored in a data.frame using Principal Variable Analysis (PVA)
Description
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.
Usage
## S3 method for class 'data.frame'
PVA(obj, responses, nvarselect = NULL, p.variance = 1, include = NULL, 
    plot = TRUE, ...)Arguments
| obj | A  | 
| responses | A  | 
| nvarselect | A  | 
| p.variance | A  | 
| include | A  | 
| plot | A  | 
| ... | allows passing of arguments to other functions | 
Details
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 = NULLand- p.variance = 1), which selects all variables in increasing order of amount of information they provide;
- to select exactly - nvarselectvariables;
- to select just enough variables, up to a maximum of - nvarselectvariables, to explain at least- p.variance*100 per cent of the total variance.
Value
A data.frame giving the results of the variable selection. 
It will contain the columns Variable, Selected, 
h.partial, Added.Propn and Cumulative.Propn.
Author(s)
Chris Brien
References
Cumming, J. A. and D. A. Wooff (2007) Dimension reduction via principal variables. Computational Statistics and Data Analysis, 52, 550–565.
See Also
PVA, PVA.matrix, intervalPVA.data.frame, rcontrib
Examples
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)
Selects a subset of variables using Principal Variable Analysis (PVA) based on a correlation matrix
Description
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.
Usage
## S3 method for class 'matrix'
PVA(obj, responses, nvarselect = NULL, p.variance = 1, include = NULL, 
    plot = TRUE, ...)Arguments
| obj | A  | 
| responses | A  | 
| nvarselect | A  | 
| p.variance | A  | 
| include | A  | 
| plot | A  | 
| ... | allows passing of arguments to other functions | 
Details
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 = NULLand- p.variance = 1), which selects all variables in increasing order of amount of information they provide;
- to select exactly - nvarselectvariables;
- to select just enough variables, up to a maximum of - nvarselectvariables, to explain at least- p.variance*100 per cent of the total variance.
Value
A data.frame giving the results of the variable selection. 
It will contain the columns Variable, Selected, 
h.partial, Added.Propn and Cumulative.Propn.
Author(s)
Chris Brien
References
Cumming, J. A. and D. A. Wooff (2007) Dimension reduction via principal variables. Computational Statistics and Data Analysis, 52, 550–565.
See Also
PVA, PVA.data.frame, intervalPVA.data.frame, rcontrib
Examples
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)
Prepped data from an experiment to investigate a rice germplasm panel.
Description
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. 
Usage
data(RicePrepped.dat)Format
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 individual occurs. | 
| 2 | Snapshot.ID.Tag | character | a unique identifier for each individual 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 individual 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 an Individual 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 Individual. | 
| 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. | |||
Source
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.
References
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.
Data for an experiment to investigate a rice germplasm panel
Description
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). 
Usage
data(RiceRaw.dat)Format
A data.frame containing 7392 observations on 34 variables.
Source
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.
References
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.
Calculates the Water Use Index (WUI)
Description
Calculates the Water Use Index, returning NA if the water use is zero.
Usage
WUI(response, water)Arguments
| response | A  | 
| water | A  | 
Value
A numeric containing the response divided by the water, unless water is 
zero in which case NA is returned.
Author(s)
Chris Brien
Examples
data(exampleData)
PSA.WUE <- with(longi.dat, WUI(PSA.AGR, WU))
Tests if any values in a vector are anomalous in being outside specified limits
Description
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.
Usage
anom(x, lower=NULL, upper=NULL, na.rm = TRUE)Arguments
| x | A  | 
| lower | A  | 
| upper | A  | 
| na.rm | A  | 
Value
A logical indicating whether any values have been found to 
be outside the limits specified by lower or upper or both.
Author(s)
Chris Brien
Examples
data(exampleData)
anom.val <- anom(longi.dat$sPSA.AGR, lower=2.5)
Creates a list of the values for the options of profile plots for the chosen smooth
Description
Creates 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.
Usage
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, 
                 ...)Arguments
| 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. | 
Value
A named list.
Author(s)
Chris Brien
See Also
traitSmooth, probeSmooths, plotSmoothsComparison and args4profile_plot.
Examples
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"))
Creates a list of the values for the smoothing parameters for 
which a smooth is to be extracted
Description
Creates a list of the values for the smoothing parameters for 
which a single smooth is to be extracted. 
The default settings for these are optimized for traitSmooth.
Usage
args4chosen_smooth(smoothing.methods = "logarithmic", 
                   spline.types = "PS", 
                   df = NULL, 
                   lambdas = NULL,
                   combinations = "single", 
                   ...)Arguments
| smoothing.methods | A  | 
| spline.types | A  | 
| df | A  | 
| lambdas | A named  | 
| combinations | Generally, this argument should be set to  | 
| ... | allows arguments to be passed to other functions; not used at present. | 
Value
A named list.
Author(s)
Chris Brien
See Also
traitSmooth and probeSmooths.
Examples
args4chosen_smooth(smoothing.methods = "direct", 
                   spline.types = "NCSS", df = 4)
args4chosen_smooth(smoothing.methods = "log", 
                   spline.types = "PS", lambdas = 0.36)
Creates a list of the values for the options of profile plots for comparing smooths
Description
Creates 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.
Usage
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, 
                    ...)Arguments
| 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. | 
Value
A named list.
Author(s)
Chris Brien
See Also
traitSmooth, probeSmooths, plotSmoothsComparison and args4chosen_plot.
Examples
args4devnboxes_plot(plots.by = "Type", 
                    facet.x = "Tuning", 
                    facet.y = c("Smarthouse", "Treatment.1"), 
                    which.plots = "absolute")
Creates a list of the values for the options of median deviations plots for smooths
Description
Creates 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.
Usage
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, 
                  ...)Arguments
| 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. | 
Value
A named list.
Author(s)
Chris Brien
See Also
traitSmooth, probeSmooths and plotSmoothsMedianDevns.
Examples
args4meddevn_plot(plots.by = "Type", plots.group = "Tuning",  
                  facet.x = "Method", facet.y = ".",
                  propn.types = c(0.02,0.1, 0.2))
Creates a list of the values for the options of profile plots for comparing smooths
Description
Creates 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.
Usage
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, 
                  ...)Arguments
| 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. | 
Value
A named list.
Author(s)
Chris Brien
See Also
traitSmooth, probeSmooths, plotSmoothsComparison and args4chosen_plot.
Examples
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"))
Creates a list of the values for the smoothing parameters to be passed to a smoothing function
Description
Creates 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.
Usage
 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", 
                ...)Arguments
| 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. | 
Value
A named list.
Author(s)
Chris Brien
See Also
traitSmooth and probeSmooths.
Examples
args4smoothing(smoothing.methods = "direct", 
               spline.types = "NCSS", df = NULL, lambdas = NULL, 
               smoothing.segments = NULL, npspline.segments = NULL, 
               combinations = "allvalid")
args4smoothing(smoothing.methods = "direct", 
               spline.types = "NCSS", df = NULL, lambdas = NULL, 
               smoothing.segments = list(c(11,20), c(21, 42)), 
               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")
Forms a smooths.frame from a data.frame, ensuring that the correct 
columns are present.
Description
Creates a smooths.frame from a data.frame by adding the 
class smooths.frame and a set of attributes to it.
Usage
as.smooths.frame(data, individuals = NULL, times = NULL)Arguments
| data | A  | 
| individuals | A  | 
| times | A  | 
Value
Author(s)
Chris Brien
See Also
validSmoothsFrame, as.smooths.frame
Examples
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 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.
Description
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).
Usage
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)Arguments
| 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  | 
Details
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.
Value
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.
Author(s)
Chris Brien
See Also
byIndv4Intvl_GRsDiff, byIndv4Intvl_WaterUse, getTimesSubset, 
 
GrowthRates, byIndv4Times_SplinesGRs
Examples
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")
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.
Description
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.
Usage
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 = ".")Arguments
| 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  | 
Details
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.
Value
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.
Author(s)
Chris Brien
See Also
byIndv4Intvl_GRsAvg, byIndv4Intvl_WaterUse,  getTimesSubset, GrowthRates, 
byIndv4Times_SplinesGRs
Examples
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")
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.
Description
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.
Usage
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, ...)
Arguments
| 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  | 
Value
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.
Author(s)
Chris Brien
See Also
byIndv4Intvl_GRsAvg, byIndv4Intvl_GRsDiff, 
byIndv4Intvl_WaterUse, 
 
getTimesSubset
Examples
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)
Calculates water use traits (WU, WUR, WUI) over a specified time interval 
for each individual in a data.frame in long format.
Description
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.
Usage
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)Arguments
| 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  | 
Details
- WU
- is the water use and is the sum of the water use after - start.timeuntil- end.time. Thus, the water use up to- start.timeis not included. Further, if any water use value in the interval is- NA, the interval value will be set to- NA.
- WUR
- is the Water Use Rate and is - WUdivided by the difference between- end.timeand- start.time.
- WUI
- is the Water Use Index and is calculated as a - responsedifference between the start.time and the end.time, which is then divided by the- WU.
Value
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 (‘.’).
Author(s)
Chris Brien
See Also
byIndv4Intvl_GRsAvg, byIndv4Intvl_GRsDiff, 
getTimesSubset, GrowthRates
Examples
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")
Adds to a data.frame, the growth rates calculated for consecutive times 
for individuals in the data.frame in long format by differencing 
response values.
Description
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 factors 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.
Usage
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)Arguments
| data | A  | 
| responses | A  | 
| individuals | A  | 
| times | A  | 
| which.rates | A  | 
| suffices.rates | A  | 
| sep.rates | A  | 
| avail.times.diffs | A  | 
| ntimes2span | A  | 
Value
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.
Author(s)
Chris Brien
See Also
smoothSpline, byIndv4Times_SplinesGRs
Examples
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)
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.
Description
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 probeSmooths can be used to investgate the effect 
the smoothing parameters 
 (smoothing.method, df or  
lambda) on the smooth that results.
Usage
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", ...)Arguments
| 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  | 
Value
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.
Author(s)
Chris Brien
References
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.
See Also
smoothSpline, probeSmooths, byIndv4Times_GRsDiff, 
smooth.spline, predict.smooth.spline, 
split
Examples
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")
Adds to a data.frame, water use traits calculated for consecutive times 
for individuals in the data.frame in long format.
Description
Calculates, for subsets of the data, those water traits out of 
Water Use (WU), Water Use Rate (WUR) and Water Use Index (WUI) that are 
specified in which.water.traits. The traits are calculated 
continuously over time for the water traits using the values of 
the variables for consecutive times stored in data. 
The weight.after column and whichever of  weight.before 
and water.added is not NULL are used  in the calculations. 
The subsets are those values with the same levels combinations of the 
factors listed in individuals. 
If avail.time.diffs is FALSE, the differences between 
consecutive time values are  calculated for each value of 
individuals.
Usage
byIndv4Times_WaterUse(data, weight.after = "Weight.After",
                    weight.before = NULL, water.added = NULL, 
                    responseAGR = NULL, 
                    individuals = "Snapshot.ID.Tag", times = "DAP", 
                    which.trait.types = c("WU","WUR","WUI"), 
                    water.trait.names = c("WU", "WUR", "WUI"),  
                    avail.times.diffs = FALSE, ntimes2span = 2)Arguments
| data | A  | 
| weight.after | A  | 
| weight.before | A  | 
| water.added | A  | 
| responseAGR | A  | 
| individuals | A  | 
| times | A  | 
| which.trait.types | A  | 
| water.trait.names | A  | 
| avail.times.diffs | A  | 
| ntimes2span | A  | 
Details
If weight.before is not NULL, then the water use (WU)  
between consecutive times is calulated as value of 
weight.after for first time minus the weight.after for 
the second time. If water.added is not NULL, then the 
water use (WU)  between consecutive times is calulated as value 
of the water.added minus the the difference between the 
weight.after values for the two  consecutive times. 
The WUR is calculated as the WU divided by the 
times.diffs and the WUI is calculated as the ratio of
the values on the column nomiated by responseAGR to the 
WUR values. 
Value
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 the water 
traits nominated in which.trait.types using the names specified in
water.trait.names.  The name of the column for times 
differences will be the value of times with ".diffs" 
appended. Each water trait will be positioned at observation 
ceiling(ntimes2span + 1) / 2 relative to the two times from 
which the growth rate is calculated.
Author(s)
Chris Brien
See Also
smoothSpline, byIndv4Times_GRsDiff
Examples
data(exampleData)
longi.dat <- byIndv4Times_WaterUse(data = longi.dat, 
                                   weight.before = "Weight.Before", 
                                   individuals = "Snapshot.ID.Tag", 
                                   times = "DAP", 
                                   which.trait.types = c("WU","WUR","WUI"), 
                                   water.trait.names = c("WU", "WUR","WUI"),
                                   responseAGR = "PSA.AGR")
Adds the necessary times and rates values to  a 
data.frame to make a set of periodic, or equally spaced, rates.
Description
Adds the times and rates values to a data.frame to produce 
a set of periodic rates i.e. rates for equally spaced times, the 
difference between  consecutive times being equal to 
reqd.times.diff. This assumes that the values for the consecutive 
differences between the values in the times column in data 
are an integer multiple of the value of reqd.times.diff and 
involves inserting times when the integer multiple of a times value is 
greater than one. It is also assumed that it is appropriate to use the 
rate value for the time immediately following inserted time(s) for the 
rate value(s) for the inserted times. Additional columns can be 
specified to have values duplicated for the inserted times. 
If avail.time.diffs is FALSE, the differences between 
consecutive time values in data are calculated.
Usage
byIndv4Times_periodicRates(data, responses, 
                           individuals = "Snapshot.ID.Tag", 
                           times = "DAP", 
                           columns2duplicate = NULL, 
                           reqd.times.diff = 1, 
                           avail.times.diffs = FALSE)Arguments
| data | A  | 
| responses | A  | 
| individuals | A  | 
| times | A  | 
| columns2duplicate | A  | 
| reqd.times.diff | A single-valued  | 
| avail.times.diffs | A  | 
Value
A data.frame obtained by expanding data to include all 
combinations of the values of individuals and the set of equally 
spaced times between the minimum and maximun values of times,
the spacing being the value of reqd.times.diff. 
For the rate(s) specified in the argument responses, values of the 
rate for the times immediately above an inserted times value 
are assigned to the values of the responses for the inserted 
times.
Author(s)
Chris Brien
See Also
Examples
data(exampleData)
longi.dat <- within(longi.dat, WUR <- WU/DAP.diffs)
longi.dat <- byIndv4Times_periodicRates(data = longi.dat, 
                                        responses = "WUR", 
                                        individuals = "Snapshot.ID.Tag", 
                                        times = "DAP", 
                                        avail.times.diffs = TRUE)
Calculates a single value that is a function of an individual's values for a response.
Description
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.
Usage
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 = ".", ...)Arguments
| 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  | 
Value
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.
Author(s)
Chris Brien
See Also
byIndv4Intvl_ValueCalc, byIndv4Times_GRsDiff,
byIndv4Times_SplinesGRs
Examples
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)
Replaces the values in a vector with the result of applying an operation to it and a lagged value
Description
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.
Usage
calcLagged(x, operation = NULL, lag = 1, ...)
Arguments
| x | A  | 
| operation | A  | 
| lag | A  | 
| ... | allows arguments to be passed to other functions; not used at present. | 
Value
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.
Author(s)
Chris Brien
See Also
Examples
data(exampleData)
longi.dat$DAP.diffs <- calcLagged(longi.dat$xDAP, operation ="-")
Calculates for a set of times, the time intervals after an origin time and the position of each within a time interval
Description
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.
Usage
calcTimes(data, imageTimes = NULL, timeFormat = "%Y-%m-%d %H:%M",
          intervals = "Time.after.Planting..d.", startTime = NULL, 
          intervalUnit = "days", timePositions = NULL)
Arguments
| data | A  | 
| imageTimes | A  | 
| timeFormat | A  | 
| intervals | A  | 
| startTime | A  | 
| intervalUnit | A  | 
| timePositions | A  | 
Value
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.
Author(s)
Chris Brien
See Also
Examples
  data(exampleData)
  raw.dat <- calcTimes(data = raw.dat, 
                       imageTimes = "Snapshot.Time.Stamp", timePositions = "Hour")
Calculates the cumulative sum, ignoring the first element if exclude.1st is TRUE
Description
Uses cumsum to calculate the cumulative sum, ignoring the first element 
if exclude.1st is TRUE.
Usage
cumulate(x, exclude.1st = FALSE, na.rm = FALSE, ...)Arguments
| x | A  | 
| exclude.1st | A  | 
| na.rm | A  | 
| ... | allows passing of arguments to other functions; not used at present. | 
Value
A vector containing  the cumulative sum.
Author(s)
Chris Brien
See Also
Examples
data(exampleData)
PSA.cum <- cumulate(longi.dat$PSA)
Adds the factors and covariates for a blocked, split-unit design
Description
Add the following  factors 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 factors are consistent with the observed numbers of individuals and measurements taken of them.
Usage
designFactors(data, insertName = NULL, designfactorMethod = "LanePosition", 
              nzones = 6, nlanesperzone = 4, 
              nmainunitsperlane = 11, nsubunitspermain = 2)Arguments
| data | A  Smarthouse, Snapshot.ID.Tag, xDAP, and, if  | 
| insertName | A  | 
| designfactorMethod | A  | 
| nzones | A  | 
| nlanesperzone | A  | 
| nmainunitsperlane | A  | 
| nsubunitspermain | A  | 
Details
The factors 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 individuals in each Smarthouse must be the product of these values and the number of observations must be the product of the numbers of smarthouse, indviduals and imagings for each individual. 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.
Value
A data.frame including the columns:
- Smarthouse: - factorwith levels for the Smarthouse
- Zone: - factordividing the Lanes into groups, usually of 4 lanes
- cZone: numeric corresponding to Zone, centred by subtracting the mean of the unique positions 
- SHZone: - factorfor the combinations of Smarthouse and Zone
- ZLane: - factorfor the lanes within a Zone
- ZMainunit: - factorfor the main units within a Zone
- Subunit: - factorfor 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 
Author(s)
Chris Brien
Examples
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")
A small data set to use in function examples
Description
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.
Usage
data(exampleData)Format
Three data.frames: 
-  raw.dat(280 rows by 34 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 inraw.dat;
-  indv.dat(20 rows by 45 columns) that contains data summarizing the growth features of the 20 plants, based on the data inlongi.dat.
Forms a subset of responses in data that contains their values for the nominated times
Description
Forms a subset of each of the responses in data that contains their values for the 
nominated times in a single column.
Usage
getTimesSubset(data, responses, 
               individuals = "Snapshot.ID.Tag", times = "DAP", 
               which.times, suffix = NULL, sep.suffix.times = ".", 
               include.times = FALSE, include.individuals = FALSE)Arguments
| data | A  | 
| responses | A  | 
| individuals | A  | 
| times | A  | 
| which.times | A  | 
| suffix | A  | 
| sep.suffix.times | A  | 
| include.times | A  | 
| include.individuals | A  | 
Value
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.
Author(s)
Chris Brien
Examples
data(exampleData)
sPSALast <- getTimesSubset("sPSA", data = longi.dat, times = "DAP", 
                           which.times = c(42), suffix = "last")
Deprecated Functions in the Package growthPheno
Description
These functions have been renamed and deprecated in growthPheno: 
- getDates -> - getTimesSubset
- anomPlot -> - plotAnom
- corrPlot -> - plotCorrmatrix
- fitspline -> - smoothSpline
- imagetimesPlot -> - plotImagetimes
- intervalGRaverage -> - byIndv4Intvl_GRsAvg
- intervalGRdiff -> - byIndv4Intvl_GRsDiff
- intervalValueCalculate -> - byIndv4Intvl_ValueCalc
- intervalWUI -> - byIndv4Intvl_WaterUse
- longiPlot -> - plotProfiles
- longitudinalPrime -> - prepImageData
- plotLongitudinal -> - plotProfiles
- plotMedianDeviations -> - plotSmoothsMedianDevns
- probeDF -> - probeSmooths
- probeSmoothing -> - probeSmooths
- splitContGRdiff -> - byIndv4Times_GRsDiff
- splitSplines -> - byIndv4Times_SplinesGRs
- splitValueCalculate -> - byIndv4Intvl_ValueCalc
Usage
getDates(...)
anomPlot(...)
corrPlot(...)
fitSpline(...)
imagetimesPlot(...)
intervalGRdiff(...)
intervalGRaverage(...)
intervalValueCalculate(...)
intervalWUI(...)
longiPlot(...)
longitudinalPrime(...)
plotLongitudinal(...)
plotMedianDeviations(...)
probeDF(...)
probeSmoothing(...)
splitContGRdiff(...)
splitSplines(...)
splitValueCalculate(...)
Arguments
| ... | absorbs arguments passed from the old functions of the style foo.bar(). | 
Author(s)
Chris Brien
Imports an Excel imaging file and allows some renaming of variables
Description
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 individuals (e.g. plant, pot, cart, plot or unit) over time. There should 
be a column, which by default is called 
Snapshot.ID.Tag, containing a unique identifier for each individual 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. 
Usage
importExcel(file, sheet="raw data", sep = ",", 
            individualId = "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, ...)Arguments
| file | A  | 
| sheet | A  | 
| sep | A  | 
| individualId | 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  | 
Value
A data.frame containing the data.
Author(s)
Chris Brien
See Also
as.POSIXct, calcTimes, plotImagetimes
Examples
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,
                                           individualId = "Snapshot.ID.Tags",
                                           startTime = "06/10/2017 0:00 AM",
                                           timeFormat = "%d/%m/%Y %H:M", 
                                           labsCamerasViews = camview.labels, 
                                           plotImagetimes = FALSE))
Selects a subset of variables using Principal Variable Analysis (PVA), based on the observed values within a specified time interval
Description
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.
Usage
## S3 method for class 'data.frame'
intervalPVA(obj, responses, times = "Days", start.time, end.time, 
            nvarselect = NULL, p.variance = 1, include = NULL, 
            plot = TRUE, ...)Arguments
| 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. | 
Details
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 = NULLand- p.variance = 1) select all variables in increasing order of amount of information they provide;
- select exactly - nvarselectvariables;
- select just enough variables, up to a maximum of - nvarselectvariables, to explain at least- p.variance*100 per cent of the total variance.
Value
A data.frame giving the results of the variable selection. 
It will contain the columns Variable, Selected, 
h.partial, Added.Propn and Cumulative.Propn.
Author(s)
Chris Brien
References
Cumming, J. A. and D. A. Wooff (2007) Dimension reduction via principal variables. Computational Statistics and Data Analysis, 52, 550–565.
See Also
Examples
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)
Tests whether an object is of class smooths.frame
Description
A single-line function that tests whether an object is of class smooths.frame.
Usage
is.smooths.frame(object)Arguments
| object | An  | 
Value
A logical.
Author(s)
Chris Brien
See Also
validSmoothsFrame, as.smooths.frame
Examples
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)
Identifies anomalous individuals and produces profile plots without them and with just them
Description
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. 
Usage
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, ...)Arguments
| 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  | 
Value
A list with three components: 
-  data, a data frame resulting from themergeofdataand thelogicalidentifying whether or not an individual is anomalous;
-  innerPlot, an object of classggplotstoring the profile plot of the individuals that are not anomalous;
-  outerPlot, an object of classggplotstoring 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.
Author(s)
Chris Brien
See Also
anom, byIndv4Intvl_ValueCalc, ggplot2.
Examples
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")
Calculates and plots correlation matrices for a set of responses
Description
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. Matrix plots of all pairwise 
combinations of the variables can be produced that includes the values of the 
the correlation coefficients. If pairs.sets is set, a matrix 
plot, along with the values of the correlation coefficients, is produced  for 
each of the pair.sets. That is, the argument pairs.sets can be used to 
restrict the pairs in a matrix plot to those combinations within each set. 
Usage
plotCorrmatrix(data, responses, which.plots = c("heatmap","matrixplots"), 
               title = NULL, labels = NULL, labelSize = 4, pairs.sets = NULL, 
               show.sig = TRUE, cell.text.size = 12, axis.text.size = 20, 
               ggplotFuncs = NULL, printPlot = TRUE, ...)
Arguments
| data | A  | 
| responses | A  | 
| which.plots | A  | 
| title | Title for the plots. | 
| labels | A  | 
| labelSize | A  | 
| pairs.sets | A  | 
| show.sig | A  | 
| cell.text.size | A  | 
| axis.text.size | A  | 
| ggplotFuncs | A  | 
| printPlot | A  | 
| ... | allows passing of arguments to other functions; not used at present. | 
Details
The correlations and their p-values are producced using rcorr 
from the Hmisc package. The heatmap is produced using 
ggplot and the matrixplots are produced using GGally.
Value
A list object that has components heatmap and matrixplots.  The component heatmap will contain the heatmap plot, if produced, as an object of class "ggplot", which can be plotted using print; otherwise NULL is returned. 
Similarly, if not NULL, the component matrixplots will contain a list with one or more components, depending on the setting of pair.sets, each of which is a scatterplot matrix stored as an object of class "ggmatrix".
Author(s)
Chris Brien
See Also
rcorr, GGally, ggplot.
Examples
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.
Description
Produces boxplots of the deviations of the observed values from the smoothed values over values of x.
Usage
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, ...)
 Arguments
| 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  | 
Value
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.
Author(s)
Chris Brien
See Also
plotSmoothsMedianDevns, probeSmooths, ggplot.
Examples
data(exampleData)
plotDeviationsBoxes(longi.dat, observed = "PSA", smoothed = "sPSA",
                    x.factor="DAP", facet.x.pf = ".", facet.y= ".", df =5)
Plots the position of a time within an interval against the interval for image
Description
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 images 
are taken 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.
Usage
plotImagetimes(data, intervals = "Time.after.Planting..d.", timePositions = "Hour", 
               groupVariable = "Snapshot.ID.Tag", colourVariable = "Lane", 
               ggplotFuncs = NULL, printPlot = TRUE)
Arguments
| data | A  | 
| intervals | A  | 
| timePositions | A  | 
| groupVariable | A  | 
| colourVariable | A  | 
| ggplotFuncs | A  | 
| printPlot | A  | 
Value
An object of class "ggplot", which can be plotted using print.
Author(s)
Chris Brien
See Also
ggplot, calcTimes.
Examples
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))))
Produces profile plots of longitudinal data for a set of individuals
Description
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).
Usage
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)
Arguments
| 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  | 
Value
An object of class "ggplot", which can be plotted using 
print.
Author(s)
Chris Brien
See Also
ggplot, labeller.
Examples
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 several sets of smoothed values for a response, possibly along with growth rates and optionally including the unsmoothed values, as well as deviations boxplots.
Description
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 factors 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 factors other than the smoothing-parameter 
factors 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 factors 
in plot.by and each plot compares the smoothed traits for the 
smoothing-parameter factors included in facet.x 
and/or facet.y (set both plots.by and one or more of 
facet.x and facet.y). 
Usage
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, ...)
Arguments
| 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  | 
Value
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 
factors in plots.by; each of these third-level 
ists contains a ggplot object that can 
be plotted using print. 
Author(s)
Chris Brien
See Also
traitSmooth, probeSmooths, args4profile_plot, plotDeviationsBoxes, plotSmoothsMedianDevns, ggplot2.
Examples
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))
Produces boxplots for several sets of deviations of the smoothed values from a response, possibly along with growth rates.
Description
 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 (responseand 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 factors 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 factors other than the smoothing-parameter 
factors can be supplied to the plots.by and facet arguments.
Usage
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, ...)
Arguments
| 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  | 
Value
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. 
Author(s)
Chris Brien
See Also
traitSmooth, probeSmooths, args4profile_plot, plotDeviationsBoxes, plotSmoothsMedianDevns, ggplot.
Examples
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 = "."))
Calculates and plots the medians of the deviations from the observed values for 
several sets of smoothed values  stored in a data.frame in long format.
Description
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 factors 
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 factors other than the 
smoothing-parameter factors, that are also associated with the data. 
The basic principle is that the number of levels combinations of the smoothing-parameter 
factors 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.
Usage
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, ...)
Arguments
| 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. | 
Value
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.
Author(s)
Chris Brien
See Also
traitSmooth, probeSmooths, args4meddevn_plot, plotSmoothsComparison, plotDeviationsBoxes, ggplot.
Examples
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))
Prepares raw imaging data for further processing
Description
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 factors and explanatory variates that might be of use in an 
analysis of the data.
Usage
prepImageData(data, individualId = "Snapshot.ID.Tag", 
              imageTimes = "Snapshot.Time.Stamp", 
              timeAfterStart = "Time.after.Planting..d.",
              PSAcolumn = "Projected.Shoot.Area..pixels.", 
              potIDcolumns = NULL, 
              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, ...)Arguments
| 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. | 
| individualId | A  | 
| imageTimes | A  | 
| timeAfterStart | A  | 
| PSAcolumn | A  | 
| potIDcolumns | A  | 
| idcolumns | A  | 
| traits | A  | 
| labsCamerasViews | A  | 
| smarthouse.lev | A  | 
| calcWaterUse | A  | 
| ... | allows passing of arguments to other functions; not used at present. | 
Details
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.
Value
A data.frame containing the columns specified by individualId, 
imageTimes, timeAfterStart, potIDcolumns or, 
if potIDcolumns is NULL, idcolumns, traits and 
cameras. The defaults will result in the following columns:
- Smarthouse: - factorwith levels for the Smarthouse
- Lane: - factorfor lane number in a smarthouse
- Position: - factorfor east/west position in a lane
- DAP: - factorfor the number of Days After Planting
- xDAP: numeric for the DAP (calculated) 
-  individualId: unique code for each individual
-  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) 
-  potIDcolumns: the columns listed inpotIDcolumns, after being converted tofactors
- Reps: - factorindexing the replicates for each combination of the- factors in- idcolumns(calculated only if- potIDcolumnsis- NULL)
-  idcolumns: only ifpotIDcolumnsisNULL, the columns listed inidcolumns, after being converted tofactors
- Weight.Before: weight of the pot before watering (only if - calcWaterUseis- TRUE)
- Weight.After: weight of the pot after watering (only if - calcWaterUseis- 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 - calcWaterUseis- 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) 
Author(s)
Chris Brien
Examples
data(exampleData)
longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1)
longi.dat <- prepImageData(data=raw.dat, 
                          traits= list(all = "Area"), 
                          labsCamerasViews = list(all = NULL), 
                          potIDcolumns = c("Genotype.ID", "Treatment.1", "Replicate" ), 
                          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))
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.
Description
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 factors Type, 
TunePar, TuneVal, Tuning (the combination 
of TunePar and TuneVal) and Method, as well as 
other factors associated with the data. 
The factors 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 factors 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 
factors 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 factors that are not 
smoothing-parameter factors 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 factors 
in plot.by and each plot compares the smoothed traits for the 
smoothing-parameter factors 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)
Usage
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"), 
             ...)Arguments
| 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  | 
Value
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.
Author(s)
Chris Brien
See Also
args4smoothing, , args4meddevn_plot, args4profile_plot, 
traitSmooth, 
 
smoothSpline, byIndv4Times_SplinesGRs, byIndv4Times_GRsDiff,  
smooth.spline, psNormal, plotSmoothsComparison, 
plotSmoothsMedianDevns, ggplot.
Examples
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))
Computes a measure of how correlated each variable in a set is with the other variable, conditional on a nominated subset of them
Description
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.
Usage
rcontrib(obj, ...)Arguments
| obj | A  | 
| ... | allows passing of arguments to other functions | 
Details
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.
Value
A numeric giving the correlation measures.
Author(s)
Chris Brien
References
Cumming, J. A. and D. A. Wooff (2007) Dimension reduction via principal variables. Computational Statistics and Data Analysis, 52, 550–565.
See Also
Computes a measure of how correlated each variable in a set is with the other variable, conditional on a nominated subset of them
Description
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.
Usage
## S3 method for class 'data.frame'
rcontrib(obj, responses, include = NULL, ...)Arguments
| obj | A  | 
| responses | A  | 
| include | A  | 
| ... | allows passing of arguments to other functions. | 
Value
A numeric giving the correlation measures.
Author(s)
Chris Brien
References
Cumming, J. A. and D. A. Wooff (2007) Dimension reduction via principal variables. Computational Statistics and Data Analysis, 52, 550–565.
See Also
rcontrib, rcontrib.matrix, PVA, intervalPVA.data.frame
Examples
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")
Computes a measure of how correlated each variable in a set is with the other variable, conditional on a nominated subset of them
Description
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.
Usage
## S3 method for class 'matrix'
rcontrib(obj, responses, include = NULL, ...)Arguments
| obj | A  | 
| responses | A  | 
| include | A  | 
| ... | allows passing of arguments to other functions. | 
Value
A numeric giving the correlation measures.
Author(s)
Chris Brien
References
Cumming, J. A. and D. A. Wooff (2007) Dimension reduction via principal variables. Computational Statistics and Data Analysis, 52, 550–565.
See Also
rcontrib, rcontrib.data.frame, PVA, intervalPVA.data.frame
Examples
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")
Fit a spline to smooth the relationship between a response and an x in a data.frame, 
optionally computing growth rates using derivatives.
Description
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.
Usage
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", ...)Arguments
| 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  | 
Value
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 - sparfor 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.splinefor- smoothing methodset to- NCSSor by- JOPS::psNormalfor- PS.
Author(s)
Chris Brien
References
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.
See Also
byIndv4Times_SplinesGRs, probeSmooths, 
byIndv4Times_GRsDiff, smooth.spline, 
predict.smooth.spline, JOPS.
Examples
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")
Description of a smooths.frame object
Description
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.
Value
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, thecharactergiving the name of thefactorthat define the subsets of thedatafor which each subset corresponds to theresponsevalues for an individual;
-  n, the number of uniqueindividuals;
-  times, thecharactergiving the name of thenumeric, orfactorwith numeric levels, that contains the values of the predictor variable plotted on the x-axis;
-  t, the number of unique values in thetimes;
-  nschemes, the number of unique combinations of the smoothing-parameter values in thesmoothsframe.
Author(s)
Chris Brien
See Also
probeSmooths, is.smooths.frame, 
as.smooths.frame, validSmoothsFrame, args4smoothing
Examples
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)
Longitudinal data for an experiment to investigate tomato response to mycorrhizal fungi and zinc
Description
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.
Usage
data(tomato.dat)Format
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. | 
References
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 features, that are single-valued for each individual, from traits observed over time.
Description
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_GRsDifforbyIndv4Intvl_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 so see its documentation for further details)
-  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_GRsDifforbyIndv4Intvl_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.
Usage
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, ...)
Arguments
| 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. | 
Value
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 oftimesat 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.ratesand a suffix for the time interval, each separated by a full stop. The interval suffix is formed by joining itsstarts.intvlandstops.intvlvalues, separating them by the value ofsep.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.ratesandsuffix.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 eitherRor the value ofsuffix.water.rateadded to the value ofwater.use4intvl.traits. Similarly the index (WUI) has eitherIor the value ofsuffix.water.indexadded to it. The WUI also has the element ofresponses4waterused 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 itsstarts.intvlandstops.intvl, separated by the value ofsep.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 eitherRor the value ofsuffix.water.rateadded to the value ofwater.use4intvl.traits. Similarly the index (WUI) has eitherIor the value ofsuffix.water.indexadded to it. The WUI also has the element ofresponses4waterused in calculating the WUI prefixed to its name. All three water use traits havesuffix.overallappended to their names.
-  the total for the whole of imaging period – The name for whole-of-imaging total is formed by combining an element of responses4overall.totalswithsuffix.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"andsuffix.overall, each separated by a full stop. The name of the column with the value oftimesat which the maximum occurred will be the result of concatenating theresponses4overall.max,"max"and the value oftimes, each separated by a full stop.
The data.frame is returned invisibly.
Author(s)
Chris Brien
References
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.
See Also
getTimesSubset, byIndv4Intvl_GRsAvg, 
byIndv4Intvl_GRsDiff, byIndv4Intvl_WaterUse, 
byIndv_ValueCalc.
Examples
 #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)
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.
Description
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:
- Smooth:
- Produces - response.smoothedusing splines for a set of smoothing parameter settings and, optionally, computes growth rates either as differences or derivatives. (see- smoothing.argsbelow and- args4smoothing) This step is bypassed if a- data.framethat is also of class- smooths.frameis supplied to- data.
- Profile plots:
- Produces profile plots of - response.smoothedand its growth rates that compare the smooths; also, boxplots of the deviations of the observed from smoothed data can be obtained. (see- profile.plot.argsbelow and- args4profile_plot) Whether these plots are produced is controlled via- which.plotsor whether- profile.plot.argsis set to- NULL.
- Median deviations plots:
- 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.argsbelow and- args4meddevn_plot) Whether these plots are produced is controlled via- which.plotsor whether- meddevn.plot.argsis set to- NULL.
- Deviations boxplots:
- 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.argsbelow and- args4devnboxes_plot) Whether these plots are produced is controlled via- which.plotsor whether- devnboxes.plot.argsis set to- NULL.
- Choose a smooth:
- Extract a single, favoured - response.smoothed, and its growth rates, for a chosen set of smoothing parameter settings. (see- chosen.smooth.argsbelow and- args4chosen_smooth) This step will be omitted if- chosen.smooth.argsis- NULL.
- Chosen smooth plot:
- Produces profile plots of the chosen smooth and its growth rates. (see - chosen.plot.argsbelow and- args4chosen_plot) Whether these plots are produced is controlled by whether- chosen.plot.argsis 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.
Usage
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, 
            ...)
Arguments
| 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  | 
Details
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 factors Type, 
TunePar, TuneVal, Tuning (the combination 
of TunePar and TuneVal) and Method, as well as 
other factors associated with the data. 
The factors 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 factors 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 
factors 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 factors that are not 
smoothing-parameter factors 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 factors 
in plot.by and each plot compares the smoothed traits for the 
smoothing-parameter factors 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 AGRs 
and RGRs 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. 
Value
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.
Author(s)
Chris Brien
References
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.
See Also
args4smoothing, args4meddevn_plot, args4profile_plot, 
args4chosen_smooth, 
 
args4chosen_plot, probeSmooths 
plotSmoothsComparison and 
 
plotSmoothsMedianDevns, ggplot.
Examples
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))
Creates a data.frame formed by applying, for each response, a binary operation to the paired values of two different treatments
Description
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.
Usage
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"))
Arguments
| 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  | 
Value
A data.frame containing the following columns and the values of the :
- those from - datanominated 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.factorto that specified by- control;
- those containing the - controlvalues of the columns whose names are specified in- responses; the control values are those having the level of- treatment.factorspecified by- control;
- those containing the values calculated using the binary - operations; the names of these columns will be constructed from- responsesby appending- suffices.resultsto them.
Author(s)
Chris Brien
Examples
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),])
Checks that an object is a valid smooths.frame.
Description
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.
Usage
validSmoothsFrame(object)Arguments
| object | 
Value
TRUE or a character describing why the object 
is not a valid smooths.frame.
Author(s)
Chris Brien
See Also
is.smooths.frame, as.smooths.frame
Examples
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)