knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(readyg)
theme <- theme_bw() +
  theme(panel.grid.minor = element_blank(),
         panel.grid.major = element_line(size = 0.1))
ggplot2::theme_set(theme)
vline_label <- function(data, x, label = deparse(x)) {
    list(
        geom_vline(data = data, 
               aes_string(xintercept = x), 
               size = 0.25),
    geom_text(data = data, 
              aes_string(x = x, y = '0', label = label), 
              family = "Helvetica", 
              angle = 90, 
              hjust = 'left', 
              color = 'white', 
              fontface = 'bold'),
    geom_text(data = data, 
              aes_string(x = x, y = '0', label = label), 
              angle = 90, 
              hjust = 'left')
    )
}

hline_label <- function(data, y, label = deparse(y)) {
    list(
        geom_hline(data = data, 
               aes_string(yintercept = y), 
               size = 0.25),
    geom_text(data = data,
              aes_string(x = '0', y = y, label = label),
              family = "Helvetica",
              hjust = 'left',
              color = 'white',
              fontface = 'bold'),
    geom_text(data = data, 
              aes_string(x = '0', y = y, label = label), 
              hjust = 'left')
    )
}

an example file

file <- '~/data/yeast-grower-db/db/07/01_04_14_AstraZeneca_maxdose_ps1_A_96_T_10.txt'
contents <- read_yg(file)
contents %>% unnest(data)
analysis_section <- readyg:::read_ini_section(file, 'Analysis')
one_well <- contents %>% unnest(data) %>% filter(well == 'A01')
one_well <- mutate(one_well, runtime_h = runtime / 3600)
one_well_analysis <- analysis_section %>% 
    mutate(value = map_chr(value, ~unlist(str_split(.x, ','))[1])) %>% 
    spread(name, value, convert = T)
one_well %>% 
    ggplot(aes(x = runtime_h, y = value)) + 
    geom_point() + 
    vline_label(one_well_analysis, 'Time_to_each_n_Gens') + 
    vline_label(one_well_analysis, 'gen_time_cutoff') + 
    geom_line()
one_well %>% 
    ggplot(aes(x = runtime_h, y = value)) + 
    geom_point() + 
    geom_line() +
    vline_label(one_well_analysis, 'Time_Saturation') + 
    hline_label(one_well_analysis, 'OD_Saturation')
one_well %>% 
    ggplot(aes(x = runtime_h, y = value)) + 
    geom_point() + 
    geom_line() +
    vline_label(one_well_analysis, 'Time_Inflex') + 
    hline_label(one_well_analysis, 'OD_Inflex')

$$ t_{0_g0} = T_{nG} \cdot G_by_interval $$

one_well %>% 
    ggplot(aes(x = runtime_h, y = value)) + 
    geom_point() + 
    geom_line() +
    vline_label(one_well_analysis, 't0_from_interval')
one_well %>% 
    ggplot(aes(x = runtime_h, y = value)) + 
    geom_point() + 
    geom_line() +
    vline_label(one_well_analysis, 'Time_to_each_n_Gens') +
    hline_label(one_well_analysis, 'OD_Gen_Pt')

$$ Avg_G = \frac{Time_to_each_n_Gens}{OD_Gen_Pt} \ OD_Gen_Pt = 0.46 \ n\ Generations\ at = 5 \ Time_to_each_n_Gens = 9.78 \ Avg_G = \frac{Time_to_each_n_Gens}{nG_{OD_Gen_Pt}} = \frac{9.78}{5} = 1.956 $$

$ Avg_G 1.956 $ Avg_G_inflex 1.977 $ Avg_G_t12 1.956 $ Avg_G_t8 2.028 $ Avg_G_tcut 1.956

Can I compute Avg_G_inflex properly now?

Time_Inflex = 9.047
Avg_G_inflex = 1.977
OD_Inflex = 0.444
OD_Gen_Pt = 0.46
nG_at_OD_Gen_Pt = 5
nG_at_Time_Inflex = (OD_Inflex / OD_Gen_Pt) * nG_at_OD_Gen_Pt
nG_at_Time_Inflex
Time_Inflex / nG_at_Time_Inflex
Time_Inflex / Avg_G_inflex

$$ OD_g \cdot exp(ln(2) \cdot x) \ 5 \cdot exp(ln(2) \cdot 0.46) \ 5 \cdot exp(ln(2) \cdot 0.44) $$



npjc/growr documentation built on Nov. 9, 2019, 7:29 a.m.