Showing posts with label growth curve. Show all posts
Showing posts with label growth curve. Show all posts

Sunday, March 16, 2014

Align two vector, first try, not perfect results

See "align_curves.20140316.R" at github/project.H2O2.tolerance/Feb14,2011.H2O2.titration.bioscreen.star.strain



#20140316 align growth curves by minimizing sum of errors 

rm(list=ls())
debug = 9; 

#
pairwise_sum_of_errors = function( X1, X2, Start1,End1,Start2, End2 ) {
  if( (End1 - Start1) == (End2 - Start2) ) {
    return( sum( ( X1[Start1:End1]-X2[Start2:End2] )^2))
  } else {
    print("Error: X1 and X2 should have the same lengths")
    return( NA); 
  }
}

#testing 
x1 = 1:100;  x2 = 5:104
pairwise_sum_of_errors( x1, x2, 5, 100, 1,96)
sum((x1[5:100]-x2[1:96])^2)
pairwise_sum_of_errors( x1, x2, 5, 100, 1,100)

#align two vectors with equal lengths
#Let's assume start2 lags behind start1 
#start2 = start1 + delta # 2nd start lags behind 1st start by delta
pairwise_cost_of_shifted_vectors = function( delta, X1, X2,  low.threshold=0.01, debug=10 ){
  delta = floor( (delta+0.5) ) #delta must be an integer
  X1[X1<low.threshold]=0;
  X2[X2<low.threshold]=0;
  Start1 = 1;
  Start2 = Start1 + delta;  #left truncation at delta
  End2 = length(X2)
  End1 = length(X1) - delta; #right truncation at delta
  if(debug){ print(paste('Start1', Start1, "Start2", Start2, "End1", End1, "End2", End2))
  }
  if( (End1 - Start1) == (End2 - Start2) ) {
    return( sum( ( X1[Start1:End1]-X2[Start2:End2] )^2))
  } else {
    print("Error: X1 and X2 should have the same lengths")
    return( NA); 
  }
}

#testing 1
x1 = 5:104; x2 = 1:100;  
pairwise_sum_of_errors( x1, x2, 1,96, 5,100 )
pairwise_cost_of_shifted_vectors( 4, x1, x2)

delta = 4
res1 = optim(c(delta), fn=pairwise_cost_of_shifted_vectors, X1=x1, X2=x2, method="Brent", lower=c(1), upper=c(100))
#return 3 not 4? 

#testing 2
x1 = 50:149; x2 = 1:100;  
pairwise_sum_of_errors( x1, x2, 1,50, 50,99 )
pairwise_cost_of_shifted_vectors( 49, x1, x2)

delta = 50
res2 = optim(c(delta), fn=pairwise_cost_of_shifted_vectors, X1=x1, X2=x2, method="Brent", lower=c(1), upper=c(100))
#return 50 not 49?

Saturday, March 15, 2014

Calculating the lag phases in growth curves by minimizing sum of squared errors


I studied '1471-2180-11-140-s1.m', a matlab script that can estimate lag phases from growth curves. This program can 'align' growth curves using the matlab optimization procedures.  I used Octave 3.8.0 with GUI and found it useful.

My plan to is to use R optim() to minimize the sum of errors.  The differences of lag phases are the indices in the vectors.   So, somehow, I need to re-index the vectors.  Maybe I can use the a small threshold and put NA to very small values.  I will then have two vectors, X1 and X2.  The sum of errors can be defined as
  SumOfErrors = sum( (X1[1:lengthOfX2] - X2[delta:END2] )^2 )

20140316:
This is basically the global alignment problems in sequence alignment.


Reference:
1471-2180-11-140-s1.m  from the Xavier group.

Monday, February 25, 2013

Quantifying microbial cell growth, Hartman group and Xavier group


In Shah 2006 BMC Systems Biology,  the Hartman group used an ecology-based growth model to quantify yeast colony growth.

This model is an extension of the simple logistic function
where the numerator is replaced by the carrying capacity, and time is adjusted by TMR.

This paper provide the fitting results to  'wells' in a plate in S4 table. 

I did not find measurements for individual strains, perhaps because this is a method paper.


For comparison, the liquid culture growth curves are modeling by Ditmarsch & Xavier 2011 BMC Microbiology.  DX11 used Monon's equation based on nutrient concentration (N):


DX11 estimates the lag-phase between starting cell density X1 and X2 (X2>X1) by

Both approaches used the concept of carrying capacity.


Reference:
  •  Accurate, precise modeling of cell proliferation kinetics from time-lapse imaging and automated image analysis of agar yeast culture arrays, Najaf A Shah, Richard J Laws, Bradley Wardman, Lue Ping Zhao and John L Hartman IV, BMC Systems Biology, 2006. PubMed
  •  http://www.biomedcentral.com/1471-2180/11/140  Xavier group's liquid growth curve model.
2013 Oct 5,
The following 2012 NBT paper measured growth and aging in a modified BY4741 background. 
http://www.sysbiol.cam.ac.uk/Muellederetalnbt2442.pdf