简体   繁体   中英

R point-to-point method for calculating x given y

I am using a commercial ELISA kit which contains four standards. These standards are used to create a standard curve, with optical densities from the ELISA reader on the y axis and concentrations in international units per milileter on the x axis.

I now need to use this standard curve to get concentrations for samples in which I only have the optical density readings. The ELISA kit instructions specifically state "Use “point-to-point” plotting for calculation of the standard curve by computer".

I am assuming they mean derive the value of x by seeing where y is hitting the line between the points on the standard curve and dropping down to the x axis from there. The problem is I have no idea how to do this in r (which is what I am using for my full analytical pipeline). I have searched in vain for any r packages, functions or code which correspond to "point-to-point" but can´t find anything. All the R packages that deal with ELISA data and / or standard curves (eg drc and ELISAtools seem to do something much more complex, ie fit a log model and account for inter-plate variances etc., which is not what I need.

Please note that I don´t need to visualise the standard curve - I just need a method to get the concentrations from the standard curve data based on the point-to-point line.

Here is some sample data:

# Data for standard curve:
scdt <- data.table(id = c("Cal1", "Cal2", "Cal3", "Cal4"), 
                   conc = c(200, 100, 25, 5), 
                   od = c(1.783, 1.395, 0.594, 0.164))

> scdt
     id conc    od
1: Cal1  200 1.783
2: Cal2  100 1.395
3: Cal3   25 0.594
4: Cal4    5 0.164

# Some example OD values for which I would like to derive concentration:
unknowns <- c(0.015, 0.634, 0.891, 1.510, 2.345, 3.105) 

In the example values I want to solve for x, I have also included some that are outside the range covered by the standards as this also occurs in my real data from time to time. The kit manufacturer advises against reporting IU/mL for anything with an OD exceeding that of the highest standard (Cal1) which is sensible.

How can I do the R equivalent of finding x with a ruler and graph paper from the standard curve and what is this formally called? (I think one reason I might not have found anything is because "point-to-point" isn´ta mathematical term, but there must be one for this - is it interpolation?).

It sounds like you want a simple linear interpolation. This is achieved in R using the function approx . You feed it your known x values, your known y values and the new values for x for which you want the corresponding y values. (Note that it doesn't matter which variable you call x and which you call y, as long as you are consistent).

To get a result that is easier to work with, we can convert the response to a data frame with appropriate column names:

new_data <- approx(scdt$od, scdt$conc, xout = unknowns) |> 
  setNames(c("od", "conc")) |> 
  as.data.frame() 

new_data
#>      od      conc
#> 1 0.015        NA
#> 2 0.634  28.74532
#> 3 0.891  52.80899
#> 4 1.510 129.63918
#> 5 2.345        NA
#> 6 3.105        NA

Note that (as the manufacturer recommends), optical densities falling outside the extreme ranges of your calibration points will give NA values for concentration. To get these you would need to extrapolate rather than interpolate

Just to confirm this is what you're looking for, let's plot the results of this interpolation in red over the curve formed from the initial data:

plot(scdt$od, scdt$conc, type = "l", lty = 2)
points(scdt$od, scdt$conc)
points(new_data$od, new_data$conc, col = "red")

在此处输入图像描述

We can see that the estimated concentrations at each new optical density lie on the lines connecting the calibration points.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM