Mercurial > repos > lecorguille > xcms_export_samplemetadata
annotate xcms_export_samplemetadata.r @ 1:008aceb33627 draft
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86-dirty
author | lecorguille |
---|---|
date | Tue, 09 Oct 2018 12:57:14 -0400 |
parents | e3c06320f884 |
children | 942ffa3c38b8 |
rev | line source |
---|---|
0
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
1 #!/usr/bin/env Rscript |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
2 |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
3 #Import the different functions |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
4 source_local <- function(fname){ argv <- commandArgs(trailingOnly=FALSE); base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)); source(paste(base_dir, fname, sep="/")) } |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
5 source_local("lib.r") |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
6 source_local("lib-xcms3.x.x.r") |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
7 |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
8 pkgs <- c("xcms","batch") |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
9 loadAndDisplayPackages(pkgs) |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
10 cat("\n\n"); |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
11 |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
12 args <- parseCommandArgs(evaluate=FALSE) #interpretation of arguments given in command line as an R list of objects |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
13 |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
14 |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
15 sampleMetadata <- NULL |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
16 for(image in args$images) { |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
17 load(image) |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
18 if (is.null(sampleMetadata)) |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
19 sampleMetadata <- xdata@phenoData@data |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
20 else |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
21 sampleMetadata <- rbind(sampleMetadata,xdata@phenoData@data) |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
22 } |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
23 colnames(sampleMetadata) <- c("sample_name","class") |
1
008aceb33627
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86-dirty
lecorguille
parents:
0
diff
changeset
|
24 sampleMetadata$sample_name <- make.names(sampleMetadata$sample_name) |
0
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
25 |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
26 # Create a sampleMetada file |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
27 write.table(sampleMetadata,file="sampleMetadata.tsv", sep="\t", row.names=FALSE, quote=FALSE) |