Mercurial > repos > lecorguille > xcms_export_samplemetadata
annotate xcms_export_samplemetadata.r @ 2:942ffa3c38b8 draft
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit ba2a5c2e962a95155c344dc1864a9c76eb565e9c
author | lecorguille |
---|---|
date | Tue, 09 Oct 2018 15:50:03 -0400 |
parents | 008aceb33627 |
children | 8c62030a1136 |
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) |
2
942ffa3c38b8
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit ba2a5c2e962a95155c344dc1864a9c76eb565e9c
lecorguille
parents:
1
diff
changeset
|
18 if (exists("raw_data")) xdata <- raw_data |
942ffa3c38b8
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit ba2a5c2e962a95155c344dc1864a9c76eb565e9c
lecorguille
parents:
1
diff
changeset
|
19 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.*") |
0
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
20 if (is.null(sampleMetadata)) |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
21 sampleMetadata <- xdata@phenoData@data |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
22 else |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
23 sampleMetadata <- rbind(sampleMetadata,xdata@phenoData@data) |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
24 } |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
25 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
|
26 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
|
27 |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
28 # Create a sampleMetada file |
e3c06320f884
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 67da3bb19bde72d5e78397e5627c176896234f86
lecorguille
parents:
diff
changeset
|
29 write.table(sampleMetadata,file="sampleMetadata.tsv", sep="\t", row.names=FALSE, quote=FALSE) |