annotate qualitymetrics_script.R @ 2:596320b84315 draft

planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
author ethevenot
date Thu, 11 Jan 2018 12:52:08 -0500
parents 6d3b7b6573d8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 # ANALYSES FOR QUALITY CONTROL #
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
3 # #
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
4 # Author: Melanie PETERA #
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
5 # User: Galaxy #
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
6 # Starting date: 04-09-2014 #
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
7 # V-1.0: Restriction of old filter script to CV filter #
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
8 # V-1.1: Addition of data check #
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
9 # V-1.2: Substitution of deletion by addition of indicator variable #
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
10 # V-1.3: Handling special characters #
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 # Input files: dataMatrix ; sampleMetadata ; variableMetadata #
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
14 # Output files: dataMatrix ; sampleMetadata ; variableMetadata #
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
15 # #
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
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
18 # Parameters (for dev)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
19 if(FALSE){
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 ion.file.in <- "test/ressources/inputs/ex_data_IONS.txt" #tab file
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
22 meta.samp.file.in <- "test/ressources/inputs/ex_data_PROTOCOLE1.txt" #tab file
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
23 meta.ion.file.in <- "test/ressources/inputs/ex_data_METAION.txt" #tab file
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 ## ion.file.out <- "test/ressources/outputs/QCtest_ex_data_IONS.txt" #tab file
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
26 meta.samp.file.out <- "test/ressources/outputs/QCtest_ex_data_PROTOCOLE1.txt" #tab file
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
27 meta.ion.file.out <- "test/ressources/outputs/QCtest_ex_data_METAION.txt" #tab file
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
28
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
29 CV <- TRUE ; if(CV){Compa<-TRUE;seuil<-1.25}else{Compa<-NULL;seuil<-NULL}
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
30
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
31 poolAsPool1L <- FALSE
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
32
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
33 if(FALSE) { ## Sacuri dataset
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
34
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
35 ## 'example' input dir
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
36 exaDirInpC <- "example/input"
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
37
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
38 ion.file.in <- file.path(exaDirInpC, "dataMatrix.tsv")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
39 meta.samp.file.in <- file.path(exaDirInpC, "sampleMetadata.tsv")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
40 meta.ion.file.in <- file.path(exaDirInpC, "variableMetadata.tsv")
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 poolAsPool1L <- FALSE
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 ## 'example' output dir
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
45 exaDirOutC <- gsub("input", "output", exaDirInpC)
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 mata.samp.file.out <- file.path(exaDirOutC, "sampleMetadata.tsv")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
48 meta.ion.file_out <- file.path(exaDirOutC, "variableMetadata.tsv")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
49 fig.out <- file.path(exaDirOutC, "figure.pdf")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
50 log.out <- file.path(exaDirOutC, "information.txt")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
51
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
52 stopifnot(file.exists(exaDirOutC))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
53
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
54 }
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 }
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
57
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
58 QualityControl <- function(ion.file.in, meta.samp.file.in, meta.ion.file.in,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
59 CV, Compa, seuil, poolAsPool1L,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
60 ion.file.out, meta.samp.file.out, meta.ion.file.out, fig.out, log.out){
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
61 # This function allows to analyse data to check its quality
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
62 # It needs 3 datasets: the data matrix, the variables' metadata, the samples' metadata.
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
63 # It generates 3 new datasets corresponding to the 3 inputs with additional columns.
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
64 #
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
65 # Parameters:
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
66 # - xxx.in: input files' names
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
67 # - xxx.out: output files' names
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
68 # - CV: CV calculation yes/no
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
69 # | > Compa: comparing pool and sample CVs (TRUE) or simple pool CV calculation (FALSE)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
70 # | > seuil: maximum ratio tolerated between pool and sample CVs or maximum pool CV
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
71
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
72
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
73 # Input -----------------------------------------------------------------------------------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
74
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
75 ion.data <- read.table(ion.file.in,sep="\t",header=TRUE,check.names=FALSE, stringsAsFactors = FALSE)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
76 meta.samp.data <- read.table(meta.samp.file.in,sep="\t",header=TRUE,check.names=FALSE, stringsAsFactors = FALSE)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
77 meta.ion.data <- read.table(meta.ion.file.in,sep="\t",header=TRUE,check.names=FALSE, stringsAsFactors = FALSE)
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 # Error vector
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
80 err.stock <- "\n"
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
81
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
82 # Table match check
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
83 table.check <- match3(ion.data,meta.samp.data,meta.ion.data)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
84 check.err(table.check)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
85
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
86 # StockID
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
87 samp.id <- stockID(ion.data,meta.samp.data,"sample")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
88 ion.data <- samp.id$dataMatrix
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
89 meta.samp.data <- samp.id$Metadata
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
90 samp.id <- samp.id$id.match
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
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
93 # Function 1: CV calculation --------------------------------------------------------------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
94 # Allows to class ions according to the Coefficient of Variation (CV):
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
95 # Compa=TRUE:
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
96 # CV of pools and CV of samples are compared (ration between pools' one and samples' one)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
97 # and confronted to a given ration.
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
98 # Compa=FALSE:
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
99 # only CV of pools are considered ; compared to a given threshold
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
100
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
101 if(CV){
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
102
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
103 # Checking the sampleType variable
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
104 if(is.null(meta.samp.data$sampleType)){
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
105 err.stock <- c(err.stock,"\n-------",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
106 "\nWarning : no 'sampleType' variable detected in sample meta-data !",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
107 "\nCV can not be calculated.\n-------\n")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
108 }else{
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
109 if(!("pool"%in%levels(factor(meta.samp.data$sampleType)))){
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
110 err.stock <- c(err.stock,"\n-------",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
111 "\nWarning : no 'pool' detected in 'sampleType' variable (sample meta-data) !",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
112 "\nCV can not be calculated.\n-------\n")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
113 }else{
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
114 if((!("sample"%in%levels(factor(meta.samp.data$sampleType))))&(Compa)){
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
115 err.stock <- c(err.stock,"\n-------",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
116 "\nWarning : no 'sample' detected in 'sampleType' variable (sample meta-data) !",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
117 "\nCV can not be calculated.\n-------\n")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
118 }else{
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
119
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
120 # Statement
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
121 tmp.ion <- data.frame(CV.ind=rep(NA,nrow(ion.data)),CV.samp=rep(NA,nrow(ion.data)),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
122 CV.pool=rep(NA,nrow(ion.data)),ion.data,stringsAsFactors=FALSE)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
123 # CV samples
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
124 tmp.samp <- which(colnames(tmp.ion)%in%meta.samp.data[which(meta.samp.data$sampleType=="sample"),1])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
125 tmp.ion$CV.samp <- apply(tmp.ion[,tmp.samp],1,function(x)sd(x, na.rm = TRUE)) / rowMeans(tmp.ion[,tmp.samp], na.rm = TRUE)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
126 tmp.ion$CV.samp[which(apply(tmp.ion[,tmp.samp],1,function(x)sd(x, na.rm = TRUE))==0)] <- 0
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
127 # CV pools
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
128 tmp.samp <- which(colnames(tmp.ion)%in%meta.samp.data[which(meta.samp.data$sampleType=="pool"),1])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
129 tmp.ion$CV.pool <- apply(tmp.ion[,tmp.samp],1,function(x)sd(x, na.rm = TRUE)) / rowMeans(tmp.ion[,tmp.samp], na.rm = TRUE)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
130 tmp.ion$CV.pool[which(apply(tmp.ion[,tmp.samp],1,function(x)sd(x, na.rm = TRUE))==0)] <- 0
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
131 # CV indicator
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
132 if(Compa){tmp.ion$CV.ind <- ifelse((tmp.ion$CV.pool)/(tmp.ion$CV.samp)>seuil,0,1)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
133 }else{tmp.ion$CV.ind <- ifelse((tmp.ion$CV.pool)>seuil,0,1)}
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
134 # Addition of new columns in meta.ion.data
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
135 if(Compa){tmp.ion<-tmp.ion[,c(4,2,3,1,1)]}else{tmp.ion<-tmp.ion[,c(4,3,1,1)]}
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
136 tmp.ion[,ncol(tmp.ion)] <- 1:nrow(tmp.ion)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
137 meta.ion.data <- merge(x=meta.ion.data,y=tmp.ion,by.x=1,by.y=1)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
138 meta.ion.data <- meta.ion.data[order(meta.ion.data[,ncol(meta.ion.data)]),][,-ncol(meta.ion.data)]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
139 rownames(meta.ion.data) <- NULL
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
140
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
141 rm(tmp.ion,tmp.samp)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
142
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
143 }}}
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
144
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
145 } # end if(CV)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
146
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
147 ## complementary metrics (ET)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
148
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
149 datMN <- t(as.matrix(ion.data[, -1]))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
150 colnames(datMN) <- ion.data[, 1]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
151 datMN <- datMN[, meta.ion.data[, 1]] ## in case meta.ion.data has been re-ordered during the CV = TRUE computations
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
152 quaLs <- qualityMetricsF(datMN,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
153 meta.samp.data,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
154 meta.ion.data,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
155 poolAsPool1L,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
156 fig.out,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
157 log.out)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
158 meta.samp.data <- quaLs[["samDF"]]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
159 meta.ion.data <- quaLs[["varDF"]]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
160
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
161
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
162 # Output ----------------------------------------------------------------------------------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
163
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
164 # Getting back original identifiers
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
165 id.ori <- reproduceID(ion.data,meta.samp.data,"sample",samp.id)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
166 ion.data <- id.ori$dataMatrix
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
167 meta.samp.data <- id.ori$Metadata
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
168
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
169
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
170 # Error checking
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
171 if(length(err.stock)>1){
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
172 stop(err.stock)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
173 }else{
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
174
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
175 ## write.table(ion.data, ion.file.out, sep="\t", row.names=FALSE, quote=FALSE)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
176 write.table(meta.samp.data, meta.samp.file.out, sep="\t", row.names=FALSE, quote=FALSE)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
177 write.table(meta.ion.data, meta.ion.file.out, sep="\t", row.names=FALSE, quote=FALSE)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
178
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
179 }
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
180
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
181
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
182 } # end of QualityControl function
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
183
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
184
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
185 # Typical function call
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
186 # QualityControl(ion.file.in, meta.samp.file.in, meta.ion.file.in,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
187 # CV, Compa, seuil,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
188 # ion.file.out, meta.samp.file.out, meta.ion.file.out)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
189
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
190
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
191 qualityMetricsF <- function(datMN,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
192 samDF,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
193 varDF,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
194 pooAsPo1L = TRUE,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
195 fig.pdfC = NULL,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
196 log.txtC = NULL) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
197
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
198 optWrnN <- options()$warn
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
199 options(warn = -1)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
200
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
201
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
202 ##------------------------------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
203 ## Functions
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
204 ##------------------------------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
205
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
206
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
207 allDigF <- function (string) { ## from the Hmisc package (all.digits)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
208 k <- length(string)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
209 result <- logical(k)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
210 for (i in 1:k) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
211 st <- string[i]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
212 ls <- nchar(st)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
213 ex <- substring(st, 1:ls, 1:ls)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
214 result[i] <- all(match(ex, c("0", "1", "2", "3", "4",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
215 "5", "6", "7", "8", "9"), nomatch = 0) > 0)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
216 }
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
217 result
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
218 }
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
219
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
220 datPloF <- function() { ## ploting data matrix
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
221
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
222 thrVn <- c(pvalue=0.001,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
223 poolCv=0.3)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
224
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
225 ## Constants
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
226
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
227 marLs <- list(dri = c(2.1, 2.6, 1.1, 1.1),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
228 ima = c(1.1, 2.6, 4.1, 1.1),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
229 msd = c(2.1, 2.6, 1.1, 0.6),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
230 sam = c(3.1, 3.6, 1.1, 0.6),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
231 pca = c(2.6, 3.6, 1.1, 0.6),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
232 sca = c(1.1, 4.1, 4.1, 0.6),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
233 tit = c(0.1, 0.6, 1.1, 0.6))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
234 palHeaVc <- rev(rainbow(ceiling(256 * 1.5))[1:256])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
235
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
236 ## Functions
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
237
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
238 axiPreF <- function(valVn,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
239 lenN) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
240
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
241 if(NA %in% valVn) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
242 warning("NA in valVn")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
243 valVn <- as.vector(na.omit(valVn))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
244 }
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
245
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
246 if(lenN < length(valVn))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
247 stop("The length of in vector must be inferior to the length of the length parameter.")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
248
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
249 if(length(valVn) < lenN)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
250 valVn <- seq(from = min(valVn), to = max(valVn), length.out = lenN)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
251
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
252 preValVn <- pretty(valVn)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
253
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
254 preLabVn <- preAtVn <- c()
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
255
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
256 for(n in 1:length(preValVn))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
257 if(min(valVn) < preValVn[n] && preValVn[n] < max(valVn)) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
258 preLabVn <- c(preLabVn, preValVn[n])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
259 preAtVn <- c(preAtVn, which(abs(valVn - preValVn[n]) == min(abs(valVn - preValVn[n])))[1])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
260 }
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
261
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
262 return(list(atVn = preAtVn,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
263 labVn = preLabVn))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
264
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
265 }
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
266
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
267 colF <- function(vecVn)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
268 sapply(vecVn,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
269 function(outN) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
270 if(outN < ploRgeVn[1])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
271 return(palHeaVc[1])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
272 else if(outN > ploRgeVn[2])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
273 return(palHeaVc[256])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
274 else return(palHeaVc[round((outN - ploRgeVn[1]) / diff(ploRgeVn) * 256 + 1)])})
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
275
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
276 obsColF <- function(typVc) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
277
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
278 ## available color palette
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
279 palVc <- palette()
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
280
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
281 ## colors for common types are set aside
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
282 palVc <- palVc[!(palVc %in% c("black", "red", "green3"))]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
283
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
284 ## filling in the types with dedicated colors
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
285 samTypVc <- sort(unique(samDF[, "sampleType"]))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
286 samColVc <- character(length(samTypVc))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
287 if("blank" %in% samTypVc)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
288 samColVc[grepl("blank", samTypVc)] <- "black"
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
289 if("pool" %in% samTypVc)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
290 samColVc[grepl("pool", samTypVc)] <- "red"
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
291 if("sample" %in% samTypVc)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
292 samColVc[grepl("sample", samTypVc)] <- "green4"
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
293
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
294 ## filling in the other types
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
295 palColI <- 1
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
296 palColMaxI <- length(palVc)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
297
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
298 while(any(samColVc == "")) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
299 typToColI <- which(samColVc == "")[1]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
300 if(palColI <= palColMaxI)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
301 samColVc[typToColI] <- palVc[palColI]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
302 else
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
303 samColVc[typToColI] <- "gray"
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
304 palColI <- palColI + 1
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
305 }
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
306
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
307 names(samColVc) <- samTypVc
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
308
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
309 samColVc[typVc]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
310
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
311 }
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
312
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
313 par(font = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
314 font.axis = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
315 font.lab = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
316 pch=18)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
317
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
318 layout(matrix(c(1, 3, 4, 5, 5,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
319 1, 7, 7, 7, 6,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
320 2, 7, 7, 7, 6),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
321 byrow = TRUE,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
322 nrow = 3),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
323 heights = c(1.8, 1.2, 2.5),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
324 widths = c(3.5, 1.8, 2.8, 1, 0.8))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
325
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
326 ## Colors
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
327 ##-------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
328
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
329 if("sampleType" %in% colnames(samDF)) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
330 obsColVc <- obsColF(samDF[, "sampleType"])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
331 } else
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
332 obsColVc <- rep("black", nrow(samDF))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
333
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
334 ## PCA and Hotelling ellipse
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
335 ##--------------------------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
336
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
337 vVn <- getPcaVarVn(ropLs)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
338 vRelVn <- vVn / ncol(datMN)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
339
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
340 par(mar = marLs[["pca"]])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
341
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
342 plot(ropScoreMN,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
343 type = "n",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
344 xlab = "",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
345 ylab = "",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
346 xlim = range(ropScoreMN[, 1]) * 1.1)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
347 mtext(paste("t1 (", round(vRelVn[1] * 100), "%)", sep = ""),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
348 cex = 0.7,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
349 line = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
350 side = 1)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
351 mtext(paste("t2 (", round(vRelVn[2] * 100), "%)", sep = ""),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
352 cex = 0.7,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
353 las = 0,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
354 line = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
355 side = 2)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
356 abline(h = 0, lty = "dashed")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
357 abline(v = 0, lty = "dashed")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
358 radVn <- seq(0, 2 * pi, length.out = 100)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
359
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
360 hotFisN <- hotN * qf(1 - thrVn["pvalue"], 2, n - 2)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
361 lines(sqrt(var(ropScoreMN[, 1]) * hotFisN) * cos(radVn),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
362 sqrt(var(ropScoreMN[, 2]) * hotFisN) * sin(radVn))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
363
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
364 text(ropScoreMN[, 1],
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
365 ropScoreMN[, 2],
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
366 cex = 0.7,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
367 col = obsColVc,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
368 labels = rownames(datMN))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
369
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
370 if("sampleType" %in% colnames(samDF)) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
371 obsColVuc <- obsColVc[sort(unique(names(obsColVc)))]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
372 legOrdVc <- c("blank", paste0("pool", 8:1), "pool", "other", "sample")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
373 obsColVuc <- obsColVuc[legOrdVc[legOrdVc %in% names(obsColVuc)]]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
374
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
375 text(rep(par("usr")[1], times = length(obsColVuc)),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
376 par("usr")[3] + (0.97 - length(obsColVuc) * 0.03 + 1:length(obsColVuc) * 0.03) * diff(par("usr")[3:4]),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
377 col = obsColVuc,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
378 font = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
379 labels = names(obsColVuc),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
380 pos = 4)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
381 }
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
382
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
383 ## Missing/low intensities and decile values
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
384 ##------------------------------------------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
385
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
386 par(mar = marLs[["sam"]])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
387
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
388 plot(missZscoVn,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
389 deciZscoMaxVn,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
390 type = "n",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
391 xlab = "",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
392 ylab = "",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
393 xlim = c(min(missZscoVn),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
394 max(missZscoVn) + 0.5))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
395 mtext("amount of missing values (z-score)",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
396 cex = 0.7,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
397 line = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
398 side = 1)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
399 mtext("deciles (zscore)",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
400 cex = 0.7,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
401 las = 0,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
402 line = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
403 side = 2)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
404 abline(h = qnorm(1 - thrVn["pvalue"] / 2) * c(-1, 1), lty = "dashed")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
405 abline(v = qnorm(1 - thrVn["pvalue"] / 2) * c(-1, 1), lty = "dashed")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
406 text(missZscoVn,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
407 deciZscoMaxVn,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
408 cex = 0.7,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
409 col = obsColVc,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
410 labels = rownames(datMN))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
411
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
412 ## tit: Title
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
413 ##-----------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
414
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
415 par(mar = marLs[["tit"]])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
416 plot(0:1, bty = "n", type = "n", xaxt = "n", yaxt = "n", xlab = "", ylab = "")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
417 text(1.5, 1, cex = 1.3, labels = "Quality Metrics")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
418 text(1, 0.85, adj=0, cex = 1.1, labels = paste0("NAs: ",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
419 round(length(which(is.na(c(datMN)))) / cumprod(dim(datMN))[2] * 100), "%"))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
420 text(1, 0.75, adj=0, cex = 1.1, labels = paste0("0 values: ",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
421 round(sum(abs(datMN) < epsN, na.rm=TRUE) / cumprod(dim(datMN))[2] * 100, 2), "%"))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
422 text(1, 0.65, adj=0, cex = 1.1, labels = paste0("min: ", signif(min(datMN, na.rm=TRUE), 2)))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
423 text(1, 0.55, adj=0, cex = 1.1, labels = paste0("median: ", signif(median(datMN, na.rm=TRUE), 2)))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
424 text(1, 0.45, adj=0, cex = 1.1, labels = paste0("mean: ", signif(mean(datMN, na.rm=TRUE), 2)))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
425 text(1, 0.35, adj=0, cex = 1.1, labels = paste0("max: ", signif(max(datMN, na.rm=TRUE), 2)))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
426 if("sampleType" %in% colnames(samDF) &&
1
6d3b7b6573d8 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 60328240b89497f9dc7633b10b2a550b10da00c7
ethevenot
parents: 0
diff changeset
427 "pool" %in% samDF[, "sampleType"]) {
6d3b7b6573d8 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 60328240b89497f9dc7633b10b2a550b10da00c7
ethevenot
parents: 0
diff changeset
428 poolCvNanVl <- is.nan(varDF[, "pool_CV"])
0
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
429 text(1,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
430 0.25,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
431 adj=0, cex = 1.1,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
432 labels = paste0("pool CV < ",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
433 round(thrVn["poolCv"] * 100), "%: ",
1
6d3b7b6573d8 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 60328240b89497f9dc7633b10b2a550b10da00c7
ethevenot
parents: 0
diff changeset
434 round(sum(varDF[!poolCvNanVl, "pool_CV", drop = FALSE] < thrVn["poolCv"]) / nrow(varDF) * 100),
0
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
435 "%"))
1
6d3b7b6573d8 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 60328240b89497f9dc7633b10b2a550b10da00c7
ethevenot
parents: 0
diff changeset
436 }
0
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
437
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
438 text(1, 0.1, adj=0, labels = paste0("Thresholds used in plots:"))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
439 text(1, 0, adj=0, labels = paste0(" p-value = ", thrVn["pvalue"]))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
440
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
441 ## dri: Analytical drift
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
442 ##----------------------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
443
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
444 par(mar = marLs[["dri"]])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
445
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
446 ## ordering
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
447
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
448 driDatMN <- datMN
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
449 driSamDF <- samDF
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
450
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
451 driSamDF[, "ordIniVi"] <- 1:nrow(driDatMN)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
452
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
453 if("injectionOrder" %in% colnames(driSamDF)) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
454 if("batch" %in% colnames(driSamDF))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
455 ordVi <- order(driSamDF[, "batch"],
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
456 driSamDF[, "injectionOrder"])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
457 else
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
458 ordVi <- order(driSamDF[, "injectionOrder"])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
459 } else
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
460 ordVi <- 1:nrow(driDatMN)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
461
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
462 driDatMN <- driDatMN[ordVi, ]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
463 driSamDF <- driSamDF[ordVi, ]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
464
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
465 driColVc <- rep("black", nrow(driDatMN))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
466 if("sampleType" %in% colnames(driSamDF))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
467 driColVc <- obsColF(driSamDF[, "sampleType"])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
468
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
469 plot(rowSums(driDatMN, na.rm=TRUE),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
470 col = driColVc,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
471 pch = 18,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
472 xlab = "",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
473 ylab = "")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
474
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
475 mtext("injection order",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
476 cex = 0.7,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
477 line = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
478 side = 1)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
479
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
480 mtext("Sum of intens. for all variables",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
481 cex = 0.7,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
482 line = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
483 side = 2)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
484
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
485 ## msd: Sd vs Mean plot
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
486 ##---------------------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
487
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
488 par(mar = marLs[["msd"]])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
489 plot(apply(datMN, 2, function(y) mean(y, na.rm = TRUE)),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
490 apply(datMN, 2, function(y) sd(y, na.rm = TRUE)),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
491 pch = 18,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
492 xlab = "",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
493 ylab = "")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
494 mtext("mean",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
495 cex = 0.7,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
496 line = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
497 side = 1)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
498 mtext("sd",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
499 cex = 0.7,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
500 line = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
501 side = 2)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
502
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
503 ## sca-6: Color scale
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
504 ##-------------------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
505
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
506 par(mar = marLs[["sca"]])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
507
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
508 ylimVn <- c(0, 256)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
509 ybottomVn <- 0:255
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
510 ytopVn <- 1:256
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
511
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
512 plot(x = 0,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
513 y = 0,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
514 font.axis = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
515 font.lab = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
516 type = "n",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
517 xlim = c(0, 1),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
518 ylim = ylimVn,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
519 xlab = "",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
520 ylab = "",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
521 xaxs = "i",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
522 yaxs = "i",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
523 xaxt = "n",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
524 yaxt = "n")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
525
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
526 rect(xleft = 0,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
527 ybottom = ybottomVn,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
528 xright = 1,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
529 ytop = ytopVn,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
530 col = palHeaVc,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
531 border = NA)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
532
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
533 eval(parse(text = paste("axis(at = axiPreF(c(ifelse(min(datMN, na.rm = TRUE) == -Inf, yes = 0, no = min(datMN, na.rm = TRUE)) , max(datMN, na.rm = TRUE)), 256)$atVn,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
534 font = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
535 font.axis = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
536 labels = axiPreF(c(ifelse(min(datMN, na.rm = TRUE) == -Inf, yes = 0, no = min(datMN, na.rm = TRUE)), max(datMN, na.rm = TRUE)), 256)$labVn,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
537 las = 1,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
538 lwd = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
539 lwd.ticks = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
540 side = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
541 xpd = TRUE)", sep = "")))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
542
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
543 arrows(par("usr")[1],
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
544 par("usr")[4],
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
545 par("usr")[1],
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
546 par("usr")[3],
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
547 code = 0,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
548 lwd = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
549 xpd = TRUE)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
550
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
551 ## ima: Image
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
552 ##-----------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
553
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
554 par(mar = marLs[["ima"]])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
555
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
556 ploRgeVn <- range(datMN, na.rm = TRUE)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
557
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
558 imaMN <- t(datMN)[, rev(1:nrow(datMN)), drop = FALSE]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
559
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
560 image(x = 1:nrow(imaMN),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
561 y = 1:ncol(imaMN),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
562 z = imaMN,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
563 col = palHeaVc,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
564 font.axis = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
565 font.lab = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
566 xaxt = "n",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
567 yaxt = "n",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
568 xlab = "",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
569 ylab = "")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
570
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
571 if(length(rownames(datMN)) == 0) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
572 rowNamVc <- rep("", times = nrow(datMN))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
573 } else
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
574 rowNamVc <- rownames(datMN)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
575
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
576 if(length(colnames(datMN)) == 0) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
577 colNamVc <- rep("", times = ncol(datMN))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
578 } else
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
579 colNamVc <- colnames(datMN)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
580
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
581 xlaVc <- paste(paste(rep("[", 2),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
582 c(1, nrow(imaMN)),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
583 rep("] ", 2),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
584 sep = ""),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
585 rep("\n", times = 2),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
586 c(colNamVc[1], tail(colNamVc, 1)),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
587 sep = "")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
588
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
589 for(k in 1:2)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
590 axis(side = 3,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
591 hadj = c(0, 1)[k],
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
592 at = c(1, nrow(imaMN))[k],
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
593 cex = 0.8,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
594 font = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
595 labels = xlaVc[k],
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
596 line = -0.5,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
597 tick = FALSE)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
598
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
599
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
600 ylaVc <- paste(paste(rep("[", times = 2),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
601 c(ncol(imaMN), 1),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
602 rep("]", times = 2),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
603 sep = ""),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
604 rep("\n", times = 2),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
605 c(tail(rowNamVc, 1), rowNamVc[1]),
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
606 sep = "")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
607
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
608 for(k in 1:2)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
609 axis(side = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
610 at = c(1, ncol(imaMN))[k],
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
611 cex = 0.8,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
612 font = 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
613 hadj = c(0, 1)[k],
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
614 labels = ylaVc[k],
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
615 las = 0,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
616 line = -0.5,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
617 lty = "blank",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
618 tick = FALSE)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
619
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
620 box(lwd = 2)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
621
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
622
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
623 }
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
624
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
625
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
626 zScoreF <- function(x) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
627 sdxN <- sd(x, na.rm = TRUE)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
628 if(sdxN < epsN)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
629 return(rep(0, length(x)))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
630 else
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
631 return((x - mean(x, na.rm = TRUE)) / sdxN)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
632 }
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
633
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
634
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
635 ## Option
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
636 ##-------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
637
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
638 strAsFacL <- options()$stringsAsFactors
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
639 options(stingsAsFactors = FALSE)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
640
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
641 ## Constants
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
642 ##----------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
643
2
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
644 modNamC <- "Quality Metrics" ## module name
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
645
0
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
646 epsN <- .Machine[["double.eps"]] ## [1] 2.22e-16
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
647
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
648
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
649 ##------------------------------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
650 ## Start
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
651 ##------------------------------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
652
2
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
653 if(!is.null(log.txtC)) {
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
654
0
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
655 sink(log.txtC)
2
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
656
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
657 cat("\nStart of the '", modNamC, "' Galaxy module call: ",
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
658 format(Sys.time(), "%a %d %b %Y %X"), "\n", sep="")
0
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
659
2
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
660 }
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
661
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
662
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
663 ## Checking the numerical type of the dataMatrix
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
664 ##----------------------------------------------
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
665
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
666
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
667 if(mode(datMN) != "numeric") {
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
668 sink()
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
669 stop("dataMatrix is not of numeric type;\ncheck your tables with the Check Format module\n",
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
670 call. = FALSE)
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
671 }
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
672
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
673
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
674 ## Re-ordering dataMatrix samples if need (internally only)
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
675 ##---------------------------------------------------------
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
676
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
677
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
678 if(!identical(rownames(datMN), samDF[, 1])) {
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
679
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
680 cat("\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\nThe sample order is not identical in dataMatrix and sampleMetadata;\nRe-ordering of the dataMatrix samples will be performed internally in this module\nfor the computation of the metrics,\nwithout changing the orders in the sampleMetadata output;\n\nTo get a re-ordered dataMatrix as output, please use the Check Format module\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
681
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
682 datMN <- datMN[samDF[, 1], , drop = FALSE]
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
683
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
684 }
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
685
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
686
0
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
687 ## Description
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
688 ##------------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
689
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
690 cat("\n\nData description:\n\n", sep = "")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
691 cat("observations:", nrow(datMN), "\n")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
692 cat("variables:", ncol(datMN), "\n")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
693 cat("missing:", sum(is.na(datMN)), "\n")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
694 cat("0 values (%):",
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
695 sum(abs(datMN) < epsN, na.rm=TRUE) / cumprod(dim(datMN))[2] * 100, "\n")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
696 cat("min:", min(datMN, na.rm=TRUE), "\n")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
697 cat("mean:", signif(mean(datMN, na.rm=TRUE), 2), "\n")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
698 cat("median:", signif(median(datMN, na.rm=TRUE), 2), "\n")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
699 cat("max:", signif(max(datMN, na.rm=TRUE), 2), "\n")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
700
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
701 if("sampleType" %in% colnames(samDF)) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
702 cat("\nSample types:\n", sep = "")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
703 print(table(samDF[, "sampleType"]))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
704 cat("\n", sep="")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
705 }
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
706
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
707
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
708 ##------------------------------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
709 ## Variable metrics
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
710 ##------------------------------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
711
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
712
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
713 ## 'blank' observations
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
714
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
715 if("sampleType" %in% colnames(samDF) && "blank" %in% samDF[, "sampleType"]) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
716
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
717 cat("\nVariables: Blank mean, sd, and CV\n", sep="")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
718
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
719 blkVl <- samDF[, "sampleType"] == "blank"
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
720
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
721 if(sum(blkVl) == 1)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
722 varDF[, "blank_mean"] <- datMN[blkVl, ]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
723 else
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
724 varDF[, "blank_mean"] <- apply(datMN[blkVl, , drop=FALSE], 2, function(varVn) mean(varVn, na.rm=TRUE))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
725
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
726 if(sum(blkVl) == 1)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
727 varDF[, "blank_sd"] <- rep(0, nrow(varDF))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
728 else
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
729 varDF[, "blank_sd"] <- apply(datMN[blkVl, , drop=FALSE], 2, function(varVn) sd(varVn, na.rm=TRUE))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
730
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
731 varDF[, "blank_CV"] <- varDF[, "blank_sd"] / varDF[, "blank_mean"]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
732
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
733 }
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
734
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
735
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
736 ## 'sample' observations
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
737
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
738 if("sampleType" %in% colnames(samDF) && "sample" %in% samDF[, "sampleType"]) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
739
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
740 cat("\nVariables: Sample mean, sd, and CV\n", sep="")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
741
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
742 samVl <- samDF[, "sampleType"] == "sample"
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
743
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
744 if(sum(samVl) == 1)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
745 varDF[, "sample_mean"] <- datMN[samVl, ]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
746 else
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
747 varDF[, "sample_mean"] <- apply(datMN[samVl, , drop=FALSE], 2, function(varVn) mean(varVn, na.rm=TRUE))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
748
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
749 if(sum(samVl) == 1)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
750 varDF[, "sample_sd"] <- rep(0, nrow(varDF))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
751 else
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
752 varDF[, "sample_sd"] <- apply(datMN[samVl, , drop=FALSE], 2, function(varVn) sd(varVn, na.rm=TRUE))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
753
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
754 varDF[, "sample_CV"] <- varDF[, "sample_sd"] / varDF[, "sample_mean"]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
755
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
756 }
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
757
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
758 ## 'blank' mean / 'sample' mean ratio
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
759
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
760 if(all(c("blank_mean", "sample_mean") %in% colnames(varDF))) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
761
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
762 cat("\nVariables: Blank mean over sample mean\n", sep="")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
763
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
764 varDF[, "blankMean_over_sampleMean"] <- varDF[, "blank_mean"] / varDF[, "sample_mean"]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
765
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
766 }
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
767
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
768 ## 'pool' observations
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
769
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
770 if("sampleType" %in% colnames(samDF) && "pool" %in% samDF[, "sampleType"]) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
771
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
772 cat("\nVariables: Pool mean, sd, and CV\n", sep="")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
773
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
774 pooVl <- samDF[, "sampleType"] == "pool"
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
775
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
776 if(sum(pooVl) == 1)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
777 varDF[, "pool_mean"] <- datMN[pooVl, ]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
778 else
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
779 varDF[, "pool_mean"] <- apply(datMN[pooVl, , drop=FALSE], 2, function(varVn) mean(varVn, na.rm=TRUE))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
780
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
781 if(sum(pooVl) == 1)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
782 varDF[, "pool_sd"] <- rep(0, nrow(varDF))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
783 else
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
784 varDF[, "pool_sd"] <- apply(datMN[pooVl, , drop=FALSE], 2, function(varVn) sd(varVn, na.rm=TRUE))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
785
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
786 varDF[, "pool_CV"] <- varDF[, "pool_sd"] / varDF[, "pool_mean"]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
787
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
788 }
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
789
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
790 ## 'pool' CV / 'sample' CV ratio
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
791
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
792 if(all(c("pool_CV", "sample_CV") %in% colnames(varDF))) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
793
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
794 cat("\nVariables: Pool CV over sample CV\n", sep="")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
795
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
796 varDF[, "poolCV_over_sampleCV"] <- varDF[, "pool_CV"] / varDF[, "sample_CV"]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
797
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
798 }
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
799
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
800
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
801 ## 'pool' dilutions
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
802
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
803 if("sampleType" %in% colnames(samDF) && any(grepl("pool.+", samDF[, "sampleType"]))) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
804
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
805 pooVi <- grep("pool.*", samDF[, "sampleType"]) ## pool, pool2, pool4, poolInter, ...
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
806
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
807 pooNamVc <- samDF[pooVi, "sampleType"]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
808
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
809 if(pooAsPo1L) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
810
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
811 pooNamVc[pooNamVc == "pool"] <- "pool1" ## 'pool' -> 'pool1'
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
812
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
813 } else {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
814
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
815 pooVl <- pooNamVc == "pool"
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
816 pooVi <- pooVi[!pooVl]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
817 pooNamVc <- pooNamVc[!pooVl]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
818
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
819 }
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
820
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
821 pooDilVc <- gsub("pool", "", pooNamVc)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
822
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
823 pooDilVl <- sapply(pooDilVc, allDigF)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
824
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
825 if(sum(pooDilVl)) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
826
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
827 cat("\nVariables: Pool dilutions\n", sep="")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
828
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
829 pooNamVc <- pooNamVc[pooDilVl] ## for the plot
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
830
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
831 pooVi <- pooVi[pooDilVl]
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
832
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
833 dilVn <- 1 / as.numeric(pooDilVc[pooDilVl])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
834
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
835 varDF[, "poolDil_correl"] <- apply(datMN[pooVi, , drop=FALSE], 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
836 function(varVn) cor(dilVn, varVn))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
837
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
838 varDF[, "poolDil_pval"] <- apply(datMN[pooVi, , drop=FALSE], 2,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
839 function(varVn) cor.test(dilVn, varVn)[["p.value"]])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
840
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
841 }
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
842
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
843 }
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
844
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
845
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
846 ##------------------------------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
847 ## Sample metrics
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
848 ##------------------------------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
849
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
850
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
851 ## Hotelling: p-value associated to the distance from the center in the first PCA score plane
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
852
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
853 cat("\nObservations: Hotelling ellipse\n", sep="")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
854
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
855 ropLs <- opls(datMN, predI = 2, plotL = FALSE, printL = FALSE)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
856
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
857 ropScoreMN <- getScoreMN(ropLs)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
858
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
859 invCovScoMN <- solve(cov(ropScoreMN))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
860
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
861 n <- nrow(datMN)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
862 hotN <- 2 * (n - 1) * (n^2 - 1) / (n^2 * (n - 2))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
863
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
864 hotPvaVn <- apply(ropScoreMN,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
865 1,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
866 function(x)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
867 1 - pf(1 / hotN * t(as.matrix(x)) %*% invCovScoMN %*% as.matrix(x), 2, n - 2))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
868
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
869 samDF[, "hotelling_pval"] <- hotPvaVn
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
870
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
871 ## p-value associated to number of missing values
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
872
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
873 cat("\nObservations: Missing values\n", sep="")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
874
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
875 missZscoVn <- zScoreF(apply(datMN,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
876 1,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
877 function(rowVn) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
878 sum(is.na(rowVn))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
879 }))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
880
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
881 samDF[, "missing_pval"] <- sapply(missZscoVn, function(zscoN) 2 * (1 - pnorm(abs(zscoN))))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
882
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
883 ## p-value associated to the deciles of the profiles
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
884
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
885 cat("\nObservations: Profile deciles\n", sep="")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
886
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
887 deciMN <- t(as.matrix(apply(datMN,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
888 1,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
889 function(x) quantile(x, 0.1 * 1:9, na.rm = TRUE))))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
890
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
891 deciZscoMN <- apply(deciMN, 2, zScoreF)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
892
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
893 deciZscoMaxVn <- apply(deciZscoMN, 1, function(rowVn) rowVn[which.max(abs(rowVn))])
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
894
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
895 samDF[, "decile_pval"] <- sapply(deciZscoMaxVn, function(zscoN) 2 * (1 - pnorm(abs(zscoN))))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
896
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
897
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
898 ##------------------------------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
899 ## Figure
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
900 ##------------------------------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
901
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
902 cat("\nPlotting\n")
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
903
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
904 if(!is.null(fig.pdfC)) {
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
905 pdf(fig.pdfC, width=11, height=7)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
906 } else
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
907 dev.new(width=11, height=7)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
908
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
909 datPloF()
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
910
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
911 if(!is.null(fig.pdfC))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
912 dev.off()
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
913
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
914
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
915 ##------------------------------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
916 ## End
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
917 ##------------------------------
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
918
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
919
2
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
920 if(!is.null(log.txtC)) {
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
921
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
922 cat("\nEnd of '", modNamC, "' Galaxy module call: ",
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
923 as.character(Sys.time()), "\n", sep = "")
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
924
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
925 cat("\n\n\n============================================================================")
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
926 cat("\nAdditional information about the call:\n")
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
927 cat("\n1) Parameters:\n")
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
928 print(args)
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
929
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
930 cat("\n2) Session Info:\n")
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
931 sessioninfo <- sessionInfo()
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
932 cat(sessioninfo$R.version$version.string,"\n")
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
933 cat("Main packages:\n")
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
934 for (pkg in names(sessioninfo$otherPkgs)) { cat(paste(pkg,packageVersion(pkg)),"\t") }; cat("\n")
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
935 cat("Other loaded packages:\n")
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
936 for (pkg in names(sessioninfo$loadedOnly)) { cat(paste(pkg,packageVersion(pkg)),"\t") }; cat("\n")
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
937
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
938 cat("============================================================================\n")
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
939
0
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
940 sink()
2
596320b84315 planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 95d4658e5d9dd0421c9336b2232cc81f32879621
ethevenot
parents: 1
diff changeset
941 }
0
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
942
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
943 options(stingsAsFactors = strAsFacL)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
944 options(warn = optWrnN)
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
945
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
946 return(list(samDF=samDF,
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
947 varDF=varDF))
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
948
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
949
b4f5b5bc01dd planemo upload for repository https://github.com/workflow4metabolomics/qualitymetrics.git commit 73366dd3473c509341ab9ba1df8ba748d08a50a1
ethevenot
parents:
diff changeset
950 } ## qualityMetricsF