Skip to content

Commit

Permalink
v1.11.2: Fix bug affecting analysisQuantifications and other improvem…
Browse files Browse the repository at this point in the history
…ents

+ Bug fix affecting {artmsAnalysisQuantifications()}
+ Allow {artmsAnalysisQuantifications()} to process previous versions of artMS
+ Change Extension of {artms_sessionInfo_quantification} file from {.txt} to {.log}
+ New parameters available in {artmsQuantification()}, including:
   - Parameter {printTables}. Default {TRUE}, prints tables. FALSE otherwise.
   - Parameter {return_results_object}. If TRUE, it returns a list of data frames with MSstats results. Default is FALSE
   - If both {printTables} and {printPDF} are FALSE, then {return_results_object} becames TRUE and a list of data frames is returned
+ Change default parameters of the configuration files: less verbose
  • Loading branch information
biodavidjm committed Jul 14, 2021
1 parent 55ea8f1 commit 5fd14f8
Show file tree
Hide file tree
Showing 15 changed files with 340 additions and 182 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
Meta
doc

# History files
**.Rhistory
**.Rapp.history
**.Rprofile
**.DS_Store

# TESTS
tests/testthat/*log
tests/testthat/*txt
tests/testthat/*pdf

# MSstats files
msstats.log*
sessionInfo.txt
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: artMS
Type: Package
Title: Analytical R tools for Mass Spectrometry
Version: 1.11.1
Date: 2021-07-08
Version: 1.11.2
Date: 2021-07-13
Authors@R: c(person("David", "Jimenez-Morales", role = c("aut","cre"),
email = "[email protected]",
comment = c(ORCID = "0000-0003-4356-6461")),
Expand Down
10 changes: 10 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Changes in version 1.10.2 (2021-07-13)
+ Bug fix affecting {artmsAnalysisQuantifications()}
+ Allow {artmsAnalysisQuantifications()} to process previous versions of artMS
+ Change Extension of {artms_sessionInfo_quantification} file from {.txt} to {.log}
+ New parameters available in {artmsQuantification()}, including:
- Parameter {printTables}. Default {TRUE}, prints tables. FALSE otherwise.
- Parameter {return_results_object}. If TRUE, it returns a list of data frames with MSstats results. Default is FALSE
- If both {printTables} and {printPDF} are FALSE, then {return_results_object} becames TRUE and a list of data frames is returned
+ Change default parameters of the configuration files: less verbose

Changes in version 1.10.1 (2021-06-30)
+ Addressing major changes in MSstats
- R version larger than 4.1 is now required
Expand Down
2 changes: 1 addition & 1 deletion R/MSstats_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ artmsSILACtoLong <- function(evidence_file,
cmmp = cmmp + 1
}
if(!any(grepl("^use_log_file$", names(config$msstats)))){
config$msstats$use_log_file = TRUE
config$msstats$use_log_file = FALSE
cmmp = cmmp + 1
}
if(!any(grepl("^append$", names(config$msstats)))){
Expand Down
19 changes: 16 additions & 3 deletions R/analysisQuantifications.R
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ artmsAnalysisQuantifications <- function(log2fc_file,

## CRAN -----
required_bioc_packages <- c("ComplexHeatmap")
for(p in required_cran_packages){
for(p in required_bioc_packages){
if(!(p %in% installed.packages())){
message(paste0('- Package < ', p, ' > not installed in your system.
Please, install running < BiocManager::install(\"',p,'\") >'))
Expand Down Expand Up @@ -315,7 +315,19 @@ artmsAnalysisQuantifications <- function(log2fc_file,
stringsAsFactors = FALSE)
colnames(dfmq) <- toupper(colnames(dfmq))
}


# ModelQC: fix old files-----
if("GROUP_ORIGINAL" %in% colnames(dfmq)){
if(verbose) message("\n------------------------------------------------------------")
if(verbose) message("(!) WARNING!")
if(verbose) message("Be aware that you are analyzing a dataset that was generated with an old version of MSstats (< 4.0)")
if(verbose) message("Some changes will be applied")
if(verbose) message(" ------------------------------------------------------------\n")
dfmq$GROUP <- NULL
dfmq$GROUP <- dfmq$GROUP_ORIGINAL
dfmq$SUBJECT <- NULL
dfmq$SUBJECT <- dfmq$SUBJECT_ORIGINAL
}

# Removing the empty protein names-----
if (any(dfmq$PROTEIN == "")) {
Expand Down Expand Up @@ -2019,7 +2031,8 @@ artmsAnalysisQuantifications <- function(log2fc_file,
list_of_datasets,
file = outexcel,
asTable = FALSE,
headerStyle = hs
headerStyle = hs,
overwrite = TRUE
)

if(verbose) message("Folder <", output_dir, "> ")
Expand Down
21 changes: 12 additions & 9 deletions R/getMSstatsformat.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
# '.txt' extension required
# @param data_object (logical) if TRUE the output_name cannot be the evidence file
# since it would be an data_object
# @param printTables (logical) `TRUE` (default) prints results tables
# @param verbose (logical) `TRUE` (default) shows function messages
# @return (data.frame) MSstats compatible format
# @keywords internal, MSstats, format, input, fractions
.artms_getMSstatsFormat <- function(data_f,
output_name,
data_object = FALSE,
printTables = TRUE,
verbose = TRUE) {

Run = PeptideSequence = Condition_BioReplicate_Run = NULL
Expand Down Expand Up @@ -126,14 +128,15 @@
}

dmss <- as.data.frame(dmss)
if(verbose) message("-- Write out the MSstats input file (-mss.txt) ")
write.table(dmss,
file = gsub('.txt', '-mss.txt', output_name),
eol = "\n",
sep = "\t",
quote = FALSE,
row.names = FALSE,
col.names = TRUE)

if(printTables){
if(verbose) message("-- Write out the MSstats input file (-mss.txt) ")
write.table(dmss,
file = gsub('.txt', '-mss.txt', output_name),
eol = "\n",
sep = "\t",
quote = FALSE,
row.names = FALSE,
col.names = TRUE)
}
return(dmss)
}
65 changes: 52 additions & 13 deletions R/main.R
Original file line number Diff line number Diff line change
Expand Up @@ -184,20 +184,44 @@ utils::globalVariables(
#' is a string to a file that should be opened or config object (yaml).
#' Default is `FALSE`. Choose `TRUE` if `yaml_config_file` is a yaml object
#' @param printPDF (logical) if `TRUE` (default), prints out pdf
#' @param printTables (logical) `TRUE` (default) print results tables
#' @param display_msstats (logical) if `TRUE`, prints MSstats outputs (default is `FALSE`)
#' @param return_results_object (logical) Default is `FALSE`.
#' If `TRUE`, it returns a list of data frames with MSstats results, including:
#' - `comparisonResult`: comparison results
#' - `ModelQC`
#' - `FittedModel`: fit model details
#' - `power`: power calculations
#' - `sample_size`: sample size estimations
#' @param verbose (logical) `TRUE` (default) shows function messages
#' @return The relative quantification of the conditions and comparisons
#' specified in the keys/contrast file resulting from running MSstats, in
#' addition to quality control plots (if selected)
#' @keywords main, driver, function
#' @examples \dontrun{
#' artmsQuantification(yaml_config_file = "path/to/artms-ab-config.yaml")
#' }
#' @examples
#' # Recommended
#' # artmsQuantification(yaml_config_file = "your-config-file.yaml")
#'
#' # Example to test this function using the example dataset available in artMS
#' # Step 1: Add evidence, keys, and contrast to configuration object
#' artms_data_ph_config$files$evidence <- artms_data_ph_evidence
#' artms_data_ph_config$files$keys <- artms_data_ph_keys
#' artms_data_ph_config$files$contrasts <- artms_data_ph_contrast
#'
#' # Step 2: Run the quantification step
#' quant_results <- artmsQuantification(yaml_config_file = artms_data_ph_config,
#' data_object = TRUE,
#' display_msstats = FALSE,
#' printPDF = FALSE,
#' printTables = FALSE)
#' # Check the list of data frames "quant_results". Nothing should be printed out.
#' @export
artmsQuantification <- function(yaml_config_file,
data_object = FALSE,
printPDF = TRUE,
printTables = TRUE,
display_msstats = FALSE,
return_results_object = FALSE,
verbose = TRUE) {

# Check if the yaml file is already open first
Expand Down Expand Up @@ -231,10 +255,16 @@ artmsQuantification <- function(yaml_config_file,
config$data$filters$modification <- toupper(config$data$filters$modification)
}

session <- sessionInfo()
sink("artms_sessionInfo_quantification.txt")
print(session)
sink()
if(isFALSE(printTables) & isFALSE(printPDF) & isFALSE(return_results_object)){
return_results_object = TRUE
}

if(printTables){
session <- sessionInfo()
sink("artms_sessionInfo_quantification.log")
print(session)
sink()
}

# Quality Control
if (config$qc$basic) {
Expand Down Expand Up @@ -282,13 +312,15 @@ artmsQuantification <- function(yaml_config_file,
# message("output_dir: ", output_dir)

# create output directory if it doesn't exist-----
if (!dir.exists(output_dir)) {
if(verbose) message("-- Folder: [", output_dir, "] created" )
dir.create(output_dir, recursive = TRUE)
if(printTables | printPDF){
if (!dir.exists(output_dir)) {
if(verbose) message("-- Folder: [", output_dir, "] created" )
dir.create(output_dir, recursive = TRUE)
}
}

# process MaxQuant data, link with keys, and convert for MSStats format-----
if (config$data$enabled) {
if ( config$data$enabled ) {
if(verbose) message(">> LOADING DATA ")
## Found more bugs in fread (issue submitted to data.table on github by
## JVD but it was closed with the excuse that 'is was not reproducible'
Expand Down Expand Up @@ -407,6 +439,7 @@ artmsQuantification <- function(yaml_config_file,
dmss <- .artms_getMSstatsFormat(data_f = data_f,
output_name = config$files$evidence,
data_object = data_object,
printTables = printTables,
verbose = verbose)
} else {
if(verbose) message(sprintf("\t+ READING PREPROCESSED FILE: %s ",
Expand All @@ -431,6 +464,8 @@ artmsQuantification <- function(yaml_config_file,
suppressWarnings(results <- .artms_runMSstats(dmss = dmss,
contrasts = contrasts,
config = config,
printTables = printTables,
printPDF = printPDF,
verbose = verbose)
)
)
Expand All @@ -441,7 +476,11 @@ artmsQuantification <- function(yaml_config_file,

if(data_object){
return(results)
}
}else{
if(return_results_object){
return(results)
}
}

} else{
if(verbose) message("\t+ MSstats not selected")
Expand Down
Loading

0 comments on commit 5fd14f8

Please sign in to comment.