I have a dataset as follows. I want to plot a dose-response curve to show the IC50 value using the drc
package.
df <- structure(list(conc = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L), levels = c("0", "0.1", "1", "10", "100", "1000",
"10000", "30000", "60000", "90000", "100000", "DMSO"), class = "factor"),
fl = c(100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 63.21225779,
101.8706211, 126.2780865, 111.5314588, 96.09426602, 78.24238472,
96.09755918, 100.5283698, 91.27381472, 97.37499067, 115.0726428,
122.5959865, 85.41762336, 179.9769368, 98.35492747, 100.5908253,
84.26773394, 101.4552505, 125.1702075, 95.88848656, 82.24099899,
110.2141294, 79.66828574, 90.02040403, 94.98167177, 99.46936453,
119.7006765, 130.5157993, 78.18920918, 96.01585941, 102.5847831,
108.9026336, 101.5528383, 79.31066707, 115.2681603, 89.6393365,
117.9085333, 96.37725618, 91.7460037, 102.0326665, 91.31663206,
90.26150215, 97.92890336, 114.4366954, 96.87187883, 109.927939,
107.3011341, 102.2116202, 96.90044379, 100.2864878, 92.65414961,
96.18469623, 93.8303407, 140.0548471, 98.65695034, 92.83672632,
106.3178975, 103.0082607, 99.91031153, 116.7370842, 100.0813435,
101.2193641, 114.7206302, 100.5724823, 129.0270352, 101.4296353,
78.85143217, 116.4561314, 110.9225058, 95.51300981, 95.82320759,
112.0002344, 153.6020867, 88.55315754, 62.40109088, 77.81809955,
82.93065795, 92.28863559, 68.89955766, 98.32670152, 100.4676841,
51.65315094, 92.33042129, 115.9890869, 83.31973839, 53.25314434,
168.4599862, 49.95222165, 76.48054079, 0.887138442, -0.584344871,
0.416501996, 45.54363915, 23.61298376, 23.16807216, 4.571463311,
3.184265707, 0.919448776, 0.451929132, -1.014153522, -1.039708501,
1.397715644, 0.051578618, 0.790341673, 5.248865072, 46.02295576,
44.89215709, 25.50864995, 51.47704304, 39.381729, 22.5317588,
14.1313762, -0.42971322, 26.95053851, 36.55531489, 21.38622522,
7.384904715, 1.105835897, 1.913830946, -0.168468303, -0.320132148,
23.98090175, 8.798552887, 5.042674912, 2.967859167, -1.471078129,
0.163655876, -0.326592551)), class = "data.frame", row.names = c(NA,
-148L))
This df
dataframe I wish to calculate the IC50 from. I have been using the following code:
library(drc)
model <- drm(fl ~ as.numeric(conc), data=df, fct=LL.4(names=c("Slope", "Lower Limit", "Upper Limit", "IC50")))
model
#note the IC50 value of 7.577
Now when I plot the model
plot(model, type="all", xlab="Concentration", ylab="Normalised Fluorescence", log="x")
This gives a log x axis. When I try to get back to my original axis by changing log = "x" to log = "", I get this:
But looking back at my original concentrations, I have values from 0-90,000, not 0-12, which is what the graph is showing. How do I change the x-axis to my actual concentration values? My IC50 is 7.577, which makes sense for the scale given by the plot, but not in my actual units of concentration. So how do I then convert the IC50 value back to the correct scale as well?
To convert to "numeric"
, you need to transform "factor"
s as.character
first, see these answers.
df$conc_num <- as.numeric(as.character(df$conc))
library(drc)
model <- drm(fl ~ conc_num, data=df, fct=LL.4(names=c("Slope", "Lower Limit", "Upper Limit", "IC50")))
plot(model, type="all", xlab="Concentration", ylab="Normalised Fluorescence", log='x')