Skip to content

Commit

Permalink
Add psg_list option to groupCorr
Browse files Browse the repository at this point in the history
  • Loading branch information
DamienCode404 committed Nov 6, 2024
1 parent 5db6857 commit bc9d3de
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
37 changes: 36 additions & 1 deletion tools/camera/CAMERA_groupCorr.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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)
Expand Down
19 changes: 19 additions & 0 deletions tools/camera/groupCorr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -51,6 +58,18 @@
<option value="maxf">maxf</option>
<option value="area">area</option> -->
</param>
<conditional name="psg_list_block">
<param name="psg_list_select" type="select" label="Use a personal psg_list">
<option value="TRUE">TRUE</option>
<option value="FALSE" selected="true">FALSE</option>
</param>
<when value="FALSE">
<!--<param name="psg_list" type="text" value="NULL" label="No psg_list" optional="true" />-->
</when>
<when value="TRUE">
<param name="psg_list" type="text" optional="true" label="Pseudospectra indices (optional)" help="Provide a comma-separated list of pseudospectra indices (e.g. 1,2,3)." />
</when>
</conditional>
<param name="convertRTMinute" type="boolean" checked="false" truevalue="TRUE" falsevalue="FALSE" label="Convert seconds to minutes when exporting tsv" />
<param name="numDigitsMZ" type="integer" value="4" max="4" min="0" label="Number of digits for MZ values (namecustom)" />
<param name="numDigitsRT" type="integer" value="4" max="4" min="0" label="Number of digits for RT values (namecustom)" />
Expand Down

0 comments on commit bc9d3de

Please sign in to comment.