# HG changeset patch # User recetox # Date 1697117454 0 # Node ID 09cabbc3d12db6f15f1f7cef6daa2b9093b57c3a # Parent 9b716db0a786eb8745908666b8dd2b147ca8c8df planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ramclustr commit b1cc1aebf796f170d93e3dd46ffcdefdc7b8018a diff -r 9b716db0a786 -r 09cabbc3d12d macros.xml --- a/macros.xml Tue Jun 27 14:29:37 2023 +0000 +++ b/macros.xml Thu Oct 12 13:30:54 2023 +0000 @@ -39,10 +39,13 @@ topic_3520 + + + ramclustr - +
diff -r 9b716db0a786 -r 09cabbc3d12d ramclustr.xml --- a/ramclustr.xml Tue Jun 27 14:29:37 2023 +0000 +++ b/ramclustr.xml Thu Oct 12 13:30:54 2023 +0000 @@ -1,15 +1,16 @@ - + A feature clustering algorithm for non-targeted mass spectrometric metabolomics data. macros.xml + operation_3557 operation_3435 operation_3432 operation_3465 - + @@ -157,7 +158,7 @@ - +
@@ -176,7 +177,7 @@ - +
@@ -197,7 +198,7 @@ - +
@@ -215,7 +216,7 @@ - +
@@ -224,7 +225,7 @@
- +
diff -r 9b716db0a786 -r 09cabbc3d12d ramclustr_wrapper.R --- a/ramclustr_wrapper.R Tue Jun 27 14:29:37 2023 +0000 +++ b/ramclustr_wrapper.R Thu Oct 12 13:30:54 2023 +0000 @@ -2,42 +2,42 @@ output_merge_msp, output_spec_abundance, msp_file) { - RAMClustR::write.msp(ramclustr_obj, one.file = output_merge_msp) - write.csv(ramclustr_obj$SpecAbund, - file = output_spec_abundance, - row.names = TRUE, quote = FALSE - ) + RAMClustR::write.msp(ramclustr_obj, one.file = output_merge_msp) + write.csv(ramclustr_obj$SpecAbund, + file = output_spec_abundance, + row.names = TRUE, quote = FALSE + ) - if (!is.null(msp_file)) { - exp_name <- ramclustr_obj$ExpDes[[1]][which( - row.names(ramclustr_obj$ExpDes[[1]]) == "Experiment" - ), 1] - filename <- paste("spectra/", exp_name, ".msp", sep = "") - file.copy(from = filename, to = msp_file, overwrite = TRUE) - } + if (!is.null(msp_file)) { + exp_name <- ramclustr_obj$ExpDes[[1]][which( + row.names(ramclustr_obj$ExpDes[[1]]) == "Experiment" + ), 1] + filename <- paste("spectra/", exp_name, ".msp", sep = "") + file.copy(from = filename, to = msp_file, overwrite = TRUE) + } } load_experiment_definition <- function(filename) { - experiment <- RAMClustR::defineExperiment(csv = filename) - return(experiment) + experiment <- RAMClustR::defineExperiment(csv = filename) + return(experiment) } read_metadata <- function(filename) { - data <- read.csv(filename, header = TRUE, stringsAsFactors = FALSE) + data <- read.csv(filename, header = TRUE, stringsAsFactors = FALSE) - if (!"qc" %in% colnames(data)) { - if ("sampleType" %in% colnames(data)) { - data$qc <- ifelse(data$sampleType == "qc", TRUE, FALSE) - } + if (!"qc" %in% colnames(data)) { + if ("sampleType" %in% colnames(data)) { + data$qc <- ifelse(data$sampleType == "qc", TRUE, FALSE) } + } - if (!"order" %in% colnames(data)) { - if ("injectionOrder" %in% colnames(data)) { - names(data)[names(data) == "injectionOrder"] <- "order" - } + if (!"order" %in% colnames(data)) { + if ("injectionOrder" %in% colnames(data)) { + names(data)[names(data) == "injectionOrder"] <- "order" } + } - return(data) + return(data) } read_ramclustr_aplcms <- function(ms1_featuredefinitions = NULL, @@ -47,41 +47,41 @@ exp_des = NULL, st = NULL, ensure_no_na = TRUE) { - ms1_featuredefinitions <- arrow::read_parquet(ms1_featuredefinitions) - ms1_featurevalues <- arrow::read_parquet(ms1_featurevalues) + ms1_featuredefinitions <- arrow::read_parquet(ms1_featuredefinitions) + ms1_featurevalues <- arrow::read_parquet(ms1_featurevalues) - if (!is.null(df_phenodata)) { - if (phenodata_ext == "csv") { - df_phenodata <- read.csv( - file = df_phenodata, - header = TRUE, check.names = FALSE - ) - } else { - df_phenodata <- read.csv( - file = df_phenodata, - header = TRUE, check.names = FALSE, sep = "\t" - ) - } + if (!is.null(df_phenodata)) { + if (phenodata_ext == "csv") { + df_phenodata <- read.csv( + file = df_phenodata, + header = TRUE, check.names = FALSE + ) + } else { + df_phenodata <- read.csv( + file = df_phenodata, + header = TRUE, check.names = FALSE, sep = "\t" + ) } - if (!is.null(exp_des)) { - exp_des <- load_experiment_definition(exp_des) - } + } + if (!is.null(exp_des)) { + exp_des <- load_experiment_definition(exp_des) + } - feature_values <- ms1_featurevalues[-1] - feature_values <- t(feature_values) - colnames(feature_values) <- ms1_featurevalues[[1]] - - feature_definitions <- data.frame(ms1_featuredefinitions) + feature_values <- ms1_featurevalues[-1] + feature_values <- t(feature_values) + colnames(feature_values) <- ms1_featurevalues[[1]] - ramclustr_obj <- RAMClustR::rc.get.df.data( - ms1_featureDefinitions = feature_definitions, - ms1_featureValues = feature_values, - phenoData = df_phenodata, - ExpDes = exp_des, - st = st, - ensure.no.na = ensure_no_na - ) - return(ramclustr_obj) + feature_definitions <- data.frame(ms1_featuredefinitions) + + ramclustr_obj <- RAMClustR::rc.get.df.data( + ms1_featureDefinitions = feature_definitions, + ms1_featureValues = feature_values, + phenoData = df_phenodata, + ExpDes = exp_des, + st = st, + ensure.no.na = ensure_no_na + ) + return(ramclustr_obj) } apply_normalisation <- function(ramclustr_obj = NULL, @@ -91,49 +91,49 @@ p_cut, rsq_cut, p_adjust) { - batch <- NULL - order <- NULL - qc <- NULL + batch <- NULL + order <- NULL + qc <- NULL - if (normalize_method == "TIC") { - ramclustr_obj <- RAMClustR::rc.feature.normalize.tic( - ramclustObj = - ramclustr_obj - ) - } else if (normalize_method == "quantile") { - ramclustr_obj <- RAMClustR::rc.feature.normalize.quantile(ramclustr_obj) - } else if (normalize_method == "batch.qc") { - if (!(is.null(metadata_file) || metadata_file == "None")) { - metadata <- read_metadata(metadata_file) - batch <- metadata$batch - order <- metadata$order - qc <- metadata$qc - } + if (normalize_method == "TIC") { + ramclustr_obj <- RAMClustR::rc.feature.normalize.tic( + ramclustObj = + ramclustr_obj + ) + } else if (normalize_method == "quantile") { + ramclustr_obj <- RAMClustR::rc.feature.normalize.quantile(ramclustr_obj) + } else if (normalize_method == "batch.qc") { + if (!(is.null(metadata_file) || metadata_file == "None")) { + metadata <- read_metadata(metadata_file) + batch <- metadata$batch + order <- metadata$order + qc <- metadata$qc + } - ramclustr_obj <- RAMClustR::rc.feature.normalize.batch.qc( - order = order, - batch = batch, - qc = qc, - ramclustObj = ramclustr_obj, - qc.inj.range = qc_inj_range - ) - } else { - if (!(is.null(metadata_file) || metadata_file == "None")) { - metadata <- read_metadata(metadata_file) - batch <- metadata$batch - order <- metadata$order - qc <- metadata$qc - } + ramclustr_obj <- RAMClustR::rc.feature.normalize.batch.qc( + order = order, + batch = batch, + qc = qc, + ramclustObj = ramclustr_obj, + qc.inj.range = qc_inj_range + ) + } else { + if (!(is.null(metadata_file) || metadata_file == "None")) { + metadata <- read_metadata(metadata_file) + batch <- metadata$batch + order <- metadata$order + qc <- metadata$qc + } - ramclustr_obj <- RAMClustR::rc.feature.normalize.qc( - order = order, - batch = batch, - qc = qc, - ramclustObj = ramclustr_obj, - p.cut = p_cut, - rsq.cut = rsq_cut, - p.adjust = p_adjust - ) - } - return(ramclustr_obj) + ramclustr_obj <- RAMClustR::rc.feature.normalize.qc( + order = order, + batch = batch, + qc = qc, + ramclustObj = ramclustr_obj, + p.cut = p_cut, + rsq.cut = rsq_cut, + p.adjust = p_adjust + ) + } + return(ramclustr_obj) }