【发布时间】:2021-07-01 12:15:03
【问题描述】:
我想使用ggplot 绘制剂量反应曲线,但是当我这样做时,它看起来非常不同。
是否可以使用 ggplot 绘制曲线,因为它看起来与使用基础 R 中的 plot 函数绘制时完全一样?
关于drm model 摘要的第二个问题:
哪个参数更能反映绑定:b、c、d 还是 e?
library(drm)
library(ggplot2)
test_data <- data.frame(Conc = c(0.0004882812, 0.001953125 ,0.0078125, 0.03125 ,0.125 ,0.5),
Response = c(1.616017 ,1.165835, 0.5783709, 0.3440007, 0.2668585, 0.2336709))
## plot drm model
model_drm <- drm(Response ~ Conc, data=test_data,
fct=LL.4())
summary(model_drm)
plot(model_drm)
## now using ggplot
ggplot(test_data, aes(x = Conc, y = Response )) +
geom_point() +
stat_smooth(method = "drm",
method.args = list(
fct = LL.4()),se = FALSE)
Model fitted: Log-logistic (ED50 as parameter) (4 parms)
Parameter estimates:
Estimate Std. Error t-value p-value
b:(Intercept) 1.15894518 0.08339821 13.896 0.005138 **
c:(Intercept) 0.24398009 0.01385086 17.615 0.003207 **
d:(Intercept) 1.81356338 0.05324814 34.059 0.000861 ***
e:(Intercept) 0.00261968 0.00020635 12.695 0.006148 **
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error:
0.01758151 (2 degrees of freedom)
编辑: 添加对数转换导致不再绘制曲线:
ggplot(test_data, aes(x = Conc, y = Response )) +
geom_point() +
stat_smooth(
method = "drm",
method.args = list(
fct = LL.4()
),
se = FALSE
)+
scale_x_continuous(trans="log10")
【问题讨论】:
-
在我看来,
plot()正在使用 x 轴上以 10 为底的转换的日志。尝试将+ scale_x_continuous(trans="log10")添加到您的ggplot代码中。 -
谢谢,但我尝试了对数转换,它删除了曲线。 log2 和 log10。此外,当我试图用 geom_line 来补偿它时,它并没有画出正确的曲线。仅将点相互连接。
-
如果我将
method="drm"替换为method="loess"(并删除method.args=...),我会得到预期的行为:出现该行。这表明method ="drm"存在问题 - 我认为这是由drm包提供的。