How To: Fit Logistic Growth Models#

Fit logistic growth curves to time-series colony measurements and extract kinetic parameters (growth rate, carrying capacity, lag time) using LogGrowthModel.

[1]:
from phenotypic.data import load_meas
from phenotypic.analysis import LogGrowthModel
[2]:
df = load_meas()
df.head()
[2]:
Metadata_Condition Metadata_Media Metadata_Set Metadata_Replicate Metadata_Time Metadata_Strain Metadata_FileName ObjectLabel Bbox_CenterRR Bbox_CenterCC ... TextureGray_InfoCorrelation1-deg135-scale04 TextureGray_InfoCorrelation2-deg000-scale04 TextureGray_InfoCorrelation2-deg045-scale04 TextureGray_InfoCorrelation2-deg090-scale04 TextureGray_InfoCorrelation2-deg135-scale04 Metadata_StrainID TextureGray_HaralickVariance-avg-scale04 CorrectedCarryingCapacity_Intensity CorrectedCarryingCapacity_Area Metadata_Dataset
0 30C S 3 4 24 CBS11445 30C_2_3S_4 14 263.025755 327.103517 ... -0.033962 0.523065 0.263252 0.538240 0.318621 220 0.662881 1629.588639 4183.333333 S 30C
1 30C S 3 5 24 CBS11445 30C_2_3S_5 14 309.120466 291.332736 ... -0.035568 0.605276 0.243759 0.563349 0.376115 220 1.373371 1433.869174 3225.333333 S 30C
2 30C S 3 6 24 CBS11445 30C_2_3S_6 13 312.525658 262.907288 ... -0.068525 0.733840 0.519368 0.658842 0.497267 220 1.298390 1206.170181 2984.666667 S 30C
3 30C S 3 12 24 CBS11445 30C_2_3S_12 16 296.079598 305.151655 ... -0.057264 0.715456 0.470510 0.672158 0.475346 220 1.870195 1279.117711 3074.666667 S 30C
4 30C S 3 8 24 CBS11445 30C_2_3S_8 14 318.208931 260.158426 ... -0.034110 0.589887 0.358457 0.596423 0.342946 220 1.067527 1244.967859 2988.333333 S 30C

5 rows × 245 columns

Fit the Model#

Specify the target measurement column, grouping structure, and time label. The model fits a logistic curve to each group independently.

[3]:
model = LogGrowthModel(
    on="Shape_Area",
    groupby=["Metadata_Strain"],
    time_label="Metadata_Time",
    agg_func="mean",
)
[4]:
results = model.analyze(df)
results
[4]:
Metadata_Strain LogGrowthModel_r LogGrowthModel_K LogGrowthModel_N0 LogGrowthModel_µmax LogGrowthModel_Kmax ModelMetrics_MAE ModelMetrics_MSE ModelMetrics_RMSE ModelMetrics_R2 ModelMetrics_OptimizerLoss ModelMetrics_OptimizerStatus ModelMetrics_NumSamples LogGrowthModel_lambda LogGrowthModel_beta
0 CBS11445 0.166225 2714.816840 137.583035 112.817401 3018.454545 183.054994 42417.210922 205.954390 0.580127 125037.142217 2 5 1.2 2
1 CBS1553 0.167559 2305.175791 115.487180 96.563188 2472.666667 137.793563 22388.740726 149.628676 0.647338 69568.899266 2 5 1.2 2
2 CBS1554 0.146019 2378.764310 144.697287 86.836175 2552.125000 138.704733 22429.914843 149.766201 0.744076 73161.487382 2 5 1.2 2

The results DataFrame contains fitted parameters for each group: growth rate, carrying capacity (K), and lag time. Use these to compare strain fitness across experimental conditions.