From f05628959c02148239e3abba63fbb0baf02bcaff Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Fri, 17 Mar 2023 16:36:46 +0100 Subject: [PATCH 1/9] improve rShiny app --- README.md | 3 +- oligopeptides_matching/app.R | 97 +-------------------------------- oligopeptides_matching/data.R | 29 ++++++++++ oligopeptides_matching/server.R | 40 ++++++++++++++ oligopeptides_matching/ui.R | 44 +++++++++++++++ 5 files changed, 116 insertions(+), 97 deletions(-) create mode 100644 oligopeptides_matching/data.R create mode 100644 oligopeptides_matching/server.R create mode 100644 oligopeptides_matching/ui.R diff --git a/README.md b/README.md index 12e7eeb..06753ed 100644 --- a/README.md +++ b/README.md @@ -109,12 +109,11 @@ install.packages("shiny") install.packages("DT") library(shiny) -library(DT) library(devtools) library(roxygen2) document() -runApp("exampleOligopeptidesMatching_aa") +runApp("oligopeptides_matching") ``` ### Examples diff --git a/oligopeptides_matching/app.R b/oligopeptides_matching/app.R index 03f9a5b..c28aa4e 100644 --- a/oligopeptides_matching/app.R +++ b/oligopeptides_matching/app.R @@ -1,99 +1,6 @@ library(shiny) -library(DT) -# Constants -### Amino acids -aa <- c("A", "C", "D", "E", "F", "G", "H", "I", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "Y") - -### amino acids molecular weight -mass_aa <- c(89.047679, 121.019751, 133.037509, 147.053159, 165.078979, - 75.032029, 155.069477, 131.094629, 146.105528, 131.094629, - 149.051051,132.053493, 115.063329, 146.069143, 174.111676, - 105.042594,119.058244, 117.078979,204.089878, 181.073894) - -aa_mw <- setNames(mass_aa, aa) - -### Polyphenols -polyphenol <- c("Cyanidin", - "Cyanidin 3,5-O-diglucoside", - "Cyanidin 3-O-(6''-acetyl-galactoside)", - "Cyanidin 3-O-(6''-acetyl-glucoside)", - "Cyanidin 3-O-(6''-caffeoyl-glucoside)") - -### polyphenol molecular weight -mass_polyphenol <- c(287.244, 611.525,491.422, 491.422, 611.527) - -pp_mw <- setNames(mass_polyphenol, polyphenol) - -### reaction elements -H2O <- 18.010565 -H <- 1.007825 - -ionization_list = stats::setNames(c(H),c("H")) - - -# See above for the definitions of ui and server -ui <- fluidPage( - - # App title ---- - titlePanel("Oligopeptides Matching"), - - # Sidebar layout with a input and output definitions ---- - sidebarLayout( - - # Sidebar panel for inputs ---- - sidebarPanel( - - # Input: Numeric entry for number of obs to view ---- - numericInput(inputId = "od", - label = "Oligomerization degree:", - value = 3), - numericInput(inputId = "mz_obs", - label = "M/z observed :", - value = 953.669), - numericInput(inputId = "ppm_error", - label = "Tolerance:", - value = 10) - ), - # Main panel for displaying outputs ---- - mainPanel( - h3("Oligopeptides"), - # Output: HTML table with requested number of observations ---- - DT::dataTableOutput("view") - ) - ) -) - -server <- function(input, output) { - - - - output$view <- DT::renderDataTable( - {aa_combined <- get_oligopeptides( - aminoacids = aa_mw, - chemical_reaction = H2O, - ionization = ionization_list, - oligomerization_degree = input$od) - - aa_combined_names <- c(aa_combined$id) - aa_combined_mass <- c(aa_combined$MW) - aa_combined_mw <- setNames(aa_combined_mass, aa_combined_names) - - combined_compounds <- get_combination_compounds( - compounds_1 = aa_combined_mw, - compounds_2 = pp_mw, - chemical_reaction = H2O, - ionization = setNames(c(H), c("H"))) - mz_obs <- 953.669 - combined_compounds_near_obs <- - match_mz_obs(input$mz_obs, combined_compounds, - ppm_error = input$ppm_error) - - return(combined_compounds_near_obs) - } - - ) - -} +source(server.R) +source(ui.R) shinyApp(ui = ui, server = server) \ No newline at end of file diff --git a/oligopeptides_matching/data.R b/oligopeptides_matching/data.R new file mode 100644 index 0000000..9150158 --- /dev/null +++ b/oligopeptides_matching/data.R @@ -0,0 +1,29 @@ +# Constants +### Amino acids +aa <- c("A", "C", "D", "E", "F", "G", "H", "I", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "Y") + +### amino acids molecular weight +mass_aa <- c(89.047679, 121.019751, 133.037509, 147.053159, 165.078979, + 75.032029, 155.069477, 131.094629, 146.105528, 131.094629, + 149.051051,132.053493, 115.063329, 146.069143, 174.111676, + 105.042594,119.058244, 117.078979,204.089878, 181.073894) + +aa_mw <- setNames(mass_aa, aa) + +### Polyphenols +polyphenol <- c("Cyanidin", + "Cyanidin 3,5-O-diglucoside", + "Cyanidin 3-O-(6''-acetyl-galactoside)", + "Cyanidin 3-O-(6''-acetyl-glucoside)", + "Cyanidin 3-O-(6''-caffeoyl-glucoside)") + +### polyphenol molecular weight +mass_polyphenol <- c(287.244, 611.525,491.422, 491.422, 611.527) + +pp_mw <- setNames(mass_polyphenol, polyphenol) + +### reaction elements +H2O <- 18.010565 +H <- 1.007825 + +ionization_list = stats::setNames(c(H),c("H")) \ No newline at end of file diff --git a/oligopeptides_matching/server.R b/oligopeptides_matching/server.R new file mode 100644 index 0000000..79ce224 --- /dev/null +++ b/oligopeptides_matching/server.R @@ -0,0 +1,40 @@ +library(DT) + +source("./data.R") + +server <- function(input, output) { + + combination_compounds <- reactive({ + aaa_combined <- get_oligopeptides( + aminoacids = aa_mw, + chemical_reaction = H2O, + ionization = ionization_list, + oligomerization_degree = input$od) + + aa_combined <- as.data.frame(aaa_combined) + aa_combined_names <- c(aa_combined$id) + aa_combined_mass <- c(aa_combined$MW) + aa_combined_mw <- setNames(aa_combined_mass, aa_combined_names) + + return(get_combination_compounds(compounds_1 = aa_combined_mw, + compounds_2 = pp_mw, + chemical_reaction = H2O, + ionization = setNames(c(H),c("H")))) + }) + # ===== + # All arrangement AA with PolyPhenols + output$view_arrangement <- DT::renderDataTable( + combination_compounds() + ) + # ===== + # Filtering on a single Value + + output$view_filter_mz_obs <- DT::renderDataTable( + { + return(match_mz_obs( + input$mz_obs, + combination_compounds(), + ppm_error = input$ppm_error)) + } + ) +} \ No newline at end of file diff --git a/oligopeptides_matching/ui.R b/oligopeptides_matching/ui.R new file mode 100644 index 0000000..32f5d90 --- /dev/null +++ b/oligopeptides_matching/ui.R @@ -0,0 +1,44 @@ +ui <- navbarPage("Oligopeptides Matching", + tabPanel("Combination AA Polyphenol", + + # Sidebar layout with a input and output definitions ---- + sidebarLayout( + + # Sidebar panel for inputs ---- + sidebarPanel( + # Input: Numeric entry for number of obs to view ---- + numericInput(inputId = "od", + label = "Oligomerization degree:", + value = 3) + ), + # Main panel for displaying outputs ---- + mainPanel( + h3("Oligopeptides"), + # Output: HTML table with requested number of observations ---- + DT::dataTableOutput("view_arrangement") + ) + ) +), +tabPanel("Match a single Mz", +# Sidebar layout with a input and output definitions ---- + sidebarLayout( + + # Sidebar panel for inputs ---- + sidebarPanel( + numericInput(inputId = "mz_obs", + label = "M/z observed :", + value = 953.669), + numericInput(inputId = "ppm_error", + label = "Tolerance:", + value = 10) + ), + # Main panel for displaying outputs ---- + mainPanel( + h3("Oligopeptides"), + # Output: HTML table with requested number of observations ---- + DT::dataTableOutput("view_filter_mz_obs") + ) + ) +), +tabPanel("Match a list of Mz") +) \ No newline at end of file From 7ca18a8bb7a2ec97e44ff70b47b7661bae90faff Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Fri, 17 Mar 2023 16:44:11 +0100 Subject: [PATCH 2/9] update --- DESCRIPTION | 2 +- README.md | 3 ++- oligopeptides_matching/server.R | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index ce1e1c6..72e61b9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: oligopeptidesMatching Title: Library of functions for in silico construction and detection of oligopeptides Description: In order to compute from amino acids molecular weight the putative oligomers of various oligomerization degree. -Version: 0.0.1 +Version: 0.0.2 Authors@R: c( person(given = "Kevin", family = "Billet", diff --git a/README.md b/README.md index 06753ed..b2b5587 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # oligopeptides_matching [![p2m2](https://circleci.com/gh/p2m2/oligopeptides_matching.svg?style=shield)](https://app.circleci.com/pipelines/github/p2m2) -[![](https://img.shields.io/badge/Shiny-shinyapps.io-blue?style=flat&labelColor=white&logo=RStudio&logoColor=blue)](https://p2m2.shinyapps.io/oligopeptides_matching/) +[![](https://img.shields.io/badge/Shiny_Stable-shinyapps.io-blue?style=flat&labelColor=white&logo=RStudio&logoColor=blue)](https://p2m2.shinyapps.io/oligopeptides_matching/) +[![](https://img.shields.io/badge/Shiny_Devel-shinyapps.io-blue?style=flat&labelColor=white&logo=RStudio&logoColor=blue)](https://p2m2.shinyapps.io/oligopeptides_matching-develop/) In order to compute from amino acids molecular weight the putative oligomers of various oligomerization degree diff --git a/oligopeptides_matching/server.R b/oligopeptides_matching/server.R index 79ce224..f76007d 100644 --- a/oligopeptides_matching/server.R +++ b/oligopeptides_matching/server.R @@ -1,3 +1,4 @@ +library(shiny) library(DT) source("./data.R") From 7d66f99794c165960354fd63808e9b25bbe742b9 Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Mon, 20 Mar 2023 12:34:52 +0100 Subject: [PATCH 3/9] fix shiny io publish package that don't support a local install --- .circleci/config.yml | 6 ++---- oligopeptides_matching/server.R | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8771730..4374a34 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,9 +26,6 @@ workflows: filters: tags: only: /.*/ - branches: - only: - - develop jobs: build: working_directory: ~/tmp @@ -96,5 +93,6 @@ jobs: - run: name: deployment on https://www.shinyapps.io/ command: | - [ -z "${CIRCLE_TAG}" ] && export APP_NAME="${CIRCLE_PROJECT_REPONAME}-${CIRCLE_BRANCH}" || export APP_NAME="${CIRCLE_PROJECT_REPONAME}" + # publish only tag release + export APP_NAME="${CIRCLE_PROJECT_REPONAME}" ./publish_rshinyapp.sh diff --git a/oligopeptides_matching/server.R b/oligopeptides_matching/server.R index f76007d..8d23d4e 100644 --- a/oligopeptides_matching/server.R +++ b/oligopeptides_matching/server.R @@ -1,6 +1,8 @@ library(shiny) library(DT) +devtools::install_github("p2m2/oligopeptides_matching") + source("./data.R") server <- function(input, output) { From 4432c96439499d1204fc98d33ecbe84c91c7363b Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Mon, 20 Mar 2023 13:23:33 +0100 Subject: [PATCH 4/9] update badge --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index b2b5587..2cda07b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ # oligopeptides_matching [![p2m2](https://circleci.com/gh/p2m2/oligopeptides_matching.svg?style=shield)](https://app.circleci.com/pipelines/github/p2m2) -[![](https://img.shields.io/badge/Shiny_Stable-shinyapps.io-blue?style=flat&labelColor=white&logo=RStudio&logoColor=blue)](https://p2m2.shinyapps.io/oligopeptides_matching/) -[![](https://img.shields.io/badge/Shiny_Devel-shinyapps.io-blue?style=flat&labelColor=white&logo=RStudio&logoColor=blue)](https://p2m2.shinyapps.io/oligopeptides_matching-develop/) +[![](https://img.shields.io/badge/stable-shinyapps.io-blue?style=flat&labelColor=white&logo=RStudio&logoColor=blue)](https://p2m2.shinyapps.io/oligopeptides_matching/) In order to compute from amino acids molecular weight the putative oligomers of various oligomerization degree From 21e503b6d40f66d3e822daa1691bb76fd8eeacdc Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Mon, 20 Mar 2023 13:25:04 +0100 Subject: [PATCH 5/9] test deployment rshiny --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4374a34..cc2bb01 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,6 +26,9 @@ workflows: filters: tags: only: /.*/ + branches: + only: + - develop jobs: build: working_directory: ~/tmp From 83349a8ad879b5957ad7bc681e5d4eca800bb209 Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Mon, 20 Mar 2023 16:33:19 +0100 Subject: [PATCH 6/9] fix publishing rshiny app --- oligopeptides_matching/server.R | 3 +-- publish_rshinyapp.sh | 13 ++++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/oligopeptides_matching/server.R b/oligopeptides_matching/server.R index 8d23d4e..b644797 100644 --- a/oligopeptides_matching/server.R +++ b/oligopeptides_matching/server.R @@ -1,7 +1,6 @@ library(shiny) library(DT) - -devtools::install_github("p2m2/oligopeptides_matching") +library(oligopeptidesMatching) source("./data.R") diff --git a/publish_rshinyapp.sh b/publish_rshinyapp.sh index 5bf70ed..a98dd34 100755 --- a/publish_rshinyapp.sh +++ b/publish_rshinyapp.sh @@ -2,10 +2,10 @@ install.packages('rsconnect') -library(devtools) -library(roxygen2) -document() -install() +#library(devtools) +#library(roxygen2) +#document() +#install() library(rsconnect) @@ -32,7 +32,6 @@ if ( nchar(APP_NAME)<=0 ) { install.packages("shiny") install.packages("DT") -library(shiny) -library(DT) +devtools::install_github("p2m2/oligopeptides_matching") -rsconnect::deployApp('oligopeptides_matching',appName=APP_NAME,forceUpdate = TRUE) \ No newline at end of file +rsconnect::deployApp('oligopeptides_matching',appName=APP_NAME,forceUpdate = TRUE) From 9258d5509f2cda46be8795a219a41dffc4c4d238 Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Mon, 20 Mar 2023 16:33:46 +0100 Subject: [PATCH 7/9] fix publishing rshiny app --- .circleci/config.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index cc2bb01..57d3bd4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,9 +26,7 @@ workflows: filters: tags: only: /.*/ - branches: - only: - - develop + jobs: build: working_directory: ~/tmp From b878a969693beb083b6ca8e9808d3927e035db6c Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Mon, 20 Mar 2023 17:07:14 +0100 Subject: [PATCH 8/9] fix github token --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 57d3bd4..fee4d6a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -96,4 +96,5 @@ jobs: command: | # publish only tag release export APP_NAME="${CIRCLE_PROJECT_REPONAME}" + export GITHUB_PAT=${GITHUB_TOKEN} ./publish_rshinyapp.sh From 1982f67c4592aa39e96b8300f0c1e291339c870f Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Mon, 20 Mar 2023 17:07:39 +0100 Subject: [PATCH 9/9] fix github token --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index fee4d6a..8c5748d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,6 +22,7 @@ workflows: - build context: - DOCKER_CONTEXT + - GITHUB_CONTEXT - SHINYAPP_CONTEXT filters: tags: