[R] smooth.spline error while fitting bacterial growth curves with grofit

Jeffrey David Johnson jefdaj at berkeley.edu
Sun May 17 19:42:58 CEST 2015

I'm trying to use the grofit package to compare growth rates between
bacterial cultures, but I've come across a couple glitches/things I
don't understand. I'm not sure if they're related to the package or to a
problem with my growth data, which is messy. Some strains don't follow
a proper logarithmic growth curve because they died or didn't grow over
the course of the experiment. I could remove those but it will get more
time consuming once I have more cultures going.

I've attached the 'time' matrix and 'data' data frame. This code should
fit the growth curves, but when I run it I get an error related to

mytime <- as.matrix(read.table('time.txt'))
mydata <- read.csv('data.csv')
dimnames(mytime) <- NULL
fits <- gcFit(mytime, mydata, grofit.control(
  interactive=FALSE, # don't ask if the graphs look OK
  nboot.gc=1000,     # number of bootstraps
  fit.opt="s"        # just do splines, no models

= 1. growth curve =================================
= 2. growth curve =================================
= 3. growth curve =================================
Error in smooth.spline(time, data, spar = control$smooth.gc) : 
  'tol' must be strictly positive and finite
Error in gcFitSpline(time.cur, data.cur, gcID, control.change) : 
  object 'y.spl' not found

That error usually occurs at some point, though I've run through all 17
successfully a couple times. The documentation says:

> smooth.gc: Parameter describing the smoothness of the spline fit;
> usually (not necessary) in (0;1]. Set ‘smooth.gc=NULL’ causes the
> program to query an optimal value via cross validation techniques.
> Note: This is partly experimental. In future improved implementations
> of the ‘smooth.spline’ function may lead to different results. See
> documentation of the R function ‘smooth.spline’ for further details.
> Especially for datasets with few data points the option ‘NULL’ might
> result in a too small smoothing parameter, which produces an error in
> ‘smooth.spline’. In that case the usage of a fixed value is
> recommended. Default: ‘NULL’.

I tried setting different values (0.1, 0.5, 0.9, 1, 10) and they all
cause the same error. If instead I use the `gcBootSpline` function
directly, it gives a different error about the number of bootstraps
being 0, when they clearly aren't:

fits <- gcBootSpline(mytime, mydata, grofit.control(nboot.gc=1000))

Error in gcBootSpline(mytime, mydata, grofit.control(nboot.gc =
1000)) : Number of bootstrap samples is zero! See grofit.control()

Am I using these right? Is there something about the data that would
make it un-fittable?

More information about the R-help mailing list