Files
2015-GCAT/R/GCAT/.Rproj.user/7CB73FCA/sdb/per/t/1B6124D6
T

16 lines
20 KiB
Plaintext
Raw Normal View History

2015-04-10 15:12:45 -05:00
{
"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# Estimate the growth curve slope at each timepoint of a well #\n# #\n########################################################################\n#\n# uses the functions <data.from> and <well.name> (see well.class.R) \n# adds estimated slopes as a new column to the \"screen.data\" slot\n\ncalculate.slopes = function(input.well, silent = T){\n # Get the growth curve data (excluding removed points, but not excluding points marked as tanking)\n\tgrowth.data = data.from(input.well, remove = T, remove.tanking = F)\n\tx = growth.data[,1]\n\ty = growth.data[,2]\n\t\n\t# Get a list of timepoint indices \n\tindices = as.numeric(rownames(growth.data))\n\t\n # Default slope is NA, values will be filled in as they are calculated\n slopes = rep(NA, length(input.well))\n\n\tfor (i in 1:length(x)){ \n\t\tif (i == 1)\n\t\t\tslopes[indices[i]] = NA\n # Calculate the slope of the line drawn from each point to the point preceding it. \n\t\telse\n\t\t\tslopes[indices[i]] = (y[i] - y[i-1])/(x[i] - x[i-1])\n\t\t}\n # Add a Slope column to the \"screen.data\" slot \n\tinput.well@screen.data$Slope = slopes\n\tif (!silent)\n\t\tcat(\"slopes filled for\", input.well@position[1], well.name(input.well), \"\\n\")\n\treturn(input.well)\n }\n \n \n########################################################################\n# #\n# Use slope estimates to check growth curves for tanking and OD jumps #\n# #\n########################################################################\n#\n# uses the functions <data.from> and <well.name> (see well.class.R) \n# Arguments: \n# ----- stringency parameters ----\n# remove.jumps - should the program remove OD jumps? default F (just report them) - \n# should be set to T if data contains distinct jumps in OD that need to be eliminated \n# otherwise, this might be too stringent and will result in loss of data. \n# check.start - which timepoint should checking for jumps and tanking start at? this is included because early timepoints can be unstable.\n# fall.cutoff - what downward slope should constitute a fall in OD? \n# jump.cutoffs - multipliers to determine whether a curve jumps up or down (see methods 1 and 2, below)\n# tank.limit - how many timepoints in a row can have falling slopes until the curve is marked as tanking?\n# tank.cutoff - what proportion of the maximum OD can the curve go below until it is considered tanking?\n\n# ---- input/output ----\n# silent - output to R console?\n# draw - plot growth curve with curve checking details? \n#\n# Fills the \"curve.par\" slot in the well with the starting index of tanking (NA if none is found)\n# \n\n#check.slopes = function(input.well, check.start = 8, fall.cutoff = -.0025, remove.jumps = F,\n#\t\t\tjump.multipliers = -c
"created" : 1425413252161.000,
"dirty" : false,
"encoding" : "UTF-8",
"folds" : "",
"hash" : "2162891425",
"id" : "1B6124D6",
"lastKnownWriteTime" : 1424208623,
"path" : "~/Documents/GCAT4/trunk/R/GCAT/R/slope.analysis.R",
"project_path" : "R/slope.analysis.R",
"properties" : {
},
"source_on_save" : false,
"type" : "r_source"
}