From 06bc9b011027cd636c986c305ee9791a4e6368cd Mon Sep 17 00:00:00 2001 From: weaversd Date: Thu, 13 Feb 2025 11:40:55 -0500 Subject: [PATCH 1/2] Added PTMs to list --- ui.R | 10 ++++++++-- www/basic_functions.R | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ui.R b/ui.R index f4fcc25..ebfb432 100644 --- a/ui.R +++ b/ui.R @@ -78,14 +78,20 @@ ui <- navbarPage(title = "PrIntMap-R", "Oxidation" , "Pyro_glu_from_E" , "Pyro_glu_from_Q", - "Sodium_adduct" + "Sodium_adduct", + "Acetylation", + "iTRAQ 4-plex", + "TMT 10-plex" ), choiceValues = c("(+57.02)", "(+0.98)", "(+15.99)", "(-18.01)", "(-17.03)", - "(+21.98)" + "(+21.98)", + "(+42.0106)", + "(+229.1629)", + "(+144.1021)" )), "Select one or more PTMs to annotate"), checkboxInput(inputId = "custom_PTM_check", label = "CUSTOM", value = F), diff --git a/www/basic_functions.R b/www/basic_functions.R index cd3cb87..36614ff 100644 --- a/www/basic_functions.R +++ b/www/basic_functions.R @@ -706,18 +706,22 @@ create_peptide_origin_vec <- function(peptide_df, vector_list <- list() for (i in 1:nrow(peptide_df)) { peptide <- peptide_df$sequence[i] + modpeptide <- peptide_df$Peptide[i] intensity_value <- peptide_df[[intensity]][i] matches_df <- str_locate_all(protein, peptide)[[1]] matches_count <- nrow(matches_df) origin_vector <- rep("", nchar(protein)) + mod_origin_vector <- rep("", nchar(protein)) if (matches_count > 0) { for (j in 1:matches_count) { start <- matches_df[[j,1]] end <- matches_df[[j,2]] origin_vector[start:end] <- paste0(peptide, "|") + mod_origin_vector[start:end] <- paste0(modpeptide, "|") } } vector_list[[i]] <- origin_vector + vector_list[[i]] <- mod_origin_vector } origin_df <- as.data.frame(sapply(vector_list, unlist)) origin_vec <- apply(origin_df, 1, paste, collapse="") From f599ee133b79b70b3f6a105c0573ecb15cdae358 Mon Sep 17 00:00:00 2001 From: weaversd Date: Thu, 13 Feb 2025 12:02:40 -0500 Subject: [PATCH 2/2] allow for custom PTM upload --- server.R | 24 ++++++++++++++++++++++++ ui.R | 33 +++++++++------------------------ www/ptm_list.csv | 10 ++++++++++ 3 files changed, 43 insertions(+), 24 deletions(-) create mode 100644 www/ptm_list.csv diff --git a/server.R b/server.R index f441f82..b627c74 100644 --- a/server.R +++ b/server.R @@ -7,6 +7,30 @@ options(shiny.maxRequestSize=100*1024^2) server <- function(input, output, session) { + + ptm_data <- reactive({ + # Check if user uploaded a file + if (!is.null(input$custom_ptm_file)) { + file_path <- input$custom_ptm_file$datapath # Path of uploaded file + } else { + file_path <- "www/ptm_list.csv" # Default file + } + + # Read CSV and return as dataframe + read.csv(file_path, stringsAsFactors = FALSE) + }) + + # Render dynamic UI based on the selected PTM file + output$ptm_selection <- renderUI({ + tipify( + checkboxGroupInput(inputId = "PTM", + label = "PTMs", + choiceNames = ptm_data()$Choice, # Display names from CSV + choiceValues = ptm_data()$Value # Corresponding values + ), "Select one or more PTMs to annotate" + ) + }) + database <- reactive({ validate( need(!is.null(input$database_file), "No Database File Provided") diff --git a/ui.R b/ui.R index ebfb432..11eb80d 100644 --- a/ui.R +++ b/ui.R @@ -71,32 +71,17 @@ ui <- navbarPage(title = "PrIntMap-R", fluidRow( checkboxInput(inputId = "displayPTMs", label = "Display PTMs"), - tipify(checkboxGroupInput(inputId = "PTM", - label = "PTMs", - choiceNames = c("Carbamidomethylation", - "Deamidation", - "Oxidation" , - "Pyro_glu_from_E" , - "Pyro_glu_from_Q", - "Sodium_adduct", - "Acetylation", - "iTRAQ 4-plex", - "TMT 10-plex" - ), - choiceValues = c("(+57.02)", - "(+0.98)", - "(+15.99)", - "(-18.01)", - "(-17.03)", - "(+21.98)", - "(+42.0106)", - "(+229.1629)", - "(+144.1021)" - )), "Select one or more PTMs to annotate"), + fileInput(inputId = "custom_ptm_file", + label = "Upload Custom PTM CSV", + accept = c(".csv")), + uiOutput("ptm_selection"), # Dynamically generated UI checkboxInput(inputId = "custom_PTM_check", - label = "CUSTOM", value = F), + label = "CUSTOM", value = FALSE), tipify(textInput(inputId = "custom_PTM", - label = "Custom PTM"), "Enter a custom PTM (CUSTOM checkbox must be selected. Enter the PTM as a string as it is seen in the peptide column of your sample input."),)) + label = "Custom PTM"), + "Enter a custom PTM (CUSTOM checkbox must be selected. Enter the PTM as a string as it is seen in the peptide column of your sample input."), + ) + ) ), tipify(checkboxInput(inputId = "disp_origin", label = "Display Origin Peptides", diff --git a/www/ptm_list.csv b/www/ptm_list.csv new file mode 100644 index 0000000..d6eb459 --- /dev/null +++ b/www/ptm_list.csv @@ -0,0 +1,10 @@ +Choice,Value +Carbamidomethylation,(+57.02) +Deamidation,(+0.98) +Oxidation,(+15.99) +Pyro_glu_from_E,(-18.01) +Pyro_glu_from_Q,(-17.03) +Sodium_adduct,(+21.98) +Acetylation,(+42.0106) +iTRAQ 4-plex,(+229.1629) +TMT 10-plex,(+144.1021)