# HG changeset patch # User recetox # Date 1627473500 0 # Node ID 2bcfd5b450bb3fb2a69581dfdf49cd3022c7f14d # Parent 2461d20911c94e2c5119269f416073243b0f0b90 "planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/waveica commit c52cdb1ab3c4e65ce3b55e29739f16abb8bfd6eb" diff -r 2461d20911c9 -r 2bcfd5b450bb test-data/features-test.csv --- a/test-data/features-test.csv Thu Mar 18 15:53:38 2021 +0000 +++ b/test-data/features-test.csv Wed Jul 28 11:58:20 2021 +0000 @@ -1,4 +1,4 @@ -sample_name,class,sampleType,injectionOrder,batch,M85T34,M86T41,M86T518,M86T539 +sampleName,class,sampleType,injectionOrder,batch,M85T34,M86T41,M86T518,M86T539 VT_160120_002,sample,sample,1,1,228520.06430737,35646729.21543971,2386896.97966461,1026645.83653468 VT_160120_004,sample,sample,2,1,90217.384387202,35735702.457215995,2456290.69621518,1089246.46040563 VT_160120_006,sample,sample,3,1,235656.75288383896,37021134.452711605,8873450.40260241,837856.449608585 diff -r 2461d20911c9 -r 2bcfd5b450bb waveica.xml --- a/waveica.xml Thu Mar 18 15:53:38 2021 +0000 +++ b/waveica.xml Wed Jul 28 11:58:20 2021 +0000 @@ -1,4 +1,4 @@ - + removal of batch effects for untargeted metabolomics data diff -r 2461d20911c9 -r 2bcfd5b450bb waveica_wrapper.R --- a/waveica_wrapper.R Thu Mar 18 15:53:38 2021 +0000 +++ b/waveica_wrapper.R Wed Jul 28 11:58:20 2021 +0000 @@ -10,8 +10,12 @@ ) { # get input from the Galaxy, preprocess data - data <- read.csv(data, header = TRUE, row.names = "sample_name") - data <- preprocess_data(data) + data <- read.csv(data, header = TRUE, row.names = "sampleName") + + # sort data by injection order + data <- data[order(data$injectionOrder, decreasing = FALSE), ] + + data <- enumerate_groups(data) # remove blanks from dataset if (exclude_blanks) { @@ -39,14 +43,12 @@ } -# Sort data, set numerical values for groups -preprocess_data <- function(data) { - # sort data by injection order - data <- data[order(data$injectionOrder, decreasing = FALSE), ] +# Match group labels with [blank/sample/qc] and enumerate them +enumerate_groups <- function(data) { - data$class[data$class == "blank"] <- 0 - data$class[data$class == "sample"] <- 1 - data$class[data$class == "QC"] <- 2 + data$sampleType[grepl("blank", tolower(data$sampleType))] <- 0 + data$sampleType[grepl("sample", tolower(data$sampleType))] <- 1 + data$sampleType[grepl("qc", tolower(data$sampleType))] <- 2 return(data) } @@ -68,7 +70,7 @@ # Exclude blanks from a dataframe exclude_group <- function(data) { row_idx_to_exclude <- which(data$class %in% 0) - if (length(row_idx_to_exclude) > 1) { + if (length(row_idx_to_exclude) > 0) { data_without_blanks <- data[-c(row_idx_to_exclude), ] msg <- paste("Blank samples have been excluded from the dataframe.\n") cat(msg)