简体   繁体   中英

How to draw this graph and get dose equation in R?

在此处输入图像描述

I got this graph and equation in excel. How to get this equation, graph and calculation method?

# Raw Data
μM <- c(0.01, 0.03, 0.1, 0.3, 1, 3, 10, 30)
log_μM <- log(c(0.01, 0.03, 0.1, 0.3, 1, 3, 10, 30))
DMSO <- c(97.01, 98.43, 98.29, 97.66, 96.51, 88.39, 38.54, 2.63) # D137
log_DMSO <- log(c(97.01, 98.43, 98.29, 97.66, 96.51, 88.39, 38.54, 2.63))
#DMSO <- c(98.29, 98.35, 99.79, 99.78, 100.43, 100.19, 99.51, 99.16) # STB-D8
dat <- data.frame(μM, DMSO)
log_dat <- data.frame(log_μM, log_DMSO)

I want to draw graph in R and get R square value, equation!

This may get you what you want. This equation is linear unlike your example.

R2 <- with(dat, cor(μM, DMSO)^2)
R2
dat.lm <- lm(DMSO~μM, dat)
summary(dat.lm)
x <- seq(min(dat$μM), max(dat$μM), length.out=100)
y <- predict(dat.lm, list(μM=x))
options(scipen=10)  # To prevent x-axis labels from using scientific notation
plot(DMSO~μM, dat, log="xy", main="Dose", pch=16, xlim=c(.01, 100), ylim=c(1, 1000), col="blue", las=1)
grid(col="darkgray")
lines(x, y, lty=3, col="blue")
mtext(bquote(""*R^2 ==.(round(R2, 4))), 3, line=.5, adj=1, cex=.75)
mtext(bquote(""*DMSO == .(round(coeff[1], 2))~"+"~.(round(coeff[2], 2))~"μM"), 3, line=1.3, adj=1, cex=.75)

阴谋

To draw a sigmoid curve you will need to use nls() with self-Start function SSlogis()

dat.nls <- nls(DMSO ~ SSlogis(μM, Asym, xmid, scal), data = dat)
x <- seq(0, 30, length.out=50)
plot(DMSO~μM, dat)
lines(x, predict(dat.nls, list(μM=x)), lty=2)
coeff <- coef(dat.nls)
mtext(bquote(""*DMSO == .(round(coeff[1], 2))~"/(1 + exp("~.(round(coeff[2], 2))~"- μM)/"~.(round(coeff[3], 2))~")"), 3, line=0, adj=1)

I am not adding the R-square value because there is disagreement on how to compute it with an asymptotic function.

渐近图

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