STEP 9 / 14

回歸、相關與劑量反應

線性、非線性、IC50、Hill 與 Michaelis-Menten——讓函數真的描述生物現象。

Linear, nonlinear, IC50, Hill, and Michaelis-Menten — making functions actually describe biology.

為什麼相關係數會騙人?

Pearson r 衡量「線性」關聯,對非線性關係毫無感應(即使是完美 sin 曲線 r 可能 ~0)。Spearman 用排名,對單調非線性穩健。劑量反應曲線本質是 sigmoidal,硬套線性回歸是論文 reviewer 最常質疑的問題之一。

Ritz et al. 2015 (PLOS ONE) 的 R 套件 drc 是劑量反應分析的標準工具,2025 年 dr4pldrda 在 robust 估計上更進一步。Sebaugh 2011 提醒:可靠的 IC50/EC50 估計必須包含上下平台區。

Pearson r measures linear association — completely blind to non-linear ones (a perfect sine wave gives r≈0). Spearman uses ranks, robust to monotonic non-linearity. Dose-response curves are inherently sigmoidal; forcing a linear fit is among reviewers' top complaints.

The R package drc (Ritz et al. 2015, PLOS ONE) is the dose-response standard; in 2025 dr4pl and drda advance robust estimation. Sebaugh 2011 reminds us: trustworthy IC50/EC50 estimates require the standard to cover both plateaus.

⚠️
三大線性回歸假設:(1) 線性 (Linearity)、(2) 殘差獨立、(3) 殘差常態+等變異 (homoscedasticity)。違反須改 GLM、weighted least squares、或 robust regression。Three linear regression assumptions: (1) Linearity, (2) Independent residuals, (3) Normal & homoscedastic residuals. Violations → GLM, weighted least squares, or robust regression.

一、相關 vs 回歸

📊

Pearson r

線性、有方向 (−1~+1)、對 outlier 敏感。要求雙變量近似常態。

Linear, directional (−1 to +1), outlier-sensitive. Requires both variables ~normal.

📈

Spearman ρ

排名相關。對單調非線性、outlier 穩健。報告時須註明是 ρ 不是 r。

Rank correlation. Robust to monotonic non-linearity and outliers. Label as ρ, not r.

📐

Linear regression

給出方程式與斜率(含 CI 與 p)。可預測,但有方向假設。

Provides equation, slope (with CI & p), and prediction. Has directional assumption.

📉

Nonlinear regression

4-PL、Hill、Michaelis-Menten、雙指數衰減等。需給合理初始值,否則收斂困難。

4-PL, Hill, Michaelis-Menten, biexponential decay, etc. Needs sensible initial values to converge.

劑量反應曲線參數

調整 Hill slope 與 IC50,觀察曲線形狀變化。實務上 Hill ≈ 1 表示 1:1 binding;Hill > 1 表示協同 (cooperativity)。

Tune Hill slope and IC50 to see curve shape. Hill ≈ 1 indicates 1:1 binding; Hill > 1 indicates cooperativity.

X:log10(μM) | Y:% inhibition

二、各種回歸的 R/Python 程式碼

# 1. 線性回歸 + 假設診斷
fit <- lm(y ~ x, data=df)
summary(fit)
library(performance); check_model(fit)     # Q-Q、殘差、共線性、影響點

# 2. 相關
cor.test(df$x, df$y, method="pearson")
cor.test(df$x, df$y, method="spearman")

# 3. 劑量反應 (4-PL) — drc
library(drc)
fit <- drm(response ~ dose, data=df, fct=LL.4())
summary(fit)
ED(fit, c(50), interval="delta")        # IC50 with 95% CI

# 4. Michaelis-Menten — nls
mm <- nls(v ~ Vmax*S/(Km+S), data=enz, start=list(Vmax=2, Km=0.5))
summary(mm)
import numpy as np, pandas as pd
from scipy import stats
from scipy.optimize import curve_fit
import statsmodels.api as sm

# 1. 線性回歸 + 假設診斷
X = sm.add_constant(df.x)
fit = sm.OLS(df.y, X).fit()
print(fit.summary())                          # Q-Q via fit.resid + statsmodels.graphics.gofplots.qqplot

# 2. 相關
stats.pearsonr(df.x, df.y)
stats.spearmanr(df.x, df.y)

# 3. 4-PL 劑量反應
def hill(x, IC50, n, top, bot):
    return bot + (top - bot) / (1 + (x/IC50)**n)
popt, pcov = curve_fit(hill, df.dose, df.response, p0=[1,1,100,0])
print("IC50 =", popt[0], "Hill n =", popt[1])

# 4. Michaelis-Menten
def mm(S, Vmax, Km): return Vmax*S/(Km+S)
popt, _ = curve_fit(mm, enz.S, enz.v, p0=[2, 0.5])
🚨
禁忌:用 Lineweaver-Burk 雙倒數圖估 Vmax/Km。線性化把誤差結構嚴重扭曲;現代教科書 (Cornish-Bowden, Fundamentals of Enzyme Kinetics) 全部反對。直接用 nls / curve_fit 非線性擬合。Forbidden: Using Lineweaver-Burk double-reciprocal plots to estimate Vmax/Km. Linearization distorts errors severely; modern textbooks (Cornish-Bowden) universally reject it. Use nls / curve_fit instead.

三、reviewer 必查清單

r² 當作唯一指標

非線性 fit 用 r² 沒意義(也不在 0-1 之間)。看 AIC / BIC + residual plot。

r² is meaningless for non-linear fits (not bounded 0-1). Use AIC/BIC + residual plot.

IC50 外推

曲線未涵蓋 top/bottom 平台 → IC50 不可信。需設計濃度橫跨 IC50 上下各 1-2 個 log。

Without top & bottom plateaus the IC50 is unreliable. Design doses spanning ~2 logs above and below the expected IC50.

忽略殘差診斷

檢查 residual vs fitted(線性?同質?)、Q-Q(常態?)、leverage(影響點?)。違反任一需處理。

Check residual-vs-fitted (linearity/homoscedasticity), Q-Q (normality), leverage (influential points).

相關當因果

相關只反映共變,因果需介入實驗或工具變量。報告時避免「導致」「造成」這類因果語言。

Correlation is co-variation, not causation. Avoid causal language ("causes," "leads to") without an intervention or instrumental variable.

🎯 章末小測驗

1. 非線性單調 + outlier 用?

Pearson r
Spearman ρ
Cosine similarity
R² of linear regression

2. 估 Vmax/Km 正確做法?

Lineweaver-Burk
nls 非線性擬合
Eadie-Hofstee plot
目測

3. Hill slope = 2 代表?

兩個獨立 site
正向協同
負向協同
IC50 = 2