@@ -115,36 +115,7 @@ read_peptide_tsv_Metamorpheus_volcano <- function(peptide_file, sample_pattern,
115115 peptides <- read.csv(peptide_file , sep = " \t " , header = T )
116116 filetype(peptides , " Combined" , " Metamorpheus" )
117117 if (length(names(peptides )[grepl(" Total.Ion.Current" , names(peptides ))]) > 0 ){
118- # if(!(any(grepl(sample_pattern, peptides$File.Name)))){
119- # stop("Sample pattern not found in file.")
120- # }
121- # else{
122- # peptides$sequence <- peptides$Base.Sequence
123- # names(peptides)[grepl("Total.Ion.Current", names(peptides))] <- "Intensity"
124- # names(peptides)[grepl("PSM.Count.*", names(peptides))] <- "PSM"
125- # names(peptides)[names(peptides) == "Full.Sequence"] <- "PEPTIDE"
126- # names(peptides)[names(peptides) == "Protein.Accession"] <- "protein"
127- # peptides <- peptides[peptides$PSM > 0,]
128- # peptides <- peptides[str_detect(peptides$File.Name, paste0(".*", sample_pattern, ".*")),]
129- # sample_count <- length(unique(peptides$File.Name))
130- #
131- # return(peptides)
132- #
133- # if (intensity_metric == "PSM") {
134- # peptides <- peptides %>% pivot_wider(names_from = File.Name, values_from = PSM)
135- # } else if (intensity_metric == "Intensity") {
136- # peptides <- peptides %>% pivot_wider(names_from = File.Name, values_from = Intensity)
137- # }
138- #
139- # new_names <- rep(NA, sample_count)
140- # for (i in 1:sample_count) {
141- # new_names[i] <- paste0("Volcano_intensity_", i)
142- # }
143- #
144- # colnames(peptides)[(ncol(peptides) - (sample_count-1)):ncol(peptides)] <- new_names
145- #
146- # return(peptides)
147- # }}
118+
148119 stop(" Only quantified peptide results may be used for volcano plot from MetaMorpheus" )
149120 } else {
150121 if (length(names(peptides )[grepl(sample_pattern , names(peptides ))])< = 0 ){
@@ -335,9 +306,20 @@ read_peptide_csv_generic_volcano <- function(peptide_file, sample_pattern, min_v
335306combine_two_volcano_dfs <- function (df_1 , df_2 , min_valid_sample = 2 , fdr = 0.05 ,
336307 fold_change_cutoff_plot = 1 , fold_change_cutoff_sig = 5 ,
337308 equal_variance_bool = T , remove_na = T , set_na = 0 ) {
309+
310+ print(paste0(" rows in df_1: " ,nrow(df_1 )))
311+ print(paste0(" rows in df_2: " ,nrow(df_2 )))
312+ print(names(df_1 ))
313+
314+ print(head(df_1 $ PEPTIDE ))
315+ print(head(df_1 $ sequence ))
316+ print(head(df_1 $ protien ))
338317
339- combine_df <- full_join(df_1 , df_2 , by = c(" PEPTIDE" , " sequence" , " protein" ))
318+ combine_df <- full_join(df_1 , df_2 , by = c(" PEPTIDE" , " sequence" , " protein" ), multiple = " any " )
340319
320+ print(paste0(" rows in combined: " ,nrow(combine_df )))
321+ print(names(combine_df ))
322+
341323 volcano_df1 <- combine_df [,grepl(" Volcano_intensity_.*\\ .x" , names(combine_df ))]
342324 volcano_df2 <- combine_df [,grepl(" Volcano_intensity_.*\\ .y" , names(combine_df ))]
343325
@@ -396,9 +378,6 @@ combine_two_volcano_dfs <- function(df_1, df_2, min_valid_sample = 2, fdr = 0.05
396378 combine_df $ neg10logp [i ] <- - log(combine_df $ p_val [i ], base = 10 )
397379 }
398380 }
399-
400- print(head(combine_df ))
401- print(" ^^^ combined DF" )
402381
403382 return (combine_df )
404383}
@@ -450,7 +429,7 @@ create_volcano_plot <- function(df, fdr = 0.05,
450429 df $ color [df $ l2fc_xy < - fold_change_cutoff_plot & df $ neg10logp > y_cutoff ] <- " Significant"
451430
452431 if (! is.null(protein_of_interest )) {
453- df $ color [grepl(protein_of_interest , df $ protein )] <- " Prot_of_interest"
432+ df $ color [grepl(protein_of_interest , df $ protein.x )] <- " Prot_of_interest"
454433 }
455434
456435 if (length(unique(df $ color )) == 1 ) {
@@ -492,13 +471,6 @@ create_volcano_plot <- function(df, fdr = 0.05,
492471 plot_title <- paste0(" Peptide Volcano Plot: " , intensity_metric , " (" , protein_of_interest , " )" )
493472 }
494473
495-
496- print(head(df ))
497- print(" ^^^ final DF" )
498-
499- print(maxx )
500- print(minx )
501-
502474 plot <- ggplot() +
503475 geom_vline(xintercept = fold_change_cutoff_plot , linetype = 2 ) +
504476 geom_vline(xintercept = - fold_change_cutoff_plot , linetype = 2 ) +
0 commit comments