Mercurial > repos > lecorguille > xcms_export_samplemetadata
comparison xcms_export_samplemetadata.r @ 10:cdab04a1d1d7 draft default tip
planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics/ commit 2cb157bd9a8701a3d6874e084032cbd050b8953e
author | workflow4metabolomics |
---|---|
date | Mon, 11 Sep 2023 09:14:35 +0000 |
parents | 94eb263cfab4 |
children |
comparison
equal
deleted
inserted
replaced
9:94eb263cfab4 | 10:cdab04a1d1d7 |
---|---|
1 #!/usr/bin/env Rscript | 1 #!/usr/bin/env Rscript |
2 | 2 |
3 #Import the different functions | 3 #Import the different functions |
4 source_local <- function(fname) { | 4 source_local <- function(fname) { |
5 argv <- commandArgs(trailingOnly = FALSE); base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)); source(paste(base_dir, fname, sep = "/")) | 5 argv <- commandArgs(trailingOnly = FALSE) |
6 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)) | |
7 source(paste(base_dir, fname, sep = "/")) | |
6 } | 8 } |
7 source_local("lib.r") | 9 source_local("lib.r") |
8 | 10 |
9 pkgs <- c("xcms", "batch") | 11 pkgs <- c("xcms", "batch") |
10 loadAndDisplayPackages(pkgs) | 12 loadAndDisplayPackages(pkgs) |
11 cat("\n\n"); | 13 cat("\n\n") |
12 | 14 |
13 args <- parseCommandArgs(evaluate = FALSE) #interpretation of arguments given in command line as an R list of objects | 15 args <- parseCommandArgs(evaluate = FALSE) #interpretation of arguments given in command line as an R list of objects |
14 | 16 |
15 | 17 |
16 sampleMetadata <- NULL | 18 sampleMetadata <- NULL |
17 for (image in args$images) { | 19 for (image in args$images) { |
18 load(image) | 20 load(image) |
19 if (exists("raw_data")) xdata <- raw_data | 21 if (exists("raw_data")) xdata <- raw_data |
20 if (!exists("xdata")) stop("\n\nERROR: The RData doesn't contain any object called 'xdata'. This RData should have been created by an old version of XMCS 2.*") | 22 if (!exists("xdata")) stop("\n\nERROR: The RData doesn't contain any object called 'xdata'. This RData should have been created by an old version of XMCS 2.*") |
21 if (is.null(sampleMetadata)) | 23 if (is.null(sampleMetadata)) |
22 sampleMetadata <- xdata@phenoData@data | 24 sampleMetadata <- xdata@phenoData@data |
23 else | 25 else |
24 sampleMetadata <- rbind(sampleMetadata, xdata@phenoData@data) | 26 sampleMetadata <- rbind(sampleMetadata, xdata@phenoData@data) |
25 } | 27 } |
26 colnames(sampleMetadata) <- c("sample_name", "class") | 28 colnames(sampleMetadata) <- c("sample_name", "class") |
27 sampleMetadata$sample_name <- make.names(sampleMetadata$sample_name) | 29 sampleMetadata$sample_name <- make.names(sampleMetadata$sample_name) |
28 | 30 |
29 # Create a sampleMetada file | 31 # Create a sampleMetada file |