rdrm

How can I plot an EC50 value onto my dose-response curve in R?


I used the drm() function in R to find the EC50 value of my data, and then created a dose-response plot. Now have the EC50 value of my data and a plot, but I want to add the EC50 value onto the curve. Is there a way I can do this?

Furthermore, I want to change the scale of the plot. Currently, the plot appears very narrow because of my narrow range of y-values (0 - 0.95). How can I increase the y axis scale?

Here is my dataset-

# 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

I then fit a four parameter log logistic model

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

Then I 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)

My output is a decent dose response curve, but I want to add the EC50 value onto the graph and increase the y axis scale.


Solution

  • U can adjust accordingly , u can increase y axis by changing ylim = c(0, 1.5)

    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
    

    enter image description here

    Note that u can draw both horzontal and vertical line withing single abline function, i just used two time, to make u understand

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

    If you want to limit the lines to where they meet. To achieve this, you can use segments instead of abline to specify the start and end points of the lines.

    # 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)