about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexander_Kabui2024-11-11 14:36:55 +0300
committerAlexander_Kabui2024-11-11 14:36:55 +0300
commitdbc9bf9478d29a9fa1c8d2a807f15d0fca569846 (patch)
treecfcb60e6f092207db846b8539347f13e14858d71
parentc568db6548e306ccf7e43ae188e749427c580642 (diff)
downloadgenenetwork3-dbc9bf9478d29a9fa1c8d2a807f15d0fca569846.tar.gz
feat: print_help when certain parameters are not provided.
-rw-r--r--scripts/rqtl2_wrapper.R22
1 files changed, 9 insertions, 13 deletions
diff --git a/scripts/rqtl2_wrapper.R b/scripts/rqtl2_wrapper.R
index 7b83284..ee56d90 100644
--- a/scripts/rqtl2_wrapper.R
+++ b/scripts/rqtl2_wrapper.R
@@ -20,7 +20,8 @@ make_option(c("-i", "--input_file"), action="store", default=NULL, type='charact
   make_option(c("--pstrata"), action="store_true", default=NULL, help="Use permutation strata")
 )
 
-opt <- parse_args(OptionParser(option_list=option_list))
+opt_parser = OptionParser(option_list=option_list);
+opt <- parse_args(opt_parser)
 NO_OF_CORES = opt$cores
 SCAN_METHOD = opt$method
 NO_OF_PERMUTATION = opt$nperm
@@ -36,14 +37,14 @@ stop("The working directory does not exists or is NULL\n")
 
 INPUT_FILE_PATH = opt$input_file
 OUTPUT_FILE_PATH = opt$output_file 
-
 if (!(file.exists(INPUT_FILE_PATH))) {
+  print_help(opt_parser)
   stop("The input file", INPUT_FILE_PATH, " you provided does not exists\n")
 } else {
   cat("Input file exists Reading the input file .... \n")
-
 }
 if (!(file.exists(OUTPUT_FILE_PATH))) {
+  print_help(opt_parser)
   stop("The output file  ",OUTPUT_FILE_PATH, " you provided does not exists\n")
 } else {
   cat("Output file exists ...", OUTPUT_FILE_PATH, "\n")
@@ -57,9 +58,6 @@ genRandomFileName <- function(prefix, string_size = 9 , file_ext = ".txt") {
 }
 
 
-
-
-
 # Step: Generate the control file name
 control_file_path  <- file.path(opt$directory,
                                 genRandomFileName(prefix = "control", file_ext = ".json"))
@@ -422,12 +420,11 @@ perm <- perform_permutation_test(dataset, Pr, n_perm = NO_OF_PERMUTATION,perm_st
 
 # get the permutation summary with a significance threshold
 get_lod_significance <- function(perm, threshold = c(0.2, 0.05)){
-      cat("Fetching  the lod with significance thresholds as ", threshold, "\n")
-      summary(perm, alpha = threshold)
+     cat("Getting the permutation summary with significance thresholds as ", threshold, "\n")
+     summary(perm, alpha = threshold)
 }
-lod_significance <- get_lod_significance(perm)
-
 
+lod_significance <- get_lod_significance(perm)
 
 # step: get the lod peaks
 # TODO fix the threshold here
@@ -472,7 +469,7 @@ if (!is.null(dataset$covar) && !is.null(dataset$covar$sex)){
 } else {
 covar  <- NULL
 }
-covar
+
 
 
 meffects <- c()
@@ -499,8 +496,7 @@ for (chr in chr_names(dataset)){
      meffects <- append(meffects_plots, image_loc)
    } else {
     coeff_results  <- get_qtl_effect(chr, Pr, pheno)
-   }
- 
+   } 
     meffects <- append(meffects, coeff_results)
 }
 output = list(lod_peaks = lod_peaks,