问题描述
我正在尝试使用散点图来计算单元格的倍增时间.这是我的数据框
I'm trying to calculate the doubling time of cells using a scatterplot. This is my dataframe
df = data.frame("x" = 1:5, "y" = c(246, 667, 1715, 4867, 11694))
并且我已经使用此代码绘制了该数据框
and I've graphed this dataframe using this code
plot(df$x, df$y, xlab = "days", ylab = "cells mL -1")
有人知道如何使用图表计算这些单元的倍增时间吗?倍增时间的等式是(ln(2)/rate constant)
Does anyone know how to calculate the doubling time of these cells using the graph? the equation for doubling time is (ln(2)/rate constant)
推荐答案
绘制 log2(y)
与 x
抑制Y轴,以便我们构建更好的一.我们还略微改善了Y轴标签.然后使用 axis
构建漂亮的轴并计算倍增时间.请注意,如果速率常数是log(y)〜x回归线的斜率,则问题中加倍时间的公式有效,但是如果我们使用回归log2(y)〜x,即log2而不是log,则正确公式仅为1/slope.我们在下面都显示.
Plot log2(y)
vs. x
suppressing the Y axis so that we can build a nicer one. We also improved the Y axis label slightly. Then use axis
to build a pretty axis and calculate the doubling time. Note that the formula for doubling time in the question works if the rate constant is the slope of the log(y) ~ x regression line but if we use the regression log2(y) ~ x, i.e. log2 instead of log, then the correct formula is just 1/slope. We show both below.
plot(df$x, log2(df$y), xlab = "days", ylab = "cells/mL", yaxt = "n")
s <- 1:round(log2(max(df$y)))
axis(2, s, parse(text = sprintf("2^%d", s)))
fm <- lm(log2(y) ~ x, df)
abline(fm)
doubling.time <- 1/coef(fm)[[2]]
doubling.time
## [1] 0.7138163
log(2)/coef(lm(log(y) ~ x, df))[[2]] # same
## [1] 0.7138163
legend("topleft", paste("doubling time:", round(doubling.time, 3), "days"), bty = "n")
这篇关于如何在R中使用散点图查找细胞的倍增时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!