#' make_manhattan
#' @export
make_manhattan <- function(res, p.type, plot.type, plot_height) {
dev.new()
plot_height
res <- res %>%
dplyr::filter_(paste0(p.type, "<=", 0.05)) %>%
manhattan_plot(result = ., type = plot.type)
g <- plotly::ggplotly(res ,tooltip = c('label', 'text'), height = plot_height)
dev.off()
g
}
#' make_dumbbell
#' @export
make_dumbbell <- function(res, plot_height, db_type) {
if(nrow(res) > 0) {
res <- dumbbell_plot(res, db_type =db_type)
plotly::ggplotly(res, tooltip = c('CODE_LABEL_TIP', 'CI95'), height = plot_height)
}
}
#'make_print_table
#'@export
make_print_table <- function(res, cols_to_remove, boot) {
if(nrow(res) > 0) {
result_to_print <- res %>%
dplyr::filter(p_fdr <= 0.05)
if(nrow(result_to_print) > 0) {
result_to_print <- result_to_print %>%
arrange(p.value) %>%
mutate(cases = paste0(cases,'/',cases+cases0, ' (',round(cases/(cases+cases0),2),')'),
control = paste0(control,'/',control+control0, ' (',round(control/(control+control0),2),')'),
OR = paste0(round(OR,1),' [',round(CI_inf,1),'-',round(CI_sup,1),']'),
p.value = format(p.value, digits = 2, scientific = TRUE),
p_fdr = format(p_fdr, digits = 2, scientific = TRUE),
p_bonf = format(p_bonf, digits = 2, scientific = TRUE)) %>%
select_( .dots = cols_to_remove) #-CODE, -CI_inf, -CI_sup, -cases0,-control0)
if (boot) {
result_to_print <- result_to_print %>%
mutate(OR_bootstrap = paste0('[',format(CI_OR_inf, digits = 2, scientific = TRUE),'-',format(CI_OR_sup, digits = 2, scientific = TRUE),']'),
pvalue_bootstrap = paste0('[',format(p_inf, digits = 2, scientific = TRUE),'-',format(p_sup, digits = 2, scientific = TRUE),']')) %>%
select(-term, -CI_OR_inf, -CI_OR_sup, -p_inf,-p_sup)
}
} else {
result_to_print <- data.frame(Results = 'No result reached the FDR correction threshold.')
}
# if (boot) {
# result_to_print <- result_to_print %>%
# mutate(OR_bootstrap = paste0('[',format(CI_OR_inf, digits = 2, scientific = TRUE),'-',format(CI_OR_sup, digits = 2, scientific = TRUE),']'),
# pvalue_bootstrap = paste0('[',format(p_inf, digits = 2, scientific = TRUE),'-',format(p_sup, digits = 2, scientific = TRUE),']')) %>%
# select(-term, -CI_OR_inf, -CI_OR_sup, -p_inf,-p_sup)
# } else{
# result_to_print
# }
} else {
result_to_print<- data.frame(Results = 'No result.')
}
return(result_to_print)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.