### Required packages ---- library(readr) library(dplyr) ### Directory selection ---- # Select directory or simply use the one where the script is stored setwd(dirname(rstudioapi::getSourceEditorContext()$path)) wd <- getwd() ### Import peak boundaries ---- Peak_Boundaries <- read_csv("Peak Boundaries.csv") ### Project peak boundaries --- # Define function boundaries.projection <- function(reference_sample, boundaries_file) { boundaries <- read_csv(boundaries_file) boundaries$"Peptide Feature" <- paste(boundaries$`Peptide Modified Sequence`, boundaries$`Precursor Charge`, sep = ":") # Bin all results with respect to peptide features Unique_features <- unique(boundaries$`Peptide Feature`) Feature_list <- list() for (p in 1:length(Unique_features)) { temp.feature <- filter(.data = boundaries, `Peptide Feature` == Unique_features[p]) # Select reference boundaries reference_min_start_time <- temp.feature$`Min Start Time`[which(temp.feature$`File Name` == reference_sample)] reference_max_end_time <- temp.feature$`Max End Time`[which(temp.feature$`File Name` == reference_sample)] if (length(reference_min_start_time) > 1) { next } else { # Implement boundaries temp.feature$`Min Start Time` <- reference_min_start_time temp.feature$`Max End Time` <- reference_max_end_time Feature_list[[p]] <- temp.feature } } Feature_list <- bind_rows(Feature_list) boundaries_corrected <- Feature_list[, c("File Name", "Peptide Modified Sequence", "Min Start Time", "Max End Time", "Precursor Charge", "PrecursorIsDecoy")] write.csv(x = boundaries_corrected, row.names = FALSE, quote = FALSE, file = paste(boundaries_file, "_corrected.csv", sep = "")) } # select reference sample and peak boundaries file to correct boundaries.projection(reference_sample = "QE_21_37_SeSc102.raw", boundaries_file = "Peak Boundaries.csv") # Output should be written in working directory. You can use this to change peak boundaries in Skyline