How to find doubling time of cells with scatterplot in R?

前端 未结 3 464
遥遥无期
遥遥无期 2021-01-27 18:45

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)         


        
3条回答
  •  自闭症患者
    2021-01-27 19:31

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

提交回复
热议问题