comparison mqppep_anova.R @ 22:61adb8801b73 draft

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/mqppep commit 0c7ca054e77e042c8a584c9903073da064df7d8b
author eschen42
date Thu, 30 Jun 2022 16:16:32 +0000
parents 2c5f1a2fe16a
children 5b8e15b2a67c
comparison
equal deleted inserted replaced
21:f3deca1a3c84 22:61adb8801b73
1 #!/usr/bin/env Rscript 1 #!/usr/bin/env Rscript
2 # libraries 2 # libraries
3 library(optparse) 3 library(optparse)
4 library(data.table) 4 library(data.table)
5 library(stringr) 5 library(stringr)
6 # bioconductor-preprocesscore
7 # - libopenblas
8 # - r-data.table
9 # - r-rmarkdown
10 # - r-ggplot2
11 # - texlive-core
12 6
13 # ref for parameterizing Rmd document: https://stackoverflow.com/a/37940285 7 # ref for parameterizing Rmd document: https://stackoverflow.com/a/37940285
14 8
15 # parse options 9 # parse options
16 option_list <- list( 10 option_list <- list(
26 action = "store", 20 action = "store",
27 default = NA, 21 default = NA,
28 type = "character", 22 type = "character",
29 help = paste0("List of alpha cutoff values for significance testing;", 23 help = paste0("List of alpha cutoff values for significance testing;",
30 " path to text file having one column and no header") 24 " path to text file having one column and no header")
25 ),
26 make_option(
27 c("-S", "--preproc_sqlite"),
28 action = "store",
29 default = NA,
30 type = "character",
31 help = "Path to 'preproc_sqlite' produced by `mqppep_mrgfltr.py`"
32 ),
33 make_option(
34 c("-K", "--ksea_sqlite"),
35 action = "store",
36 default = NA,
37 type = "character",
38 help = "Path to 'ksea_sqlite' output produced by this tool"
31 ), 39 ),
32 make_option( 40 make_option(
33 c("-f", "--firstDataColumn"), 41 c("-f", "--firstDataColumn"),
34 action = "store", 42 action = "store",
35 default = "^Intensity[^_]", 43 default = "^Intensity[^_]",
97 c("-r", "--reportFile"), 105 c("-r", "--reportFile"),
98 action = "store", 106 action = "store",
99 default = "QuantDataProcessingScript.html", 107 default = "QuantDataProcessingScript.html",
100 type = "character", 108 type = "character",
101 help = "HTML report file path" 109 help = "HTML report file path"
110 ),
111 make_option(
112 c("-k", "--ksea_cutoff_statistic"),
113 action = "store",
114 default = "FDR",
115 type = "character",
116 help = paste0("Method for missing-value imputation,",
117 " one of c('FDR','p.value'), but don't expect 'p.value' to work well.")
118 ),
119 make_option(
120 c("-t", "--ksea_cutoff_threshold"),
121 action = "store",
122 default = 0.05,
123 type = "double",
124 help = paste0("Maximum score to be used to score a kinase enrichment as significant")
125 ),
126 make_option(
127 c("-M", "--anova_ksea_metadata"),
128 action = "store",
129 default = "anova_ksea_metadata.tsv",
130 type = "character",
131 help = "Phosphopeptide metadata, ANOVA FDR, and KSEA enribhments"
102 ) 132 )
103 ) 133 )
104 args <- parse_args(OptionParser(option_list = option_list)) 134 args <- parse_args(OptionParser(option_list = option_list))
105 print("args is:") 135 print("args is:")
106 cat(str(args)) 136 cat(str(args))
110 if (! file.exists(args$inputFile)) { 140 if (! file.exists(args$inputFile)) {
111 stop((paste("Input file", args$inputFile, "does not exist"))) 141 stop((paste("Input file", args$inputFile, "does not exist")))
112 } 142 }
113 input_file <- args$inputFile 143 input_file <- args$inputFile
114 alpha_file <- args$alphaFile 144 alpha_file <- args$alphaFile
145 preproc_sqlite <- args$preproc_sqlite
115 imputed_data_file_name <- args$imputedDataFile 146 imputed_data_file_name <- args$imputedDataFile
116 imp_qn_lt_data_filenm <- args$imputedQNLTDataFile 147 imp_qn_lt_data_filenm <- args$imputedQNLTDataFile
148 anova_ksea_metadata <- args$anova_ksea_metadata
117 report_file_name <- args$reportFile 149 report_file_name <- args$reportFile
150 ksea_sqlite <- args$ksea_sqlite
151 ksea_cutoff_statistic <- args$ksea_cutoff_statistic
152 ksea_cutoff_threshold <- args$ksea_cutoff_threshold
153 if (
154 sum(
155 grepl(
156 pattern = ksea_cutoff_statistic,
157 x = c("FDR", "p.value")
158 )
159 ) < 1
160 ) {
161 print(sprintf("bad ksea_cutoff_statistic argument: %s", ksea_cutoff_statistic))
162 return(-1)
163 }
118 164
119 imputation_method <- args$imputationMethod 165 imputation_method <- args$imputationMethod
120 print(
121 grepl(
122 pattern = imputation_method,
123 x = c("group-median", "median", "mean", "random")
124 )
125 )
126
127 if ( 166 if (
128 sum( 167 sum(
129 grepl( 168 grepl(
130 pattern = imputation_method, 169 pattern = imputation_method,
131 x = c("group-median", "median", "mean", "random") 170 x = c("group-median", "median", "mean", "random")
217 script_dir <- location_of_this_script() 256 script_dir <- location_of_this_script()
218 257
219 rmarkdown_params <- list( 258 rmarkdown_params <- list(
220 inputFile = input_file 259 inputFile = input_file
221 , alphaFile = alpha_file 260 , alphaFile = alpha_file
261 , preprocDb = preproc_sqlite
222 , firstDataColumn = first_data_column 262 , firstDataColumn = first_data_column
223 , imputationMethod = imputation_method 263 , imputationMethod = imputation_method
224 , meanPercentile = mean_percentile 264 , meanPercentile = mean_percentile
225 , sdPercentile = sd_percentile 265 , sdPercentile = sd_percentile
226 , regexSampleNames = regex_sample_names 266 , regexSampleNames = regex_sample_names
227 , regexSampleGrouping = regex_sample_grouping 267 , regexSampleGrouping = regex_sample_grouping
228 , imputedDataFilename = imputed_data_file_name 268 , imputedDataFilename = imputed_data_file_name
229 , imputedQNLTDataFile = imp_qn_lt_data_filenm 269 , imputedQNLTDataFile = imp_qn_lt_data_filenm
270 , anovaKseaMetadata = anova_ksea_metadata
271 , kseaAppPrepDb = ksea_sqlite
272 , kseaCutoffThreshold = ksea_cutoff_threshold
273 , kseaCutoffStatistic = ksea_cutoff_statistic
230 ) 274 )
231 275
232 print("rmarkdown_params") 276 print("rmarkdown_params")
233 str(rmarkdown_params) 277 str(rmarkdown_params)
234 278