Double Sigmoidal Formula with h0
Source:R/doublesigmoidalFitFunctions_h0.R
doublesigmoidalFitFormula_h0.Rd
Calculates intensities using the double-sigmoidal model fit and the parameters (maximum, final asymptote intensity, slope1Param, midpoint1Param, slope2Param, and mid point distance).
Usage
doublesigmoidalFitFormula_h0(
x,
finalAsymptoteIntensityRatio,
maximum,
slope1Param,
midPoint1Param,
slope2Param,
midPointDistanceParam,
h0
)
Arguments
- x
the "time" (time) column of the dataframe
- finalAsymptoteIntensityRatio
This is the ratio between asymptote intensity and maximum intensity of the fitted curve.
- maximum
the maximum intensity that the double sigmoidal function reach.
- slope1Param
the slope parameter of the sigmoidal function at the steepest point in the exponential phase of the viral production.
- midPoint1Param
the x axis value of the steepest point in the function.
- slope2Param
the slope parameter of the sigmoidal function at the steepest point in the lysis phase. i.e when the intensity is decreasing.
- midPointDistanceParam
the distance between the time of steepest increase and steepest decrease in the intensity data. In other words the distance between the x axis values of arguments of slope1Param and slope2Param.
- h0
the lower asymptote (baseline) intensity
Value
Returns the predicted intensities for the given time points with the double-sigmoidal fitted parameters for the double sigmoidal fit.
Examples
time <- seq(3, 24, 0.1)
#simulate intensity data and add noise
noise_parameter <- 0.2
intensity_noise <- stats::runif(n = length(time), min = 0, max = 1) * noise_parameter
intensity <- doublesigmoidalFitFormula_h0(time,
finalAsymptoteIntensityRatio = .3,
maximum = 4,
slope1Param = 1,
midPoint1Param = 7,
slope2Param = 1,
midPointDistanceParam = 8,
h0 = 1)
intensity <- intensity + intensity_noise
dataInput <- data.frame(intensity = intensity, time = time)
normalizedInput <- normalizeData(dataInput)
parameterVector <- doublesigmoidalFitFunction_h0(normalizedInput, tryCounter = 1)
#Check the results
# doublesigmoidalFitFunction_h0() is run on the startList param values (because 'tryCounter = 1')
# use multipleFitFunction() for multiple random starts in order to optimize
if(parameterVector$isThisaFit){
intensityTheoretical <-
doublesigmoidalFitFormula_h0(
time,
finalAsymptoteIntensityRatio = parameterVector$finalAsymptoteIntensityRatio_Estimate,
maximum = parameterVector$maximum_Estimate,
slope1Param = parameterVector$slope1Param_Estimate,
midPoint1Param = parameterVector$midPoint1Param_Estimate,
slope2Param = parameterVector$slope2Param_Estimate,
midPointDistanceParam = parameterVector$midPointDistanceParam_Estimate,
h0 = parameterVector$h0_Estimate)
comparisonData <- cbind(dataInput, intensityTheoretical)
require(ggplot2)
ggplot(comparisonData) +
geom_point(aes(x = time, y = intensity)) +
geom_line(aes(x = time, y = intensityTheoretical)) +
expand_limits(x = 0, y = 0)
}
if(!parameterVector$isThisaFit){
print(parameterVector)
}
#> finalAsymptoteIntensityRatio_N_Estimate
#> 1 NA
#> finalAsymptoteIntensityRatio_Std_Error finalAsymptoteIntensityRatio_t_value
#> 1 NA NA
#> finalAsymptoteIntensityRatio_Pr_t maximum_N_Estimate maximum_Std_Error
#> 1 NA NA NA
#> maximum_t_value maximum_Pr_t slope1Param_N_Estimate slope1Param_Std_Error
#> 1 NA NA NA NA
#> slope1Param_t_value slope1Param_Pr_t midPoint1Param_N_Estimate
#> 1 NA NA NA
#> midPoint1Param_Std_Error midPoint1Param_t_value midPoint1Param_Pr_t
#> 1 NA NA NA
#> slope2Param_N_Estimate slope2Param_Std_Error slope2Param_t_value
#> 1 NA NA NA
#> slope2Param_Pr_t midPointDistanceParam_N_Estimate
#> 1 NA NA
#> midPointDistanceParam_Std_Error midPointDistanceParam_t_value
#> 1 NA NA
#> midPointDistanceParam_Pr_t h0_N_Estimate h0_Std_Error h0_t_value h0_Pr_t
#> 1 NA NA NA NA NA
#> residual_Sum_of_Squares log_likelihood AIC_value BIC_value isThisaFit
#> 1 Inf NA NA NA FALSE
#> startVector.finalAsymptoteIntensityRatio startVector.maximum
#> 1 0 1
#> startVector.slope1Param startVector.midPoint1Param startVector.slope2Param
#> 1 1 0.33 1
#> startVector.midPointDistanceParam startVector.h0
#> 1 0.29 0.1
#> dataScalingParameters.timeRange dataScalingParameters.intensityMin
#> 1 24 1.142112
#> dataScalingParameters.intensityMax dataScalingParameters.intensityRange
#> 1 4.167546 3.025433
#> model finalAsymptoteIntensityRatio_Estimate maximum_Estimate
#> 1 doublesigmoidal NA NA
#> slope1Param_Estimate midPoint1Param_Estimate slope2Param_Estimate
#> 1 NA NA NA
#> midPointDistanceParam_Estimate h0_Estimate
#> 1 NA NA