This is a document provide examples related with categorize function. It will investigate 2 examples one is related with sigmoidal and other is related with double sigmoidal
To generate the figures, we will go backwards and firstly generate some data to analize. To add some randomness to the input data I will use some noise. The input of all package must be in the form of a data frame with at least 2 columns time and intensity.
We will generate data for both sigmoidal and double sigmoidal
time=seq(3,24,0.5)
#simulate intensity data and add noise
noise_parameter=0.1
intensity_noise=stats::runif(n = length(time),min = 0,max = 1)*noise_parameter
intensity=sigmoidalFitFormula(time, maximum=4, slope=1, midPoint=8)
intensity=intensity+intensity_noise
dataInputSigmoidal=data.frame(intensity=intensity,time=time)
noise_parameter=0.2
intensity_noise=runif(n = length(time),min = 0,max = 1)*noise_parameter
intensity=doublesigmoidalFitFormula(time,
finalAsymptoteIntensity=.3,
maximum=4,
slope1=1,
midPoint1=7,
slope2=1,
midPointDistance=8)
intensity=intensity+intensity_noise
dataInputDoubleSigmoidal=data.frame(intensity=intensity,time=time)
This is the first step. Data should be normalized before any fit. I.e time and intensity should be in between 0-1 interval.
The normalization code is
normalizedSigmoidalInput = sicegar::normalizeData(dataInput = dataInputSigmoidal,
dataInputName = "sigmoidalSample")
normalizedDoubleSigmoidalInput = sicegar::normalizeData(dataInput = dataInputDoubleSigmoidal,
dataInputName = "doubleSigmoidalSample")
Now we need to fit all three models to the data. Linear, sigmoidal and double sigmoidal on both sigmoidal and double-sigmoidal data.
# Do the sigmoidal fit
# Fit linear model
linearModel_sd=fitFunction(dataInput=normalizedSigmoidalInput,
model="linear",
n_runs_min=20,
n_runs_max=500,
showDetails=FALSE)
# Fit sigmoidal model
sigmoidalModel_sd=fitFunction(dataInput=normalizedSigmoidalInput,
model="sigmoidal",
n_runs_min=20,
n_runs_max=500,
showDetails=FALSE)
# Fit double sigmoidal model
doubleSigmoidalModel_sd=fitFunction(dataInput=normalizedSigmoidalInput,
model="doublesigmoidal",
n_runs_min=20,
n_runs_max=500,
showDetails=FALSE)
# Do the sigmoidal fit
# Fit linear model
linearModel_dsd=fitFunction(dataInput=normalizedDoubleSigmoidalInput,
model="linear",
n_runs_min=20,
n_runs_max=500,
showDetails=FALSE)
# Fit sigmoidal model
sigmoidalModel_dsd=fitFunction(dataInput=normalizedDoubleSigmoidalInput,
model="sigmoidal",
n_runs_min=20,
n_runs_max=500,
showDetails=FALSE)
# Fit double sigmoidal model
doubleSigmoidalModel_dsd=fitFunction(dataInput=normalizedDoubleSigmoidalInput,
model="doublesigmoidal",
n_runs_min=20,
n_runs_max=500,
showDetails=FALSE)
Now we have attempts of fits for linear, sigmoidal and double sigmoidal models on our datasets. By using the results of those atempts one can make decisions about the category of the input data; wheather it is sigmoidal or double sigmoidal.
outputCluster_sd=categorize(parameterVectorLinear=linearModel_sd,
parameterVectorSigmoidal=sigmoidalModel_sd,
parameterVectorDoubleSigmoidal=doubleSigmoidalModel_sd)
print(outputCluster_sd) # This should give sigmoidal
## classification dataInputName
## 1 sigmoidal sigmoidalSample
outputCluster_dsd=categorize(parameterVectorLinear=linearModel_dsd,
parameterVectorSigmoidal=sigmoidalModel_dsd,
parameterVectorDoubleSigmoidal=doubleSigmoidalModel_dsd)
print(outputCluster_dsd) # This should give double sigmoidal
## classification dataInputName
## 1 double_sigmoidal doubleSigmoidalSample