mikeblazanin / gcplyr

gcplyr is an R package that facilitates wrangling and analysis of microbial growth curve data
https://mikeblazanin.github.io/gcplyr/
Other
30 stars 2 forks source link

some form of rolling regression for smoothing and/or deriv calculation? #94

Closed mikeblazanin closed 1 year ago

mikeblazanin commented 1 year ago

E.g. like that implemented by Daniel: https://padpadpadpad.netlify.app/post/calculating-microbial-growth-rates-from-od-using-rolling-regression/ (formerly https://padpadpadpad.github.io/post/calculating-microbial-growth-rates-from-od-using-rolling-regression/)

I wonder if this would best be implemented by having calc_derivs be able to use a window-width wider than 1 and using least squares to fit a regression to the points that the slope of is then calculated (when window-width = 1 this reduces to the current calculation)

mikeblazanin commented 1 year ago

Notably: could have the fitting done in linear space or in log space (all log y axes are equivalent for fitting purposes)

Edit: not all log axes are equivalent for fitting purposes. Although they are all multiples of ea other and so fits will work fine, to get per-cap growth rate from slope have to use ln [or would have to scale other logs according to log_b(e)]

mikeblazanin commented 1 year ago

develop branch now has an attempt at this implemented. However, still need to iron out some creases and conceptually understand best practices for mixing percap & log axes

mikeblazanin commented 1 year ago

This is now all ironed out in v0.11.2.9000. Can set window_width or window_width_n for calc_deriv, and can use trans_y = "log" for percap derivs instead of the old way (which gives identical results when time resolution is fine enough)