calculate_dydx: Calculate dy/dx vector from vectors y and x

View source: R/amp_melt_curve_functions.R

calculate_dydxR Documentation

Calculate dy/dx vector from vectors y and x

Description

Used in tidyqpcr to calculate dR/dT for a melt curve of fluorescence signal R vs temperature T.

Usage

calculate_dydx(x, y, method = "spline", ...)

Arguments

x

input variable, numeric vector, assumed to be temperature

y

output variable, numeric vector of same length as x, assumed to be fluorescence signal.

method

to use for smoothing:

"spline" default, uses smoothing spline stats::smooth.spline.

"diff" base::diff for lagged difference

...

other arguments to pass to smoothing method.

Value

estimated first derivative of y with respect to x, numeric vector of same length as y.

See Also

Other melt_curve_functions: calculate_drdt_plate()

Examples

# create simple curve
x = 1:5
y = x^2

# calculate gradient of curve
#----- use case 1 : using splines
calculate_dydx(x, y)

# optional arguments are passed to smooth.splines function
calculate_dydx(x, y, spar = 0.5)

#----- use case 2 : using difference between adjacent points
calculate_dydx(x, y, method = "diff")


ewallace/tidyqpcr documentation built on June 5, 2024, 10:04 a.m.