1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| s_symbol = 'Bmal1' s_organ = 'Heart' s_project = 'compare1'
dt_s <- dt %>% subset(symbol == s_symbol & organ == s_organ & project == s_project) %>% mutate(group = factor(group))
options(show.error.messages = F, warn = -1) result <- try({ circacompare( x = dt_s, col_time = "time", col_group = "group", col_outcome = "measure", period = 24, alpha_threshold = 1, timeout_n = 100000, control = list( main_params = c("k", "alpha", "phi"), decay_params = c("alpha"), grouped_params = c("alpha", "alpha_decay") ) ) }, silent = TRUE) options(show.error.messages = T, warn = 1)
save_plot <- result$plot + theme_minimal() + ggtitle(paste(c(s_symbol, s_organ), collapse = '_')) + theme(plot.title = element_text(hjust = 0.5))
result$summary tmp <- circacompare:::extract_model_coefs(result$fit) tmp tmp['phi', c('estimate', 'std_error')] <- (tmp['phi', c('estimate', 'std_error')] / (2 * pi)) * save_plot$plot_env$V['tau'] tmp['phi1', c('estimate', 'std_error')] <- (tmp['phi1', c('estimate', 'std_error')] / (2 * pi)) * save_plot$plot_env$V['tau'] tmp
save_plot
{pdf(file = paste0('pdf/', paste(c(s_symbol, s_organ, s_project), collapse = '_'), '_decay.pdf'), width = 6, height = 6) print(save_plot) dev.off()}
|