Skip to content

Commit

Permalink
Merge pull request #72 from duocang/modulization
Browse files Browse the repository at this point in the history
deploy PMET-shiny-app with docker
  • Loading branch information
duocang authored May 27, 2024
2 parents 9d3e678 + fa41c0f commit cc533d4
Show file tree
Hide file tree
Showing 34 changed files with 1,776 additions and 226 deletions.
19 changes: 19 additions & 0 deletions 01_deploy_via_Docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

source scripts/colored_print.sh
source scripts/check_and_set_email_credentials.sh
source scripts/check_CPU_number.sh
set -e

#################### 1 email
print_green "1. Configurations of email to send results"
check_and_set_email_credentials

#################### 2. CPU
print_green "2. Configuration of CPU number"
check_cpu_number

#################### 3. Docker build
print_green "3. Docker building"
chmod 777 logs result
docker-compose up -d
File renamed without changes.
46 changes: 46 additions & 0 deletions R/R_packages_installation.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[1] TRUE
[1] TRUE
[1] TRUE
character(0)

The installed packages are as follows:
[1] "av" "bslib"
[3] "daattali/shinycssloaders" "daattali/shinydisconnect"
[5] "data.table" "datawookie/emayili"
[7] "devtools" "dplyr"
[9] "dreamRs/shinybusy" "dreamRs/shinyWidgets"
[11] "DT" "emayili"
[13] "enrichplot" "future"
[15] "gapminder" "ggasym"
[17] "ggplot2" "ggpubr"
[19] "glue" "Hmisc"
[21] "httpuv" "jhrcook/ggasym"
[23] "kableExtra" "magick"
[25] "merlinoa/shinyFeedback" "msigdbr"
[27] "openxlsx" "pak"
[29] "pdftools" "plotly"
[31] "promises" "pryr"
[33] "qpdf" "r-lib/ragg"
[35] "r-lib/rlang" "r-lib/systemfonts"
[37] "r-lib/textshaping" "r-lib/usethis"
[39] "r-rust/gifski" "ragg"
[41] "RcppRoll" "reshape2"
[43] "RinteRface/fullPage" "rintrojs"
[45] "rJava" "rlang"
[47] "rstudio/httpuv" "rsvg"
[49] "rtracklayer" "scales"
[51] "seqinr" "shiny"
[53] "shinyBS" "shinybusy"
[55] "shinycssloaders" "shinydashboard"
[57] "shinydisconnect" "shinyFeedback"
[59] "shinyjs" "shinythemes"
[61] "shinyvalidate" "shinyWidgets"
[63] "stringr" "svglite"
[65] "systemfonts" "tesseract"
[67] "textshaping" "tibble"
[69] "tictoc" "tidyverse"
[71] "usethis" "xfun"
[73] "xlsxjars" "zip"

The following packages could not be installed:
[1] "pander"
3 changes: 3 additions & 0 deletions R/app.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Sys.setenv(R_LIBS_USER = "/usr/local/lib/R/library")
.libPaths(new = "/usr/local/lib/R/library")

source("R/global.R")

ui <- fluidPage(
Expand Down
204 changes: 144 additions & 60 deletions R/global.R
Original file line number Diff line number Diff line change
@@ -1,52 +1,102 @@
Sys.setenv(R_LIBS_USER = "/usr/local/lib/R/library")
.libPaths(new = "/usr/local/lib/R/library")

options(shiny.maxRequestSize = 30000 * 1024^2)

suppressMessages({
# Used packages
pacotes <- c(
"bslib", # customizing the appearance of Shiny applications using Bootstrap.
"data.table", # fast data manipulation and analysis.
"DT", # creating interactive and customizable data tables in R.
"dplyr", # data manipulation and transformation using a consistent grammar.
"fullPage", # creating full-page scrolling websites.
"future",
"ggasym", # creating asymmetric visualizations with ggplot2.
"ggpubr", # enhancing ggplot2 visualizations with publication-ready themes and annotations.
"glue", # interpolating strings and expressions in R.
"jsonify",
"kableExtra", # creating complex tables in R Markdown documents.
"openxlsx", # reading, writing, and manipulating Microsoft Excel files.
"promises", # creating and managing asynchronous programming in R.
"purrr", # functional programming and iterating over data structures.
"reshape2", # transforming and restructuring data in R.
"rintrojs", # creating interactive and guided tours in Shiny applications.
"rjson", # converts R object into JSON objects and vice-versa.
"rtracklayer", # read gff3
"scales", # controlling the scaling of data in R graphics.
"seqinr", # extract fasta's name
"shiny", # building interactive web applications in R.
"shinyBS", # adding additional Bootstrap functionality to Shiny applications.
"shinybusy", # Automated (or not) busy indicator for Shiny apps & other progress / notifications tools
"shinydashboard", # creating dashboards with a tabbed layout in Shiny.
"shinydisconnect", # handling disconnections and reconnections in Shiny applications.
"shinyFeedback", # providing user feedback and notifications in Shiny applications.
"shinycssloaders", # adding CSS loaders to Shiny applications.
"shinyjs", # easily incorporating JavaScript functions and events in Shiny applications.
"shinythemes", # customizing the appearance of Shiny applications with predefined themes.
"shinyvalidate", # client-side form validation in Shiny applications.
"shinyWidgets", # creating custom UI controls and widgets in Shiny.
"snow", # parallel computing using a simple network of workstations.
"tibble", # creating and manipulating data frames with enhanced features compared to traditional data frames.
"tidyverse", # data manipulation, visualization, and analysis.
"tictoc", # measuring the time taken by R code execution.
"shinyvalidate", # shinyvalidate adds input validation capabilities to Shiny.
"zip" # reading, writing, and manipulating ZIP archives in R.
)

# verify required packages installed or not. If some package
# is missing, it will be installed automatically
package.check <- lapply(pacotes, FUN = function(x) {
if (!require(x, character.only = TRUE)) {
install.packages(x, dependencies = TRUE)
}
})
# # Used packages
# pacotes <- c(
# "emayili",
# "bslib", # customizing the appearance of Shiny applications using Bootstrap.
# "data.table", # fast data manipulation and analysis.
# "DT", # creating interactive and customizable data tables in R.
# "dplyr", # data manipulation and transformation using a consistent grammar.
# "fullPage", # creating full-page scrolling websites.
# "future",
# "ggasym", # creating asymmetric visualizations with ggplot2.
# "ggpubr", # enhancing ggplot2 visualizations with publication-ready themes and annotations.
# "glue", # interpolating strings and expressions in R.
# "kableExtra", # creating complex tables in R Markdown documents.
# "openxlsx", # reading, writing, and manipulating Microsoft Excel files.
# "promises", # creating and managing asynchronous programming in R.
# "purrr", # functional programming and iterating over data structures.
# "reshape2", # transforming and restructuring data in R.
# "rintrojs", # creating interactive and guided tours in Shiny applications.
# "rjson", # converts R object into JSON objects and vice-versa.
# "rtracklayer", # read gff3
# "scales", # controlling the scaling of data in R graphics.
# "seqinr", # extract fasta's name
# "shiny", # building interactive web applications in R.
# "shinyBS", # adding additional Bootstrap functionality to Shiny applications.
# "shinybusy", # Automated (or not) busy indicator for Shiny apps & other progress / notifications tools
# "shinydisconnect", # handling disconnections and reconnections in Shiny applications.
# "shinyFeedback", # providing user feedback and notifications in Shiny applications.
# "shinycssloaders", # adding CSS loaders to Shiny applications.
# "shinyjs", # easily incorporating JavaScript functions and events in Shiny applications.
# "shinythemes", # customizing the appearance of Shiny applications with predefined themes.
# "shinyvalidate", # client-side form validation in Shiny applications.
# "shinyWidgets", # creating custom UI controls and widgets in Shiny.
# "snow", # parallel computing using a simple network of workstations.
# "tibble", # creating and manipulating data frames with enhanced features compared to traditional data frames.
# "tidyverse", # data manipulation, visualization, and analysis.
# "tictoc", # measuring the time taken by R code execution.
# "shinyvalidate", # shinyvalidate adds input validation capabilities to Shiny.
# "zip" # reading, writing, and manipulating ZIP archives in R.
# )

# # # verify required packages installed or not. If some package
# # # is missing, it will be installed automatically
# # package.check <- lapply(pacotes, FUN = function(x) {
# # if (!require(x, character.only = TRUE)) {
# # print(x)
# # install.packages(x, dependencies = TRUE)
# # }
# # })

# # 循环引入包
# lapply(pacotes, function(pkg) {
# requireNamespace(pkg, quietly = TRUE)
# library(pkg, character.only = TRUE)
# })

# 显式地调用packages是因为renv的package管理需要识别library
library(jsonlite)
library(emayili)
library(bslib)
library(data.table)
library(DT)
library(dplyr)
library(fullPage)
library(future)
library(ggasym)
library(ggpubr)
library(glue)
library(kableExtra)
library(openxlsx)
library(promises)
library(purrr)
library(reshape2)
library(rintrojs)
library(rjson)
library(rtracklayer)
library(scales)
library(seqinr)
library(shiny)
library(shinyBS)
library(shinybusy)
library(shinydisconnect)
library(shinyFeedback)
library(shinycssloaders)
library(shinyjs)
library(shinythemes)
library(shinyvalidate)
library(shinyWidgets)
library(snow)
library(tibble)
library(tidyverse)
library(tictoc)
library(shinyvalidate)
library(zip)

source("R/utils/utils.R")
source("R/utils/shiny_busy_indicator.R")
Expand All @@ -66,23 +116,21 @@ suppressMessages({
source("R/utils/motif_pair_gene_diagonal.R")
})

options(shiny.maxRequestSize = 30000 * 1024^2)
plan(multisession)


cpu_configuration <- readLines("data/cpu_configuration.txt")
NCPU <- cpu_configuration[1]
NCPU <- readLines("data/cpu_configuration.txt")[1]

# to detect the pre-computed motif-DB data
# when new daata comes, there is no need to change code.
# auto detect the pre-computed motif-DB data: when new species or motif database comes, no need to change code.
species <- list.dirs("./data/indexing", recursive=F) %>%
sapply(function(i) {
str <- stringr::str_split_1(i, "/")[4] # %>% tolower() #%>% gsub("(^|\\s)([a-z])", "\\1\\U\\2", ., perl = TRUE) # capitablize first letter
return(str)
})
# > species
# ./data/indexing/arabidopsis_thaliana ./data/indexing/mais
# "arabidopsis_thaliana" "mais"
# ./data/indexing/Arabidopsis_thaliana
# "Arabidopsis_thaliana"
# ./data/indexing/Brachypodium_distachyon
# "Brachypodium_distachyon"
# ./data/indexing/Brassica_napus
# "Brassica_napus"

MOTIF_DB <- lapply(species, function(speci) {

Expand All @@ -93,10 +141,24 @@ MOTIF_DB <- lapply(species, function(speci) {
for (i in seq(length(motif_dbs))) {
result[[ list_names[i] ]] <- file.path("data/indexing", speci , motif_dbs[i])
}

return(result)
}) %>% setNames(unname(species))
# > MOTIF_DB
# $Arabidopsis_thaliana
# $Arabidopsis_thaliana$`CIS-BP2`
# [1] "data/indexing/Arabidopsis_thaliana/CIS-BP2"

# $Arabidopsis_thaliana$`Franco-Zorrilla et al 2014`
# [1] "data/indexing/Arabidopsis_thaliana/Franco-Zorrilla_et_al_2014"

# $Arabidopsis_thaliana$`Jaspar plants non redundant 2022`
# [1] "data/indexing/Arabidopsis_thaliana/Jaspar_plants_non_redundant_2022"

# $Arabidopsis_thaliana$`Plant Cistrome DB`
# [1] "data/indexing/Arabidopsis_thaliana/Plant_Cistrome_DB"

# $Arabidopsis_thaliana$PlantTFDB
# [1] "data/indexing/Arabidopsis_thaliana/PlantTFDB"

SPECIES_LIST <- list()

Expand All @@ -105,5 +167,27 @@ for (speci in species) {
SPECIES_LIST[[temp]] <- speci
}
SPECIES_LIST <- list(species = SPECIES_LIST) # to show nothing first of fileInput box
# > SPECIES_LIST
# $species
# $species$`Arabidopsis thaliana`
# [1] "Arabidopsis_thaliana"

# $species$`Brachypodium distachyon`
# [1] "Brachypodium_distachyon"

# $species$`Brassica napus`
# [1] "Brassica_napus"

# $species$`Glycine max`
# [1] "Glycine_max"

MOTF_DB_META <- rjson::fromJSON(file = "data/motif_db_meta.json")
# > MOTF_DB_META
# $Arabidopsis_thaliana
# $Arabidopsis_thaliana$genome_name
# [1] "Arabidopsis_thaliana.TAIR10.dna.toplevel.fa"

# $Arabidopsis_thaliana$annotation_name
# [1] "Arabidopsis_thaliana.TAIR10.56.gff3"

MOTF_DB_META <- fromJSON(file = "data/motif_db_meta.json")
# $Arabidopsis_thaliana$genome_link
1 change: 1 addition & 0 deletions R/server/tab_visualize.R
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,4 @@ observeEvent(pmet.result.processed(), {
})
server_data("pmet_talble_tab", result)
})

27 changes: 27 additions & 0 deletions R/ui/tab_test.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
# tabPanel(
# title = "Test",
# value = "Test_tabpanel",
# tags$head(
# tags$link(rel = "stylesheet", href = "https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/3.1.2/fullpage.min.css"),
# tags$script(src = "https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/3.1.2/fullpage.min.js")
# ),
# tags$script("
# $(document).ready(function() {
# new fullpage('#my-fullpage', {
# // fullPage.js options
# });
# });
# "),
# div(id = "my-fullpage",
# div(class = "section",
# actionButton("a", "a"),
# h1("Section 1")
# ),
# div(class = "section",
# h1("Section 2")
# ),
# div(class = "section",
# h1("Section 3")
# )
# )
# )
tabPanel(
class = "tabPanel_shiny",
"My Tab",
Expand Down
Loading

0 comments on commit cc533d4

Please sign in to comment.