diff --git a/DESCRIPTION b/DESCRIPTION index ae5ea6d33495e09473fd2941bcbbfc62f880e02d..4a6b2bbbcc7e04b938d6c462c8401737907d021f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: graphstatsr Title: graphstatsr -Version: 2.0.0 +Version: 2.1.0 Authors@R: person("Etienne", "Rifa", , "etienne.rifa@insa-toulouse.fr", role = c("cre", "aut")) Description: A shiny app to easily generate advanced graphics and some non diff --git a/R/app_ui.R b/R/app_ui.R index 81e25992461fb0d0d88e26400b5a343611e08b3f..644d2f94967db0bcf4f7f4e61c9d67602d26bb75 100644 --- a/R/app_ui.R +++ b/R/app_ui.R @@ -19,7 +19,7 @@ app_ui <- function(request) { # ) dashboardPage(skin = "red", dashboardHeader( - title = "GraphStatsR 2.0.0", + title = "GraphStatsR 2.1.0", tags$li(class="dropdown",tags$a("Hosted by", img(src = SK8img, title = "SK8", height = "20px"), headerText = "Source code",href="https://sk8.inrae.fr/", target="_blank")), diff --git a/R/mod_boxplots.R b/R/mod_boxplots.R index 439bd904147336b125501b79939909c190b85c32..57a017add18413503ed6ae7399c479b170909156 100644 --- a/R/mod_boxplots.R +++ b/R/mod_boxplots.R @@ -611,7 +611,14 @@ mod_boxplots_server <- function(id, r = r, session = session){ print("WRITE PLOTS") systim <- as.numeric(Sys.time()) print(glue::glue("{tmpdir}/figures_pngs/")) - dir.create(glue::glue("{tmpdir}/figures_ggplot/figures_{systim}"), recursive = TRUE) + + if(length(input$outtype)>1){ + for (i in input$outtype){ + dir.create(glue::glue("{tmpdir}/figures_jpgs_{systim}/{i}/"), recursive = TRUE) + } + }else{ + dir.create(glue::glue("{tmpdir}/figures_jpgs_{systim}/"), recursive = TRUE) + } if(input$ggstatOUT){ req(pdfall_ggstat()) @@ -627,13 +634,44 @@ mod_boxplots_server <- function(id, r = r, session = session){ withProgress({ for(i in 1:length(FEAT)){ incProgress(1/length(FEAT)) - tt <- stringr::str_split(FEAT[i], "__") - ggsave(glue::glue("{tmpdir}/figures_ggplot/figures_{systim}/{sapply(tt,'[[',2)}_boxplot_{sapply(tt,'[[',1)}.{input$ImgFormat}"), listP[[FEAT[i]]], width = 20, height = 15, units = "cm", device = input$ImgFormat) + # tt <- stringr::str_split(FEAT[i], "__") + met1 <- stringr::str_split_1(FEAT[i], "__")[1] %>% stringr::str_replace("/", "_") + typ1 <- stringr::str_split_1(FEAT[i], "__")[2] %>% stringr::str_replace("/", "_") + + if(length(input$outtype)>1){ + path1 <- glue::glue("{tmpdir}/figures_jpgs_{systim}/{typ1}/") + }else{ + path1 <- glue::glue("{tmpdir}/figures_jpgs_{systim}") + } + + # ggsave(glue::glue("{tmpdir}/figures_ggplot/figures_{systim}/{sapply(tt,'[[',2)}_boxplot_{sapply(tt,'[[',1)}.{input$ImgFormat}"), listP[[FEAT[i]]], width = 20, height = 15, units = "cm", device = input$ImgFormat) + ggsave(glue::glue("{path1}/{met1}.{input$ImgFormat}"), listP[[FEAT[i]]], width = 20, height = 15, units = "cm", device = input$ImgFormat) } }, value = 0, message = "Generating Images...") - tar(filename, files = glue::glue("{tmpdir}/figures_ggplot/figures_{systim}") ) + # tar(filename, files = glue::glue("{tmpdir}/figures_ggplot/figures_{systim}") ) + + if(length(input$outtype) > 1){ + + for (i in input$outtype){ + tar(glue::glue("{tmpdir}/figures_jpgs_{systim}/{i}.tar"), files = glue::glue("{tmpdir}/figures_jpgs_{systim}/{i}")) + tar(glue::glue("{tmpdir}/figures_jpgs_{systim}/{i}.tar"), files = glue::glue("{tmpdir}/figures_jpgs_{systim}/{i}")) + tar(glue::glue("{tmpdir}/figures_jpgs_{systim}/{i}.tar"), files = glue::glue("{tmpdir}/figures_jpgs_{systim}/{i}")) + } + + print("TAR2") + # browser() + files <- dir(glue::glue("{tmpdir}/figures_jpgs_{systim}/")) + outfiles <- files[stringr::str_detect(files, ".tar")] + + print(outfiles) + + tar(filename, files = glue::glue("{tmpdir}/figures_jpgs_{systim}/{outfiles}")) #glue::glue("{tmpdir}/figures_jpgs_{systim}/") + + }else{ + tar(filename, files = glue::glue("{tmpdir}/figures_jpgs_{systim}/")) + } file.copy(filename, file) @@ -815,11 +853,21 @@ mod_boxplots_server <- function(id, r = r, session = session){ content <- function(file) { print("WRITE PLOTS") systim <- as.numeric(Sys.time()) - print(glue::glue("{tmpdir}/figures_jpgs/figures_{systim}")) - dir.create(glue::glue("{tmpdir}/figures_jpgs/figures_{systim}"), recursive = TRUE) + print(glue::glue("{tmpdir}/figures_jpgs_{systim}")) + + if(length(input$outtype)>1){ + for (i in input$outtype){ + dir.create(glue::glue("{tmpdir}/figures_jpgs_{systim}/{i}/"), recursive = TRUE) + } + }else{ + dir.create(glue::glue("{tmpdir}/figures_jpgs_{systim}/"), recursive = TRUE) + } req(r_values$tabF_melt2,r_values$fact3ok) - tabF_melt2 <- r_values$tabF_melt2 + tabF_melt1 <- r_values$tabF_melt2 + tabF_melt2 <- r_values$tabF_melt2 %>% + separate(features, sep = "__", into = c("feat","type","unit"), remove =FALSE) %>% + filter(type %in% input$outtype) print(input$ymin); print(input$ymax); print(input$steps) @@ -870,8 +918,26 @@ mod_boxplots_server <- function(id, r = r, session = session){ met1 <- stringr::str_split_1(feat1, "__")[1] %>% stringr::str_replace("/", "_") typ1 <- stringr::str_split_1(feat1, "__")[2] %>% stringr::str_replace("/", "_") - jpeg(glue::glue("{tmpdir}/figures_jpgs/figures_{systim}/{typ1}_boxplot_{met1}.jpeg"), - width = 1422, height = 800, quality = 100, res = 150) + + if(length(input$outtype)>1){ + path1 <- glue::glue("{tmpdir}/figures_jpgs_{systim}/{typ1}/") + }else{ + path1 <- glue::glue("{tmpdir}/figures_jpgs_{systim}") + } + + + if(input$ImgFormat == "jpeg"){ + jpeg(glue::glue("{path1}/{met1}.jpeg"), width = 1422, height = 800, quality = 100, res = 150) + }else if(input$ImgFormat == "png"){ + png(glue::glue("{path1}/{met1}.png"), width = 1422, height = 800, res = 150) + }else if(input$ImgFormat == "tiff"){ + tiff(glue::glue("{path1}/{met1}.tiff"), width = 1422, height = 800, res = 150) + }else if(input$ImgFormat == "bmp"){ + bmp(glue::glue("{path1}/{met1}.bmp"), width = 1422, height = 800, res = 150) + }else{ + jpeg(glue::glue("{path1}/{met1}.jpeg"), width = 1422, height = 800, quality = 100, res = 150) + } + # Y custom @@ -940,10 +1006,29 @@ mod_boxplots_server <- function(id, r = r, session = session){ grid() dev.off() } - # save(list = ls(all.names = TRUE), file = "debug.rdata", envir = environment()); print("SAVE0") - tar(filename, files = glue::glue("{tmpdir}/figures_jpgs/figures_{systim}") ) + if(length(input$outtype) > 1){ + + for (i in input$outtype){ + tar(glue::glue("{tmpdir}/figures_jpgs_{systim}/{i}.tar"), files = glue::glue("{tmpdir}/figures_jpgs_{systim}/{i}")) + tar(glue::glue("{tmpdir}/figures_jpgs_{systim}/{i}.tar"), files = glue::glue("{tmpdir}/figures_jpgs_{systim}/{i}")) + tar(glue::glue("{tmpdir}/figures_jpgs_{systim}/{i}.tar"), files = glue::glue("{tmpdir}/figures_jpgs_{systim}/{i}")) + } + + print("TAR2") + # browser() + files <- dir(glue::glue("{tmpdir}/figures_jpgs_{systim}/")) + outfiles <- files[stringr::str_detect(files, ".tar")] + + print(outfiles) + + tar(filename, files = glue::glue("{tmpdir}/figures_jpgs_{systim}/{outfiles}")) #glue::glue("{tmpdir}/figures_jpgs_{systim}/") + + }else{ + tar(filename, files = glue::glue("{tmpdir}/figures_jpgs_{systim}/")) + } + file.copy(filename, file) diff --git a/R/mod_plots_isot.R b/R/mod_plots_isot.R index 816f63a8e1836f2e4eb6bffcec738de4ed93e969..9bbd9a7630c0793404ecceb2b2457bf70ee730ac 100644 --- a/R/mod_plots_isot.R +++ b/R/mod_plots_isot.R @@ -278,7 +278,7 @@ mod_plots_isot_server <- function(id, r = r, session = session){ p3_bar <- p3_bar_group <- ggplot(tabhisto2, aes(x = get(input$group1), y = MeanGroupEnrC13)) + geom_bar(stat="identity", color="black", fill = "#b6bced", position=position_dodge()) + - theme_bw() + ylab("Mean EnrC13") + + theme_bw() + ylab("Mean EnrC13") + xlab(input$group1) + theme(legend.position = "None", axis.text.x = element_text( angle = 45, hjust=1)) + @@ -289,7 +289,7 @@ mod_plots_isot_server <- function(id, r = r, session = session){ p4_bar <- p4_bar_group <- ggplot(tabhisto2, aes(x = get(input$group1), y = MeanGroupArea)) + geom_bar(stat="identity", color="black", fill = "#b6bced", position=position_dodge()) + - theme_bw() + ylab("Mean TotalArea") + + theme_bw() + ylab("Mean TotalArea") + xlab(input$group1) + theme(legend.position = "None", axis.text.x = element_text( angle = 45, hjust=1)) + @@ -602,7 +602,7 @@ mod_plots_isot_server <- function(id, r = r, session = session){ LL[[glue::glue("{i}_enrC13")]] <- p3_bar_group <- ggplot(tabhisto2, aes(x = get(input$group1), y = MeanGroupEnrC13)) + geom_bar(stat="identity", color="black", fill = "#b6bced", position=position_dodge()) + - theme_bw() + ylab("Mean EnrC13") + + theme_bw() + ylab("Mean EnrC13") + xlab("") + theme(legend.position = "None", axis.text.x = element_text( angle = 45, hjust=1)) + @@ -613,7 +613,7 @@ mod_plots_isot_server <- function(id, r = r, session = session){ LL[[glue::glue("{i}_area")]] <- p4_bar_group <- ggplot(tabhisto2, aes(x = get(input$group1), y = MeanGroupArea)) + geom_bar(stat="identity", color="black", fill = "#b6bced", position=position_dodge()) + - theme_bw() + ylab("Mean TotalArea") + + theme_bw() + ylab("Mean TotalArea") + xlab("") + theme(legend.position = "None", axis.text.x = element_text( angle = 45, hjust=1)) +