Mercurial > repos > ethevenot > qualitymetrics
annotate easyrlibrary-lib/miniTools.R @ 0:b4f5b5bc01dd draft
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
| author | ethevenot | 
|---|---|
| date | Sat, 06 Aug 2016 12:01:17 -0400 | 
| parents | |
| children | 
| rev | line source | 
|---|---|
| 
0
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
1 ##################################################### | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
2 # Mini tools for Galaxy scripting | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
3 # Coded by: M.Petera, | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
4 # - - | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
5 # R functions to use in R scripts and wrappers | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
6 # to make things easier (lightening code, reducing verbose...) | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
7 # - - | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
8 # V0: script structure + first functions | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
9 # V1: addition of functions to handle special characters in identifiers | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
10 ##################################################### | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
11 | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
12 | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
13 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
14 # Function to call packages without printing all the verbose | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
15 # (only getting the essentials, like warning messages for example) | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
16 | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
17 shyLib <- function(...){ | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
18 for(i in 1:length(list(...))){ | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
19 suppressPackageStartupMessages(library(list(...)[[i]],character.only=TRUE)) | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
20 } | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
21 } | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
22 | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
23 #example: shyLib("xcms","pcaMethods") | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
24 | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
25 | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
26 | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
27 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
28 # Fonction pour sourcer les scripts R requis | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
29 # /!\ ATTENTION : actuellement la fonction n'est pas chargee au lancement du script, | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
30 # il faut donc la copier-coller dans le wrapper R pour pouvoir l'utiliser. | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
31 | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
32 if(FALSE){ | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
33 source_local <- function(...){ | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
34 argv <- commandArgs(trailingOnly = FALSE) | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
35 base_dir <- dirname(substring(argv[grep("--file=", argv)], 8)) | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
36 for(i in 1:length(list(...))){ | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
37 source(paste(base_dir, list(...)[[i]], sep="/")) | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
38 } | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
39 } | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
40 } | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
41 | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
42 #example: source_local("filter_script.R","RcheckLibrary.R") | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
43 | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
44 | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
45 | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
46 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
47 # Functions to stock identifiers before applying make.names() and | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
48 # to reinject it into final matrices | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
49 # Note: it reproduces the original order of datasets' identifiers | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
50 # - - - | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
51 # stockID: stocks original identifiers and original order | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
52 # -> needs checked data regarding table match | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
53 # reproduceID: reinjects original identifiers and original order into final tables | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
54 # -> function to be used at the very end, when exporting tables | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
55 | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
56 stockID <- function(dataMatrix, Metadata, Mtype){ | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
57 # dataMatrix = data.frame containing dataMatrix | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
58 # Metadata = data.frame containing sampleMetadata or variableMetadata | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
59 # Mtype = "sample" or "variable" depending on Metadata content | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
60 cname <- colnames(dataMatrix)[1] | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
61 # dataMatrix temporary-stock + transfo - - - - | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
62 if(Mtype=="sample"){ | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
63 id.ori <- colnames(dataMatrix)[-1] | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
64 colnames(dataMatrix) <- make.names(colnames(dataMatrix)) | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
65 } | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
66 if(Mtype=="variable"){ | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
67 id.ori <- dataMatrix[,1] | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
68 dataMatrix[,1] <- make.names(dataMatrix[,1]) | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
69 } | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
70 # global stock - - - - - - - - - - - - - - - - | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
71 id.new <- data.frame(order.ori=c(1:length(Metadata[,1])),Metadata[,1], | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
72 id.new=make.names(Metadata[,1]),id.ori, | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
73 id.new.DM=make.names(id.ori),stringsAsFactors=FALSE) | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
74 colnames(id.new)[c(2,4)] <- c(colnames(Metadata)[1],cname) | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
75 # Metadata transfo + returning data - - - - - | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
76 Metadata[,1] <- make.names(Metadata[,1]) | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
77 return(list(id.match=id.new, dataMatrix=dataMatrix, Metadata=Metadata)) | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
78 } | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
79 #example: A<-stockID(myDM,mysM,"sample") ; myDM<-A$dataMatrix ; mysM<-A$Metadata ; A<-A$id.match | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
80 | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
81 reproduceID <- function(dataMatrix, Metadata, Mtype, id.match){ | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
82 # dataMatrix = data.frame containing dataMatrix | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
83 # Metadata = data.frame containing sampleMetadata or variableMetadata | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
84 # Mtype = "sample" or "variable" depending on Metadata content | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
85 # id.match = 'id.match' element produced by stockID | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
86 #Metadada - - - - - - - - - - - - - - | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
87 temp.table <- id.match[,c(1,2,3)] | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
88 ## Removing deleted rows | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
89 for(i in 1:(dim(id.match)[1])){ | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
90 if(!(temp.table[i,3]%in%Metadata[,1])){temp.table[i,1] <- 0} | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
91 } | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
92 if(length(which(temp.table[,1]==0))!=0){ | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
93 temp.table <- temp.table[-c(which(temp.table[,1]==0)),] | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
94 } | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
95 ## Restoring original identifiers and order | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
96 temp.table <- merge(x=temp.table,y=Metadata,by.x=3,by.y=1) | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
97 temp.table <- temp.table[order(temp.table$order.ori),] | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
98 Metadata <- temp.table[,-c(1,2)] | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
99 rownames(Metadata) <- NULL | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
100 #dataMatrix - - - - - - - - - - - - - | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
101 rownames(dataMatrix)<-dataMatrix[,1] | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
102 if(Mtype=="sample"){ | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
103 dataMatrix <- t(dataMatrix[,-1]) | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
104 } | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
105 temp.table <- id.match[,c(1,4,5)] | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
106 ## Removing deleted rows | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
107 for(i in 1:(dim(id.match)[1])){ | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
108 if(!(temp.table[i,3]%in%rownames(dataMatrix))){temp.table[i,1] <- 0} | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
109 } | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
110 if(length(which(temp.table[,1]==0))!=0){ | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
111 temp.table <- temp.table[-c(which(temp.table[,1]==0)),] | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
112 } | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
113 ## Restoring original identifiers and order | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
114 temp.table <- merge(x=temp.table,y=dataMatrix,by.x=3,by.y=0) | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
115 temp.table <- temp.table[order(temp.table$order.ori),] | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
116 if(Mtype=="variable"){ | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
117 dataMatrix <- temp.table[,-c(1,2,4)] | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
118 colnames(dataMatrix)[1] <- colnames(id.match)[4] | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
119 } else { | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
120 rownames(temp.table) <- temp.table[,3] | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
121 temp.table <- t(temp.table[,-c(1,2,3)]) | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
122 dataMatrix <- data.frame(rownames(temp.table),temp.table) | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
123 colnames(dataMatrix)[1] <- colnames(id.match)[4] | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
124 } | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
125 rownames(dataMatrix) <- NULL | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
126 # return datasets - - - - - - - - - - - | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
127 return(list(dataMatrix=dataMatrix, Metadata=Metadata)) | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
128 } | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
129 #example: B<-reproduceID(myDM,mysM,"sample",A) ; myDM<-B$dataMatrix ; mysM<-B$Metadata | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
130 | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
131 | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
132 | 
| 
 
b4f5b5bc01dd
planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
 
ethevenot 
parents:  
diff
changeset
 | 
133 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 
