16 lines
14 KiB
Plaintext
16 lines
14 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# #\n# Functions to calculate various things about wells based on fit model #\n# #\n########################################################################\n\n# S3 generic\nlag <- function(fitted.well, ...)\n{\n UseMethod(\"lag\")\n}\n\n#\n# Common arguments:\n# fitted.well - should be a well containing the results of <fit.model>, most functions will return NA if well has not been fit yet.\n# unlog - should the value be returned on the linear scale as opposed to the log-transformed scale?\n# constant.added - for returning values on the linear scale, what was the constant added before the log transform?\n# digits - passed to the <round> function, default is no rounding (infinity digits)\n\nunlog = function(x, constant.added) {\n ########################################################################\n # Transform values back to OD scale #\n ########################################################################\nexp(x) - constant.added\n}\n\nwell.eval = function(fitted.well, Time = NULL){\n ########################################################################\n # Evaluate estimated OD at any timepoints using the fitted model #\n ########################################################################\n\n # If no timepoints are provided, use the ones collected in the experiment itself.\n\tif(!is.numeric(Time))\n\t\tTime = data.from(fitted.well)$Time\n\n # Use of equation is deprecated. Use nls and loess models stored in the well object instead\n # Attempt to use <eval> with the fitted equation and parameters to get estimates for OD at the given timepoints.\n\t#output = try(eval(fitted.well@equation, fitted.well@fit.par), silent = T)\n \n # Predict log.OD value(s) using nls model if present. If no nls model, try using loess.\n if (length(fitted.well@nls)>0) {\n output = try(predict(fitted.well@nls,list(Time=Time)),silent=T)\n } else if (length(fitted.well@loess)>0) {\n output = try(predict(fitted.well@loess,Time),silent=T)\n } else {\n output = NA\n }\n\n # Return values. If OD evaluation failed for any reason, return NULL.\n if (is.numeric(output)){\n return(output)\n } else {\n return(NULL)\n\t}\n}\n\nmodel.residuals = function(fitted.well, unlog = F){\n ########################################################################\n # Evaluate model residuals using the measured vs. fitted log.OD values #\n ########################################################################\n\tmeasured.OD = data.from(fitted.well)[,2]\n\n\t# Use <well.eval> with no Time argument to get fitted OD values at measured timepoints.\n\tpredicted.OD = well.eval(fitted.well)\n\n\t# If all values are valid, return the differences\n\tif (!is.numeric(predicted.OD))\n\t\treturn(NA)\n\telse\n return(measured.OD - predicted.OD)\n\t}\n\ndev.from.mean = function(fitted.well){\n ########################################################################
|
||
|
|
"created" : 1425413281936.000,
|
||
|
|
"dirty" : false,
|
||
|
|
"encoding" : "UTF-8",
|
||
|
|
"folds" : "",
|
||
|
|
"hash" : "2757150562",
|
||
|
|
"id" : "26C12555",
|
||
|
|
"lastKnownWriteTime" : 1428437531,
|
||
|
|
"path" : "~/Documents/GCAT4/trunk/R/GCAT/R/fitted.calculations.R",
|
||
|
|
"project_path" : "R/fitted.calculations.R",
|
||
|
|
"properties" : {
|
||
|
|
},
|
||
|
|
"source_on_save" : false,
|
||
|
|
"type" : "r_source"
|
||
|
|
}
|