Skip to content

Commit

Permalink
Merge pull request #13 from weaversd/VolcanoErrorHandling
Browse files Browse the repository at this point in the history
v0.1.12
  • Loading branch information
weaversd authored Mar 10, 2023
2 parents f23d77b + 3a2b4fa commit 0ca06bc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 47 deletions.
7 changes: 6 additions & 1 deletion Documentation/Release Updates.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ Version 0.1.10

Version 0.1.11
2022-11-22
- Added annotation option to display amino acid sequence along the x-axis.
- Added annotation option to display amino acid sequence along the x-axis.

Version 0.1.12
2023-03-10
- Fixed bug that displayed peptide multiple times on volcano plot
- Fixed PEAKS import bug
4 changes: 1 addition & 3 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ server <- function(input, output, session) {


output$plot_intensity1 <- renderPlotly({
print(intensity_vec1())
validate(
need(nrow(peptides1()) > 0, "Invalid peptide file. Check format.")
)
Expand Down Expand Up @@ -1157,9 +1158,6 @@ PTM_regex_length <- reactive(length(PTM_regex()))
equal_variance_bool = input$equal_var,
remove_na = input$remove_na,
set_na = input$set_na_value)
print(str(df))
print("^^^DF within server")
browser()
return(df)
})

Expand Down
2 changes: 1 addition & 1 deletion ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ library(shiny)
ui <- navbarPage(title = "PrIntMap-R",
tabPanel("Documentation",
includeMarkdown("Documentation/Documentation.md"),
"Version 0.1.11"), #update version here for each push
"Version 0.1.12"), #update version here for each push
tabPanel("Run",
flowLayout(
fileInput(inputId = "database_file", label = "Upload fasta database file",
Expand Down
56 changes: 14 additions & 42 deletions www/Volcano_plot_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,36 +115,7 @@ read_peptide_tsv_Metamorpheus_volcano <- function(peptide_file, sample_pattern,
peptides <- read.csv(peptide_file, sep = "\t", header = T)
filetype(peptides, "Combined", "Metamorpheus")
if(length(names(peptides)[grepl("Total.Ion.Current", names(peptides))]) >0){
# if(!(any(grepl(sample_pattern, peptides$File.Name)))){
# stop("Sample pattern not found in file.")
# }
# else{
# peptides$sequence <- peptides$Base.Sequence
# names(peptides)[grepl("Total.Ion.Current", names(peptides))] <- "Intensity"
# names(peptides)[grepl("PSM.Count.*", names(peptides))] <- "PSM"
# names(peptides)[names(peptides) == "Full.Sequence"] <- "PEPTIDE"
# names(peptides)[names(peptides) == "Protein.Accession"] <- "protein"
# peptides <- peptides[peptides$PSM > 0,]
# peptides <- peptides[str_detect(peptides$File.Name, paste0(".*", sample_pattern, ".*")),]
# sample_count <- length(unique(peptides$File.Name))
#
# return(peptides)
#
# if (intensity_metric == "PSM") {
# peptides <- peptides %>% pivot_wider(names_from = File.Name, values_from = PSM)
# } else if (intensity_metric == "Intensity") {
# peptides <- peptides %>% pivot_wider(names_from = File.Name, values_from = Intensity)
# }
#
# new_names <- rep(NA, sample_count)
# for (i in 1:sample_count) {
# new_names[i] <- paste0("Volcano_intensity_", i)
# }
#
# colnames(peptides)[(ncol(peptides) - (sample_count-1)):ncol(peptides)] <- new_names
#
# return(peptides)
# }}

stop("Only quantified peptide results may be used for volcano plot from MetaMorpheus")
} else {
if(length(names(peptides)[grepl(sample_pattern, names(peptides))])<=0){
Expand Down Expand Up @@ -335,9 +306,20 @@ read_peptide_csv_generic_volcano <- function(peptide_file, sample_pattern, min_v
combine_two_volcano_dfs <- function(df_1, df_2, min_valid_sample = 2, fdr = 0.05,
fold_change_cutoff_plot = 1, fold_change_cutoff_sig = 5,
equal_variance_bool = T, remove_na = T, set_na = 0) {

print(paste0("rows in df_1: " ,nrow(df_1)))
print(paste0("rows in df_2: " ,nrow(df_2)))
print(names(df_1))

print(head(df_1$PEPTIDE))
print(head(df_1$sequence))
print(head(df_1$protien))

combine_df <- full_join(df_1, df_2, by = c("PEPTIDE", "sequence", "protein"))
combine_df <- full_join(df_1, df_2, by = c("PEPTIDE", "sequence", "protein"), multiple = "any")

print(paste0("rows in combined: " ,nrow(combine_df)))
print(names(combine_df))

volcano_df1 <- combine_df[,grepl("Volcano_intensity_.*\\.x", names(combine_df))]
volcano_df2 <- combine_df[,grepl("Volcano_intensity_.*\\.y", names(combine_df))]

Expand Down Expand Up @@ -396,9 +378,6 @@ combine_two_volcano_dfs <- function(df_1, df_2, min_valid_sample = 2, fdr = 0.05
combine_df$neg10logp[i] <- -log(combine_df$p_val[i], base = 10)
}
}

print(head(combine_df))
print("^^^ combined DF")

return(combine_df)
}
Expand Down Expand Up @@ -450,7 +429,7 @@ create_volcano_plot <- function(df, fdr = 0.05,
df$color[df$l2fc_xy < -fold_change_cutoff_plot & df$neg10logp > y_cutoff] <- "Significant"

if (!is.null(protein_of_interest)) {
df$color[grepl(protein_of_interest, df$protein)] <- "Prot_of_interest"
df$color[grepl(protein_of_interest, df$protein.x)] <- "Prot_of_interest"
}

if (length(unique(df$color)) == 1) {
Expand Down Expand Up @@ -492,13 +471,6 @@ create_volcano_plot <- function(df, fdr = 0.05,
plot_title <- paste0("Peptide Volcano Plot: ", intensity_metric, " (", protein_of_interest, ")")
}


print(head(df))
print("^^^ final DF")

print(maxx)
print(minx)

plot <- ggplot() +
geom_vline(xintercept = fold_change_cutoff_plot, linetype = 2) +
geom_vline(xintercept = -fold_change_cutoff_plot, linetype = 2) +
Expand Down

0 comments on commit 0ca06bc

Please sign in to comment.