## global options
knitr::opts_chunk$set(echo=FALSE,
                      warning=FALSE,
                      error=TRUE,
                      message=FALSE,
                      comment = NA,
                      fig.height = 12,
                      fig.width = 10)
library(MQmetrics)
MQPathCombined <- params$input_dir
MQCombined <- make_MQCombined(MQPathCombined,
                              remove_contaminants = params$remove_contaminants) 
MaxQuantAnalysisInfo(MQCombined) 

\newpage

if (! is.null(MQCombined$proteinGroups.txt)) {

  PlotProteinsIdentified(MQCombined,
                       intensity_type =params$intensity_type,
                       long_names = params$long_names, 
                       sep_names = params$sep_names, 
                       palette = params$palette)
}else{
  print('proteinGroups.txt is missing, can not create plot')
}

\newpage

if (! is.null(MQCombined$proteinGroups.txt)) {

  PlotProteinOverlap(MQCombined)

}else{
  print('proteinGroups.txt is missing, can not create plot')
}

\newpage

if ((!is.null(MQCombined$summary.txt )) &&
     (!is.null(MQCombined$parameters.txt)))  {

  PlotPeptidesIdentified(MQCombined, 
                       long_names = params$long_names, 
                       sep_names = params$sep_names, 
                       palette = params$palette)
}else{
  print('parameter.txt and/or peptides.txt is missing, can not create plot')
}

\newpage

if ((!is.null(MQCombined$summary.txt == TRUE )) &&
     (!is.null(MQCombined$parameters.txt)== TRUE))  {

  PlotProteinPeptideRatio(MQCombined,
                          intensity_type = params$intensity_type, 
                          long_names = params$long_names, 
                          sep_names = params$sep_names)

}else{
  print('summary.txt and/or proteinGroups.txt is missing, can not create plot')
}  

\newpage

if ((!is.null(MQCombined$summary.txt == TRUE )) &&
     (!is.null(MQCombined$parameters.txt)== TRUE)) {

  PlotMsMs(MQCombined,
           long_names = params$long_names, 
           sep_names = params$sep_names, 
           palette = params$palette)
}else{
  print('summary.txt and/or parameters.txt is missing, can not create plot')
}    

\newpage

if ((!is.null(MQCombined$summary.txt == TRUE )) &&
     (!is.null(MQCombined$parameters.txt)== TRUE))  {

  PlotPeaks(MQCombined, 
            long_names = params$long_names, 
            sep_names = params$sep_names, 
            palette = params$palette)
}else{
  print('summary.txt and/or parameters.txt is missing, can not create plot')
}   

\newpage

if ((!is.null(MQCombined$summary.txt == TRUE )) &&
     (!is.null(MQCombined$parameters.txt)== TRUE)) {
  PlotIsotopePattern(MQCombined,
                     long_names = params$long_names, 
                     sep_names = params$sep_names, 
                     palette = params$palette)
}else{
  print('summary.txt and/or parameters.txt is missing, can not create plot')
} 

\newpage

# To avoid the report of printing [[1]] .. plot , [[2]] .., 
# I create a variable called n_pages, that I will use to print the pages of 
# some of the functions directly.

n_pages <- ceiling(nrow(MQCombined$summary.txt)/params$plots_per_page)
if (! is.null(MQCombined$evidence.txt )) {

  for (page in seq_len(n_pages)) {
    print(
      PlotCharge(MQCombined, 
             palette = params$palette,
             plots_per_page = params$plots_per_page)[[page]]
      )
  }
}else{
  print('evidence.txt is missing, can not create plot')
}   

\newpage

if (! is.null(MQCombined$peptides.txt )) {

  for(page in seq_len(n_pages)){
    print(
      PlotProteaseSpecificity(MQCombined, 
                          palette = params$palette,
                          plots_per_page = params$plots_per_page)[[page]]
      )
  }
}else{
  print('peptides.txt is missing, can not create plot')
}   

\newpage

if (! is.null(MQCombined$peptides.txt )) {

  for(page in seq_len(n_pages)){
    print(
      PlotHydrophobicity(MQCombined,
                       palette = params$palette,
                       show_median =  params$show_median,
                       size_median = params$size_median,
                       binwidth = params$binwidth,
                       plots_per_page = params$plots_per_page)[[page]]
      )
  }
}else{
  print('peptides.txt is missing, can not create plot')
} 

\newpage

if (! is.null(MQCombined$peptides.txt )) {  

  for(page in seq_len(n_pages)){
    print(
      PlotAndromedaScore(MQCombined,
                         show_median =  params$show_median,
                         size_median = params$size_median,
                         palette = params$palette,
                         plots_per_page = params$plots_per_page)[[page]]
      )
  }
}else{
  print('peptides.txt is missing, can not create plot')
} 

\newpage

if (! is.null(MQCombined$proteinGroups.txt )) {

  PlotIntensity(MQCombined, 
                intensity_type = params$intensity_type, 
                log_base = params$log_base, 
                long_names = params$long_names, 
                sep_names = params$sep_names,
                palette = params$palette)
}else{
  print('proteinGroups.txt is missing, can not create plot')
}   

\newpage

if (! is.null(MQCombined$proteinGroups.txt )) {

  PlotPCA(MQCombined,
          intensity_type = params$intensity_type,
          palette = params$palette)

}else{
  print('proteinGroups.txt is missing, can not create plot')
} 

\newpage

if (! is.null(MQCombined$proteinGroups.txt )) {

  PlotCombinedDynamicRange(MQCombined,
                           show_shade = params$show_shade, 
                           percent_proteins = params$percent_proteins) 

}else{
  print('proteinGroups.txt is missing, can not create plot')
} 

\newpage

if (! is.null(MQCombined$proteinGroups.txt )) {

  PlotAllDynamicRange(MQCombined,
                      show_shade = params$show_shade, 
                      percent_proteins = params$percent_proteins)


}else{
  print('proteinGroups.txt is missing, can not create plot')
} 

\newpage

if ((! is.null(MQCombined$peptides.txt  ) == TRUE) && 
    (!is.null(MQCombined$proteinGroups.txt  ) == TRUE)) {

  p <- PlotProteinCoverage(MQCombined,
                            UniprotID = params$UniprotID,
                            log_base = params$log_base,
                            segment_width = params$segment_width,
                            palette = params$palette,
                            plots_per_page = params$plots_per_page)




  if(is.null(params$UniprotID)){

      print('No UniprotID provided.')

  } else if (is.null(p)) {
    print(paste0('The UniprotID: ',params$UniprotID,
                 ' was not found in the analysis.'))
  }else{

    # For each different page
    for(page in seq_len(n_pages)){

      # For each different Uniprot 
      for (plot in seq_len(length(p[[1]]))) {

              print(p[[page]][[plot]])
        }
      }
  }

}else{
  print('proteinGroups.txt and/or peptides.txt is missing, can not create plot')
} 

\newpage

if (! is.null(MQCombined$evidence.txt )) {


  p <- PlotiRT(MQCombined, 
              show_calibrated_rt = params$show_calibrated_rt,
              tolerance =  params$tolerance,
              plots_per_page = params$plots_per_page)


  if (is.null(p)) {
    print('iRT peptides not found')

  } else{

    for(page in seq_len(n_pages)){
      print(p[[page]])
      }
  }

} else{
  print('evidence.txt is missing, can not create plot')
} 

\newpage

if (! is.null(MQCombined$evidence.txt )) {

  p <-  PlotiRTScore(MQCombined,
                   tolerance =  params$tolerance,
                   plots_per_page = params$plots_per_page)

  if (is.null(p)) {
    print('iRT peptides not found')
  } else{

    for(page in seq_len(n_pages)){
      print(p[[page]])
    }
  }

} else{
  print('evidence.txt is missing, can not create plot')
} 

\newpage

if (! is.null(MQCombined$msmsScans.txt )) {

  for(page in seq_len(n_pages)){
    print(
      PlotTotalIonCurrent(MQCombined,
                          show_max_value = params$show_max_value,
                          palette = params$palette,
                          plots_per_page = params$plots_per_page)[[page]]
        )
  }

}else{
  print('msmsScans.txt is missing, can not create plot')
} 

\newpage

if (! is.null(MQCombined$msScans.txt )) {

  for(page in seq_len(n_pages)){
    print(
      PlotAcquisitionCycle(MQCombined, 
                           palette = params$palette,
                           plots_per_page = params$plots_per_page)[[page]]
        )
  }

}else{
  print('msScans.txt is missing, can not create plot')
} 

\newpage

if (! is.null(MQCombined$modificationSpecificPeptides )) {

  for(page in seq_len(n_pages)){
    print(
      PlotPTM(MQCombined, 
              peptides_modified = params$peptides_modified,
              log_base = params$log_base,
              plot_unmodified_peptides = params$plot_unmodified_peptides,
              palette = params$palette,
              aggregate_PTMs = params$aggregate_PTMs,
              combine_same_residue_ptms = params$combine_same_residue_ptms,
              plots_per_page = params$plots_per_page)[[page]]
        )
  }

}else{
  print('modificationSpecificPeptides is missing, can not create plot')
}   

\newpage

if (! is.null(MQCombined$modificationSpecificPeptides )) {

  p <- PlotPTMAcrossSamples(MQCombined, 
                      PTM_of_interest = params$PTM_of_interest,
                      log_base = params$log_base, 
                      long_names = params$long_names, 
                      sep_names = params$sep_names)

  for (index in seq_len(length(params$PTM_of_interest))) {
    print(p[[index]])
  }

}else{
  print('modificationSpecificPeptides is missing, can not create plot')
} 

\newpage

a <- ReportTables(MQCombined,
                  log_base = params$log_base,
                  intensity_type = params$intensity_type,
                  long_names = params$long_names, 
                  sep_names = params$sep_names)


kable(a[[1]], caption = 'Protein Information')
kable(a[[2]], caption =  paste0('Information of: Log',
                                params$log_base,
                                ' ',
                                params$intensity_type))   
kable(a[[3]], caption = 'Charge Information')
kable(a[[4]], caption = 'Peptide hydrophobicity (GRAVY)')
kable(a[[5]], caption = 'Missed Enzymatic Cleavages')
kable(a[[6]], caption = 'Protein Identification Overlap Between Samples')


BioAlvaro/MQmetrics documentation built on Jan. 12, 2022, 3:02 p.m.