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 Object_Label 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.128296 2774.486146 361.146883 88.989209 3018.454545 149.156592 37500.693073 193.650957 0.628794 1235.513459 3 5 1.2 2
1 CBS1553 0.096670 2461.589556 268.039039 59.490509 2472.666667 111.983445 41337.150766 203.315397 0.348866 915.756366 2 5 1.2 2
2 CBS1554 0.049705 2549.056960 1027.927953 31.675310 2552.125000 50.849750 4101.485366 64.042840 0.953202 1411.496844 3 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.