Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
27 changes: 9 additions & 18 deletions ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +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"
),
choiceValues = c("(+57.02)",
"(+0.98)",
"(+15.99)",
"(-18.01)",
"(-17.03)",
"(+21.98)"
)), "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",
Expand Down
4 changes: 4 additions & 0 deletions www/basic_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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="")
Expand Down
10 changes: 10 additions & 0 deletions www/ptm_list.csv
Original file line number Diff line number Diff line change
@@ -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)