如何在 R 中将 EC50 值绘制到我的剂量反应曲线上?

问题描述 投票:0回答:2

我使用 R 中的 drm() 函数来查找数据的 EC50 值,然后创建剂量反应图。现在有了数据的 EC50 值和绘图,但我想将 EC50 值添加到曲线上。我有办法做到这一点吗?

此外,我想改变绘图的比例。目前,由于 y 值范围较窄 (0 - 0.95),该图显得非常狭窄。如何增加 y 轴刻度?

这是我的数据集-

# A tibble: 6 × 11
    conc    AR1  AR21   AR3  AR22   AR4  AR23    AR5
   <dbl>  <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>  <dbl>
1  0     0.943  0.963 0.967 0.947 0.98  0.94  0.96  
2  0.001 0.837  0.743 0.893 0.787 0.983 0.783 0.947 
3  0.01  0.363  0.22  0.857 0.13  0.95  0.107 0.937 
4  0.1   0.0133 0     0     0     0.923 0     0.94  
5  1     0      0     0     0     0.453 0     0.613 
6 10     0      0     0     0     0     0     0.0633

然后我拟合一个四参数对数逻辑模型

sporecount <- drm(AR1 ~ conc, data = Spore_Count_Averages_Plot_, 
                  fct = LL.4(names = c("Slope", "Lower Limit", "Upper Limit", "ED50"))

然后我绘制模型

plot(sporecount, broken = FALSE, xlab="Concentration", ylab="Percent Germinated", lwd=2, 
     cex=1.2, cex.axis=1.2, cex.lab=1.2)

我的输出是一个不错的剂量反应曲线,但我想将 EC50 值添加到图表上并增加 y 轴刻度。

r drm
2个回答
1
投票

U可以相应调整,u可以通过改变ylim = c(0, 1.5)来增加y轴

library(drc)
Spore_Count_Averages_Plot_ <- data.frame(
  conc = c(0, 0.001, 0.01, 0.1, 1, 10),
  AR1 = c(0.943, 0.837, 0.363, 0.0133, 0, 0),
  AR21 = c(0.963, 0.743, 0.22, 0, 0, 0),
  AR3 = c(0.967, 0.893, 0.857, 0, 0, 0),
  AR22 = c(0.947, 0.787, 0.13, 0, 0, 0),
  AR4 = c(0.98, 0.983, 0.95, 0.923, 0.453, 0),
  AR23 = c(0.94, 0.783, 0.107, 0, 0, 0),
  AR5 = c(0.96, 0.947, 0.937, 0.94, 0.613, 0.0633)
)

    # Assuming you have a data frame with your ED50 values
ed_values <- data.frame(concentration = c(0.00672008),
                        estimate = c(0.00672008),
                        std_error = c(0.00052615))

# Plot the model
plot(sporecount, broken = FALSE, xlab = "Concentration", ylab = "Percent Germinated", 
     lwd = 2, cex = 1.2, cex.axis = 1.2, cex.lab = 1.2,
     ylim = c(0, 1))  # Set y-axis limits

# Add vertical line for ED50
abline(v = ed_values$estimate, col = "blue", lty = 2)
text(x = ed_values$estimate + 0.02, y = 0.5,
     labels = paste("ED50 =", round(ed_values$estimate, 3)), col = "blue")

# Add horizontal line at y = 0.5
abline(h = 0.5, col = "green", lty = 2)

text(x = 0.01, y = 0.52, labels = "y = 0.5", col = "green")# u can avoid this things, i included just to show how it works

请注意,您可以使用单个 abline 函数绘制水平线和垂直线,我只使用了两次,以便您理解

abline(v = ed_values$estimate, h = 0.5, col = "blue", lty = 2)

如果您想将线条限制在它们相交的位置。为了实现这一点,您可以使用线段而不是 abline 来指定线条的起点和终点。

# Add lines
segments(y0 = 0.5, x0 = 0.000001, y1 = 0.5, x1 = ed_values$estimate, col = "blue", lty = 2)
segments(x0 = ed_values$estimate, y0 = 0, x1 = ed_values$estimate, 
         y1 = 0.5, col = "blue", lty = 2)

0
投票

您可以使用

drm()
命令从
ED()
获取 LD50 值,然后简单地绘制数据(我也添加了置信区间),并且您可以使用
text()
命令将任何内容添加到您想要的图表中在 R 基地。

library(drc)

Spore_Count_Averages_Plot_ <- data.frame(
  conc = c(0, 0.001, 0.01, 0.1, 1, 10),
  AR1 = c(0.943, 0.837, 0.363, 0.0133, 0, 0),
  AR21 = c(0.963, 0.743, 0.22, 0, 0, 0),
  AR3 = c(0.967, 0.893, 0.857, 0, 0, 0),
  AR22 = c(0.947, 0.787, 0.13, 0, 0, 0),
  AR4 = c(0.98, 0.983, 0.95, 0.923, 0.453, 0),
  AR23 = c(0.94, 0.783, 0.107, 0, 0, 0),
  AR5 = c(0.96, 0.947, 0.937, 0.94, 0.613, 0.0633)
)

sporecount <- drm(AR1 ~ conc, data = Spore_Count_Averages_Plot_, 
                  fct = LL.4(names = c("Slope", "Lower Limit", "Upper Limit", "ED50")))


plot(sporecount, broken = FALSE, xlab="Concentration", ylab="Percent Germinated", lwd=2, 
     cex=1.2, cex.axis=1.2, cex.lab=1.2, ylim=c(0,1))

#re-run to add confidence interval
plot(sporecount, broken = FALSE, xlab="Concentration", ylab="Percent Germinated", lwd=2, 
     cex=1.2, cex.axis=1.2, cex.lab=1.2, type="confidence", add = T, col="grey")


#get LD50 level
ED(sporecount, c(50), interval="delta")

#add to graph
text(0.1,0.5, "LD50 = 0.00672007", cex=2,font = 2 , col="black")

© www.soinside.com 2019 - 2024. All rights reserved.