16 lines
12 KiB
Plaintext
16 lines
12 KiB
Plaintext
|
|
{
|
||
|
|
"contents" : "#Copyright 2012 The Board of Regents of the University of Wisconsin System.\n#Contributors: Jason Shao, James McCurdy, Enhai Xie, Adam G.W. Halstead,\n#Michael H. Whitney, Nathan DiPiazza, Trey K. Sato and Yury V. Bukhman\n#\n#This file is part of GCAT.\n#\n#GCAT is free software: you can redistribute it and/or modify\n#it under the terms of the GNU Lesser General Public License as published by\n#the Free Software Foundation, either version 3 of the License, or\n#(at your option) any later version.\n#\n#GCAT is distributed in the hope that it will be useful,\n#but WITHOUT ANY WARRANTY; without even the implied warranty of\n#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n#GNU Lesser General Public License for more details.\n#\n#You should have received a copy of the GNU Lesser General Public License \n#along with GCAT. If not, see <http://www.gnu.org/licenses/>.\n########################################################################\n# #\n# Fit a parameterized model to the growth data in a well object. #\n# #\n# There are now three modelling choices: #\n# 1) Sigmoid model (no linear param c) #\n# 2) Linear Sigmoid model #\n# 3) Loess (with optional smoothing parameter) #\n########################################################################\n#' fit.model \n#' \n#' This function will use the function stored in the \"guess\" slot of \\code{growth.model} to calculate initial guesses \n#' for growth.model parameters, then it will use the \"formula\" slot with \\code{nls} to fit a non-linear least squares \n#' \\code{growth.model} or Local Polynomial Regression Fitting to the data. Richards model is first fitted. \n#' If the shape parameter is statisticaly significant then Richards is used. If it is within 2 SE of 1 or Zero than \n#' a simpler model is preferred. If the Richards fit fails, then Logistic is tried. If it fails, Gompertz is tried. \n#' Model fit failure is reported if none of the models can sucessfully fit the data \n#' \n#' @param input.well The well needed to be fitted with the given model. \n#' @param growth.model What growth model should be used? \n#' @param backup.growth.model If \\code{gowth.mode} fails, this model will be used. \n#' @param fit.if.no.growth should the function attempt to fit a well even if there was no growth detected? default is F \n#' @param silent output back to R console? \n#' @param use.linear.param: Should an additional linear parameter (c) be used when fitting the data to the model? \n#' @param use.loess: Should Local Polynomial Regression Fitting (loess function) be used instead of nls? \n#' @param smooth.param: If loess is used, an optional smoothing parameter. Default is .6 \nfit.model = function(input.well, growth.model, backup.growth.model = NULL, fit.if.no.growth = F, \n use.linear.param=F, use.loess=F, smooth.param, silent = T){\n \n # Conditional breakpoint: go into debugging mode when fitting a specific well\n #if (input.well@position[\"row\"] == \"A\" && input.well@position[\"col\"] == \"12\") browser()\n \n # Change all relevant slots to <NA> or blank values\n input.well@model.name = \"<NA>\"\n input.well@fit.par = list()\n input.well@equation = expression()\n \n # Get OD vs. time data from well\n input.data = data.from(input.well, na.rm = T)\n \n # Skip well if <no.growth> in slot \"curve.par\" is set to true, and <fit.if.no.growth> is false.\n if(!fit.if.no.growth & lacks.growth(input.well)){\n input.well@fit.info = \"skipped - no growth in well.\"\n if (!silent)\n cat(plate.name(input.well), well.name(input.well), \":\", input.well@fit.info, \"\\n\")\n return(input.well)\n }\n # Skip well if there are fewer than 5 data points left in the analysis.\n if (length(input.data$Time) < 5){\n input.well@fit.info =
|
||
|
|
"created" : 1425413287007.000,
|
||
|
|
"dirty" : false,
|
||
|
|
"encoding" : "UTF-8",
|
||
|
|
"folds" : "",
|
||
|
|
"hash" : "2355348307",
|
||
|
|
"id" : "B0B7416E",
|
||
|
|
"lastKnownWriteTime" : 1425509229,
|
||
|
|
"path" : "~/Documents/GCAT4/trunk/R/GCAT/R/fit.model.R",
|
||
|
|
"project_path" : "R/fit.model.R",
|
||
|
|
"properties" : {
|
||
|
|
},
|
||
|
|
"source_on_save" : false,
|
||
|
|
"type" : "r_source"
|
||
|
|
}
|