fitSpline: Fit Splines

View source: R/fitSpline.R

fitSplineR Documentation

Fit Splines

Description

Fit P-Splines on corrected or raw data. The number of knots is chosen by the user. The function outputs are predicted P-Spline values and their first and second derivatives on a dense grid. The outputs can then be used for outlier detection for time series (see detectSerieOut) and to estimate relevant parameters from the curve for further analysis (see estimateSplineParameters).

Usage

fitSpline(
  inDat,
  trait,
  genotypes = NULL,
  plotIds = NULL,
  knots = 50,
  useTimeNumber = FALSE,
  timeNumber = NULL,
  minNoTP = NULL
)

Arguments

inDat

A data.frame with corrected spatial data.

trait

A character string indicating the trait for which the spline should be fitted.

genotypes

A character vector indicating the genotypes for which splines should be fitted. If NULL, splines will be fitted for all genotypes.

plotIds

A character vector indicating the plotIds for which splines should be fitted. If NULL, splines will be fitted for all plotIds.

knots

The number of knots to use when fitting the spline.

useTimeNumber

Should the timeNumber be used instead of the timePoint?

timeNumber

If useTimeNumber = TRUE, a character vector indicating the column containing the numerical time to use.

minNoTP

The minimum number of time points for which data should be available for a plant. Defaults to 80% of all time points present in the TP object. No splines are fitted for plants with less than the minimum number of timepoints.

Value

An object of class HTPSpline, a list with two data.frames, predDat with predicted values and coefDat with P-Spline coefficients on a dense grid.

See Also

Other functions for fitting splines: plot.HTPSpline()

Examples

## The data from the Phenovator platform have been corrected for spatial
## trends and outliers for single observations have been removed.

## Fit P-Splines on a subset of genotypes
subGeno <- c("G070", "G160")
fit.spline <- fitSpline(inDat = spatCorrectedVator,
                        trait = "EffpsII_corr",
                        genotypes = subGeno,
                        knots = 50)

## Extract the data.frames with predicted values and P-Spline coefficients.
predDat <- fit.spline$predDat
head(predDat)

coefDat <- fit.spline$coefDat
head(coefDat)

## Visualize the P-Spline predictions for one genotype.
plot(fit.spline, genotypes = "G160")

## Visualize the P-Spline predictions and first derivatives for one plant.
plot(fit.spline, plotIds = "c10r29", plotType = "predictions")
plot(fit.spline, plotIds = "c10r29", plotType = "derivatives")


statgenHTP documentation built on April 14, 2023, 9:12 a.m.