From bc9d3de5b365069d85a3900f2f0a9bfa57cd7cd7 Mon Sep 17 00:00:00 2001 From: Damien RAT Date: Wed, 6 Nov 2024 15:25:49 +0100 Subject: [PATCH] Add psg_list option to groupCorr --- tools/camera/CAMERA_groupCorr.R | 37 ++++++++++++++++++++++++++++++++- tools/camera/groupCorr.xml | 19 +++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/tools/camera/CAMERA_groupCorr.R b/tools/camera/CAMERA_groupCorr.R index bb3c41bbb..4aed27bb2 100755 --- a/tools/camera/CAMERA_groupCorr.R +++ b/tools/camera/CAMERA_groupCorr.R @@ -25,6 +25,41 @@ cat("\n\n") print("Arguments retrieved from the command line:") print(args) +# Function to convert "NULL" strings to actual NULL values +convertNullString <- function(x) { + if (x == "NULL") { + return(NULL) + } + return(x) +} + +# Function to convert string to numeric lists +convert_psg_list <- function(x) { + # Check if x is NULL or has zero length before further processing + if (is.null(x) || length(x) == 0) { + return(NULL) + } + + # Force conversion to character + x <- as.character(x) + + if (grepl("^[0-9]+$", x)) { + # If the string represents a single numeric value + return(as.numeric(x)) + } else { + # Convert string representation of a list to a numeric vector + # Use a regular expression to split by common separators + return(as.numeric(unlist(strsplit(x, "[,;\\s]+")))) + } +} + +for (arg in names(args)) { + args[[arg]] <- convertNullString(args[[arg]]) +} + +# Convert only the 'psg_list' element in args +args$psg_list <- convert_psg_list(args$psg_list) + print("Argument types:") print(sapply(args, class)) @@ -66,7 +101,7 @@ print(xa) # Apply the groupCorr function to the xsAnnotate object print("Calling groupCorr function:") -xa <- groupCorr(xa, cor_eic_th = args$cor_eic_th, pval = args$pval, graphMethod = args$graphMethod, calcIso = args$calcIso, calcCiS = args$calcCiS, calcCaS = args$calcCaS, cor_exp_th = args$cor_exp_th, intval = args$intval) +xa <- groupCorr(xa, cor_eic_th = args$cor_eic_th, pval = args$pval, graphMethod = args$graphMethod, calcIso = args$calcIso, calcCiS = args$calcCiS, calcCaS = args$calcCaS, psg_list = args$psg_list, cor_exp_th = args$cor_exp_th, intval = args$intval) print("Result of groupCorr function:") print(xa) diff --git a/tools/camera/groupCorr.xml b/tools/camera/groupCorr.xml index 991a749d8..4e2c25929 100755 --- a/tools/camera/groupCorr.xml +++ b/tools/camera/groupCorr.xml @@ -21,6 +21,13 @@ calcIso $calcIso calcCiS $calcCiS calcCaS $calcCaS + + #if $psg_list_block.psg_list_select == "FALSE": + psg_list NULL + #else + psg_list $psg_list + #end if + cor_exp_th $cor_exp_th intval $intval numDigitsMZ $numDigitsMZ @@ -51,6 +58,18 @@ --> + + + + + + + + + + + +