annotate pipe-t.R @ 0:185ba61836ab draft

planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
author davidecangelosi
date Thu, 02 May 2019 04:49:04 -0400
parents
children 6cd22b1fbf6d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
1
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
2 cat("\n Started! \n")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
3 #sessionInfo()
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
4
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
5
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
6 # Send R errors to stderr
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
7 options(show.error.messages = F, error = function(){cat(geterrmessage(), file = stderr()); q("no", 1, F)})
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
8
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
9 # Avoid crashing Galaxy with an UTF8 error on German LC settings
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
10 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
11 suppressPackageStartupMessages({
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
12 library(HTqPCR)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
13 library(base)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
14 library(Biobase)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
15 library(utils)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
16 library(stats)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
17 library(graphics)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
18 library(grDevices)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
19 library(RColorBrewer)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
20 library(limma)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
21 library(RankProd)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
22 library(methods)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
23 library(impute)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
24 library(BBmisc)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
25 library(affy)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
26 library(psych)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
27 #library(gmp)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
28 library(zoo)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
29 library(nondetects)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
30 library(Hmisc)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
31 #library(missForest)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
32 #library(mice)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
33 })
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
34
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
35 cat("\n R libraries...loaded!\n")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
36
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
37 args = commandArgs(trailingOnly=TRUE)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
38 dpfiles<-basename(args[1])
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
39 path000<-dirname(args[1])
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
40 format<-args[2]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
41 nfeatures<-args[3]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
42 rawout<-args[4]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
43 path <- args[5]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
44 dcCtmin<-args[6]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
45 dcCtmax<-args[7]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
46 dcflag<-args[8]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
47 x<-args[9]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
48 normalizationMethod<-args[10]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
49 if (normalizationMethod=="deltaCt") {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
50 normalizers<-args[11]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
51 outputNorm<-args[12]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
52 outputECDF<-args[13]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
53 percentofnastoremove<-args[14]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
54 outputRemaining<-args[15]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
55 imputeMethod<-args[16]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
56 if (imputeMethod=="knn") {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
57 kappa<- args[17]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
58 macsp<-args[18]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
59 outputIMP<-args[19]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
60
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
61 DEAMethod<-args[20]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
62 if (DEAMethod=="ttest") {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
63 alternative<- args[21]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
64 paired<-args[22]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
65 replicates<- args[23]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
66 sort<-args[24]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
67 stringent<- args[25]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
68 padjust<-args[26]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
69 outputDEA<-args[27]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
70 filtnames<-args[28]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
71 } else {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
72 outputDEA<-args[21]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
73 filtnames<-args[22]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
74 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
75 } else {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
76 #mean, median, nondetects, cubic
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
77 outputIMP<-args[17]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
78 DEAMethod<-args[18]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
79 if (DEAMethod=="ttest") {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
80 alternative<- args[19]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
81 paired<-args[20]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
82 replicates<- args[21]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
83 sort<-args[22]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
84 stringent<- args[23]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
85 padjust<-args[24]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
86 outputDEA<-args[25]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
87 filtnames<-args[26]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
88 } else {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
89 outputDEA<-args[19]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
90 filtnames<-args[20]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
91 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
92 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
93 }else {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
94 outputNorm<-args[11]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
95 outputECDF<-args[12]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
96 percentofnastoremove<-args[13]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
97 outputRemaining<-args[14]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
98 imputeMethod<-args[15]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
99
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
100 if (imputeMethod=="knn") {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
101 kappa<- args[16]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
102 macsp<-args[17]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
103 outputIMP<-args[18]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
104
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
105 DEAMethod<-args[19]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
106
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
107 if (DEAMethod=="ttest") {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
108 alternative<- args[20]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
109 paired<-args[21]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
110 replicates<- args[22]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
111 sort<-args[23]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
112 stringent<- args[24]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
113 padjust<-args[25]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
114 outputDEA<-args[26]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
115 filtnames<-args[27]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
116 } else {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
117 outputDEA<-args[20]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
118 filtnames<-args[21]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
119 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
120 } else {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
121 #mean, median, nondetects, cubic
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
122 outputIMP<-args[16]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
123 DEAMethod<-args[17]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
124 if (DEAMethod=="ttest") {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
125 alternative<- args[18]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
126 paired<-args[19]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
127 replicates<- args[20]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
128 sort<-args[21]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
129 stringent<- args[22]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
130 padjust<-args[23]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
131 outputDEA<-args[24]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
132 filtnames<-args[25]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
133
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
134 } else {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
135 outputDEA<-args[18]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
136 filtnames<-args[19]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
137
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
138 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
139 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
140 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
141 cat("\n Initialization completed! \n")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
142
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
143 readCtDataDav<-
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
144 function (files, path = NULL, n.features = 384, format = "plain",
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
145 column.info, flag, feature, type, position, Ct, header = FALSE,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
146 SDS = FALSE, n.data = 1, samples, na.value = 40, sample.info,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
147 ...)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
148 {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
149 if (missing(files))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
150 stop("No input files specified")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
151 if (length(files) != length(n.data) & length(n.data) != 1)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
152 stop("n.data must either be a single integer, or same length as number of files")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
153 if (length(n.data) == 1)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
154 n.data <- rep(n.data, length(files))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
155 nsamples <- sum(n.data)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
156 ncum <- cumsum(n.data)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
157 s.names <- NULL
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
158 nspots <- n.features
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
159 if (SDS) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
160 warning("Please use format='SDS'. The SDS' parameter is retained for backward compatibility only.")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
161 format <- "SDS"
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
162 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
163 if (!missing(flag) | !missing(feature) | !missing(type) |
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
164 !missing(position) | !missing(Ct)) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
165 warning("Please use 'column.info' for providing a list of column numbers containing particular information. The use of 'flag', 'feature', 'type', 'position' and 'Ct' is deprecated and will be removed in future versions.")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
166 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
167 if (missing(column.info)) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
168 column.info <- switch(format, EDS = list(flag="EXPFAIL", feature="Target.Name", position="Well.Position", Ct="CT"),
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
169 plain = list(flag = 4,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
170 feature = 6, type = 7, position = 3, Ct = 8), SDS = list(flag = 4,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
171 feature = 6, type = 7, position = 3, Ct = 8), LightCycler = list(feature = "Name",
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
172 position = "Pos", Ct = "Cp"), CFX = list(feature = "Content",
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
173 position = "Well", Ct = "Cq.Mean"), OpenArray = list(flag = "ThroughHole.Outlier",
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
174 feature = "Assay.Assay.ID", type = "Assay.Assay.Type",
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
175 position = "ThroughHole.Address", Ct = "ThroughHole.Ct"),
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
176 BioMark = list(flag = "Call", feature = "Name.1",
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
177 position = "ID", Ct = "Value"))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
178 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
179 X <- matrix(0, nspots, nsamples)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
180 X.flags <- as.data.frame(X)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
181 X.cat <- data.frame(matrix("OK", ncol = nsamples, nrow = nspots),
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
182 stringsAsFactors = FALSE)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
183 for (i in seq_along(files)) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
184 if (i == 1) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
185 cols <- 1:ncum[i]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
186 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
187 else {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
188 cols <- (ncum[i - 1] + 1):ncum[i]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
189 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
190 readfile <- ifelse(is.null(path), files[i], file.path(path,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
191 files[i]))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
192 sample <- switch(format, EDS =.readCtEDS(readfile = readfile,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
193 n.data = n.data, i = i, nspots = nspots, ...), plain = .readCtPlain(readfile = readfile,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
194 header = header, n.features = n.features, n.data = n.data,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
195 i = i, ...), SDS = .readCtSDS(readfile = readfile,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
196 n.data = n.data, i = i, nspots = nspots, ...), LightCycler = .readCtLightCycler(readfile = readfile,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
197 n.data = n.data, i = i, nspots = nspots, ...), CFX = .readCtCFX(readfile = readfile,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
198 n.data = n.data, i = i, nspots = nspots, ...), OpenArray = .readCtOpenArray(readfile = readfile,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
199 n.data = n.data, i = i, nspots = nspots, ...), BioMark = .readCtBioMark(readfile = readfile,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
200 n.data = n.data, i = i, nspots = nspots, ...))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
201
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
202 data <- matrix(sample[, column.info[["Ct"]]], ncol = n.data[i])
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
203 undeter <- apply(data, 2, function(x) x %in% c("Undetermined",
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
204 "No Ct"))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
205 X.cat[, cols][undeter] <- "Undetermined"
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
206 nas <- c("Undetermined", "No Ct", "999", "N/A")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
207 if (is.null(na.value)) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
208 data[data %in% nas | data == 0] <- NA
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
209 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
210 else {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
211 data[data %in% nas | is.na(data) | data == 0] <- na.value
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
212 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
213 X[, cols] <- apply(data, 2, function(x) as.numeric(as.character(x)))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
214 if ("flag" %in% names(column.info)) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
215 flags <- matrix(sample[, column.info[["flag"]]],
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
216 ncol = n.data[i])
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
217 flags[flags == "-"] <- "Failed"
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
218 flags[flags == "+"] <- "Passed"
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
219 X.flags[, cols] <- flags
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
220 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
221 else {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
222 X.flags[, cols] <- "Passed"
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
223 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
224 if (format == "OpenArray") {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
225 s.names <- c(s.names, unique(sample$SampleInfo.SampleID))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
226 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
227 else if (format %in% c("EDS","plain", "SDS")) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
228 s.names <- c(s.names, unique(sample[, 2]))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
229 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
230 else {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
231 s.names <- s.names
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
232 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
233 if (i == 1) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
234 featPos <- paste("feature", 1:nspots, sep = "")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
235 if ("position" %in% names(column.info))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
236 featPos <- as.character(sample[1:nspots, column.info[["position"]]])
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
237 featType <- factor(rep("Target", nspots))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
238 if ("type" %in% names(column.info))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
239 featType <- sample[1:nspots, column.info[["type"]]]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
240 featName <- paste("feature", 1:nspots, sep = "")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
241 if ("feature" %in% names(column.info))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
242 featName <- as.character(sample[1:nspots, column.info[["feature"]]])
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
243 df <- data.frame(featureNames = featName, featureType = as.factor(featType),
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
244 featurePos = featPos)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
245 metaData <- data.frame(labelDescription = c("Name of the qPCR feature (gene)",
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
246 "Type pf feature", "Position on assay"))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
247 featData <- AnnotatedDataFrame(data = df, varMetadata = metaData)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
248 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
249 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
250 if (!missing(samples)) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
251 if (length(samples) < nsamples) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
252 warning("Not enough sample names provided; using Sample1, Sample2, ... instead\n")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
253 samples <- paste("Sample", 1:nsamples, sep = "")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
254 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
255 else if (length(samples) == nsamples) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
256 samples <- samples
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
257 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
258 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
259 else if (missing(samples)) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
260 if (length(files) == nsamples) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
261 samples <- gsub("(.+)\\..+", "\\1", files)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
262 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
263 else if (length(s.names) == nsamples) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
264 samples <- s.names
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
265 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
266 else {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
267 samples <- paste("Sample", 1:nsamples, sep = "")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
268 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
269 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
270 samples <- make.unique(samples)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
271 if (any(is.na(X)))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
272 warning("One or more samples contain NAs. Consider replacing these with e.g. Ct=40 now.")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
273 if (missing(sample.info)) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
274 pdata <- data.frame(sample = 1:length(samples), row.names = samples)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
275 sample.info <- new("AnnotatedDataFrame", data = pdata,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
276 varMetadata = data.frame(labelDescription = "Sample numbering",
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
277 row.names = "Sample names"))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
278 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
279 X.hist <- data.frame(history = capture.output(match.call(readCtData)),
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
280 stringsAsFactors = FALSE)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
281 out <- new("qPCRset", exprs = X, phenoData = sample.info,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
282 featureData = featData, featureCategory = X.cat, flag = X.flags,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
283 CtHistory = X.hist)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
284 out
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
285 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
286 .readCtEDS <-
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
287 function(readfile=readfile, n.data=n.data, i=i, nspots=nspots, ...)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
288 {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
289 # Scan through beginning of file, max 100 lines
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
290 file.header <- readLines(con=readfile, n=100)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
291 n.header <- grep("^Well", file.header)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
292 if (length(n.header)==0)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
293 n.header <- 0
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
294 # Read data, skip the required lines
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
295 out <- read.delim(file=readfile, header=TRUE, colClasses="character", nrows=nspots*n.data[i], skip=n.header-1, strip.white=TRUE, ...)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
296 out
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
297 } # .readCtEDS
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
298
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
299 head(read.delim(file.path(path000, dpfiles), sep="\t"))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
300 files <- read.delim(file.path(path000, dpfiles), sep="\t")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
301 switch(format,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
302 "EDS"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
303 columns<- list(flag="EXPFAIL", feature="Target.Name", position="Well.Position", Ct="CT")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
304 metadata <- data.frame(labelDescription = c("sampleName", "Treatment"), row.names = c("sampleName", "Treatment"))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
305 phenoData <- new("AnnotatedDataFrame", data = files, varMetadata = metadata)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
306 rownames(phenoData)=as.vector(files$sampleName)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
307 raw<- readCtDataDav(files = as.vector(files$sampleName), header=TRUE, format="EDS", column.info=columns, path = path,sample.info=phenoData,n.features = as.numeric(nfeatures))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
308 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
309 "plain"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
310 metadata <- data.frame(labelDescription = c("sampleName", "Treatment"), row.names = c("sampleName", "Treatment"))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
311 phenoData <- new("AnnotatedDataFrame", data = files, varMetadata = metadata)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
312 rownames(phenoData)=as.vector(files$sampleName)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
313 raw<- readCtDataDav(files = as.vector(files$sampleName), header=FALSE, format="plain", path = path, sample.info=phenoData,n.features = as.numeric(nfeatures))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
314 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
315 "SDS"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
316 columns<- list(feature=3, Ct=6, flag=11)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
317 metadata <- data.frame(labelDescription = c("sampleName", "Treatment"), row.names = c("sampleName", "Treatment"))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
318 phenoData <- new("AnnotatedDataFrame", data = files, varMetadata = metadata)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
319 rownames(phenoData)=as.vector(files$sampleName)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
320 raw<- readCtDataDav(files = files$sampleName, format="SDS",column.info=columns, path = path, sample.info=phenoData, n.features=as.numeric(nfeatures))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
321 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
322 "LightCycler"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
323 metadata <- data.frame(labelDescription = c("sampleName", "Treatment"), row.names = c("sampleName", "Treatment"))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
324 phenoData <- new("AnnotatedDataFrame", data = files, varMetadata = metadata)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
325 rownames(phenoData)=as.vector(files$sampleName)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
326 raw <- readCtDataDav(files = files$sampleName, path = path, format = "LightCycler", sample.info=phenoData,n.features = as.numeric(nfeatures))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
327 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
328 "CFX"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
329 metadata <- data.frame(labelDescription = c("sampleName", "Treatment"), row.names = c("sampleName", "Treatment"))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
330 phenoData <- new("AnnotatedDataFrame", data = files, varMetadata = metadata)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
331 rownames(phenoData)=as.vector(files$sampleName)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
332 raw <- readCtDataDav(files = files$sampleName, path = path, format = "CFX", sample.info=phenoData,n.features = as.numeric(nfeatures))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
333 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
334 "OpenArray"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
335 metadata <- data.frame(labelDescription = c("sampleName", "Treatment"), row.names = c("sampleName", "Treatment"))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
336 phenoData <- new("AnnotatedDataFrame", data = files, varMetadata = metadata)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
337 rownames(phenoData)=as.vector(files$sampleName)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
338 raw <- readCtDataDav(files = files$sampleName, path = path, format = "OpenArray", sample.info=phenoData,n.features = as.numeric(nfeatures))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
339 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
340 "BioMark"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
341 metadata <- data.frame(labelDescription = c("sampleName", "Treatment"), row.names = c("sampleName", "Treatment"))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
342 phenoData <- new("AnnotatedDataFrame", data = files, varMetadata = metadata)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
343 rownames(phenoData)=as.vector(files$sampleName)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
344 raw <- readCtDataDav(files = files$sampleName, path = path, format = "BioMark", sample.info=phenoData, n.features = as.numeric(nfeatures))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
345 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
346 stop("Enter something that switches me!")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
347 )
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
348 cat("\n Files read correctly! ")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
349
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
350 write.table(exprs(raw), file=rawout, quote=FALSE, row.names=TRUE, col.names=TRUE,sep = "\t")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
351 ####################################################################################################################
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
352 #Set a new categories for the values meeting two criterions
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
353 switch(format,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
354 "EDS"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
355 unreliable<-setCategory(raw, Ct.max=dcCtmax, Ct.min=dcCtmin,replicates=FALSE, flag=dcflag, flag.out="Y", quantile=NULL)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
356 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
357 "plain"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
358 unreliable<-setCategory(raw, Ct.max=dcCtmax, Ct.min=dcCtmin,replicates=FALSE, flag=dcflag, flag.out="Flagged", quantile=NULL)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
359 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
360 "SDS"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
361 unreliable<-setCategory(raw, Ct.max=dcCtmax, Ct.min=dcCtmin,replicates=FALSE, flag=dcflag, flag.out="TRUE", quantile=NULL)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
362 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
363 "LightCycler"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
364 unreliable<-setCategory(raw, Ct.max=dcCtmax, Ct.min=dcCtmin,replicates=FALSE, flag=dcflag, flag.out="Y", quantile=NULL)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
365 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
366 "CFX"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
367 unreliable<-setCategory(raw, Ct.max=dcCtmax, Ct.min=dcCtmin,replicates=FALSE, flag=dcflag, flag.out="Y", quantile=NULL)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
368 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
369 "OpenArray"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
370 unreliable<-setCategory(raw, Ct.max=dcCtmax, Ct.min=dcCtmin,replicates=FALSE, flag=dcflag, flag.out="TRUE ", quantile=NULL)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
371 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
372 "BioMark"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
373 unreliable<-setCategory(raw, Ct.max=dcCtmax, Ct.min=dcCtmin,replicates=FALSE, flag=dcflag, flag.out="Fail", quantile=NULL)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
374 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
375 stop("Enter something that switches me!")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
376 )
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
377 #unreliable<-setCategory(raw, Ct.max=dcCtmax, Ct.min=dcCtmin,replicates=FALSE, flag=dcflag, flag.out="Y", quantile=NULL)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
378
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
379 ####################################################################################################################
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
380 #Filter out the values of the new category
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
381 xFilter <- filterCategory(unreliable)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
382
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
383 cat("\n Categorization completed! ")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
384
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
385 png(x, # create PNG for the heat map
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
386 width = 10*300, # 5 x 300 pixels
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
387 height = 10*300,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
388 res = 300, # 300 pixels per inch
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
389 pointsize = 8)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
390 plotCtBoxes(xFilter, stratify=NULL, xlab = "Samples", ylab="Ct", names=as.character(seq(1, ncol(xFilter), 1))) # smaller font size
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
391 dev.off()
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
392
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
393 #write.table(exprs(xFilter), file=x, quote=FALSE, row.names=TRUE, col.names=TRUE,sep = "\t")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
394
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
395 ####################################################################################################################
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
396 #NORMALIZATION
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
397 #method version 3.5.1 + Global mean
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
398 normalizeCtDataDav <-
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
399 function(q,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
400 norm = "deltaCt",
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
401 deltaCt.genes = NULL,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
402 scale.rank.samples,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
403 rank.type = "pseudo.median",
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
404 Ct.max = dcCtmax,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
405 geo.mean.ref,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
406 verbose = TRUE)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
407 {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
408 # Extract the data
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
409 data <- exprs(q)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
410 data.norm <- data
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
411 # Get the normalisation method
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
412 method <- match.arg(norm, c("quantile", "scale.rankinvariant", "norm.rankinvariant", "deltaCt", "geometric.mean", "globalmean"))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
413 # Some general stuff that will be used by both rank.invariant methods
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
414 if (method %in% c("scale.rankinvariant", "norm.rankinvariant")) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
415 # Index to use for too high Ct values
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
416 #Ct.index <- data>Ct.max
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
417 data.Ctmax <- data
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
418 Ct.index <- is.na(data)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
419 #data.Ctmax[Ct.index] <- NA
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
420 data<-na.spline(data)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
421 # Define what to rank against
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
422 if (rank.type=="pseudo.median") {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
423 ref.data <- apply(data.Ctmax, 1, median, na.rm=TRUE)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
424 } else if (rank.type=="pseudo.mean") {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
425 ref.data <- apply(data.Ctmax, 1, mean, na.rm=TRUE)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
426 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
427 # Mark + replace NA values with something temporary
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
428 na.index <- is.na(ref.data)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
429 ref.data[na.index] <- 30
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
430 # Run the rank.invariant function
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
431 data.rankinvar <- apply(data, 2, normalize.invariantset, ref=ref.data)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
432 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
433 # The actual normalisation
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
434 switch(method,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
435 quantile = {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
436 # Use an internal limma function
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
437 data.norm <- normalizeQuantiles(data)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
438 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
439 scale.rankinvariant = {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
440 # Get all the rank invariant genes
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
441 ri.genes <- sapply(data.rankinvar, "[[", "i.set")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
442 # Remove those with too high Ct values
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
443 ri.genes[Ct.index] <- FALSE
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
444 # Remove those that were all NA for potentially other reasons
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
445 ri.genes[na.index,] <- FALSE
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
446 # Select those to use here
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
447 ri.count <- rowSums(ri.genes)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
448 if (missing(scale.rank.samples))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
449 scale.rank.samples <- ncol(data)-1
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
450 ri.index <- ri.count >= scale.rank.samples
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
451 if (sum(ri.index)==0)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
452 stop(paste("No rank invariant genes were found across", scale.rank.samples, "samples"))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
453 # Extract the corresponding Ct values; average
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
454 ri.mean <- colMeans(data[ri.index,,drop=FALSE])
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
455 ri.scale <- ri.mean/ri.mean[1]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
456 # Correct the data
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
457 data.norm <- t(t(data)*ri.scale)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
458 # Print info
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
459 if (verbose) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
460 cat(c("Scaling Ct values\n\tUsing rank invariant genes:", paste(featureNames(q)[ri.index], collapse=" "), "\n"))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
461 cat(c("\tScaling factors:", format(ri.scale, digits=3), "\n"))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
462 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
463 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
464 norm.rankinvariant = {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
465 # Print info
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
466 if (verbose)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
467 cat("Normalizing Ct values\n\tUsing rank invariant genes:\n")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
468 # Correct the data based on the calculations above
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
469 for (i in 1:ncol(data)) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
470 # Check if there are any rank invariant genes
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
471 ri.sub <- data.rankinvar[[i]]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
472 ri.genes <- ri.sub[["i.set"]]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
473 # Remove those that don't pass the Ct.max criteria
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
474 ri.genes[Ct.index[,i]] <- FALSE
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
475 # Remove those that are NA for other reasons
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
476 ri.genes[na.index] <- FALSE
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
477 if (sum(ri.genes)==0) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
478 warning(paste("\tNo rank invariant genes were found for sample ", sampleNames(q)[i], "; sample not normalized\n", sep=""))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
479 next
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
480 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
481 # If verbose, print some info
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
482 if (verbose)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
483 cat(paste("\t", sampleNames(q)[i], ": ", sum(ri.genes), " rank invariant genes\n", sep=""))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
484 # The actual correction
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
485 data.norm[,i] <- as.numeric(approx(ri.sub$n.curve$y, ri.sub$n.curve$x, xout=data[,i], rule=2)$y)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
486 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
487 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
488 deltaCt = {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
489 # Which are the reference genes (endogenous controls)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
490 if (is.null(deltaCt.genes))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
491 deltaCt.genes <- unique(featureNames(q)[featureType(q)=="Endogenous Control"])
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
492 c.index <- featureNames(q) %in% deltaCt.genes
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
493 if (verbose) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
494 cat(c("Calculating deltaCt values\n\tUsing control gene(s):", paste(deltaCt.genes, collapse=" "), "\n"))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
495 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
496 # Run though all cards; perform internal normalisation
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
497 for (c in 1:ncol(data)) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
498 # Calculate the control genes
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
499 refCt <- mean(data[c.index,c], na.rm=TRUE)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
500 refsd <- sd(data[c.index,c], na.rm=TRUE)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
501 # Difference for target and controls
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
502 data.norm[,c] <- data[,c]-refCt
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
503 # Print results
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
504 if (verbose)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
505 cat(paste("\tCard ", c, ":\tMean=", format(refCt, dig=4), "\tStdev=", format(refsd, dig=3), "\n", sep=""))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
506 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
507 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
508 geometric.mean = {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
509 # For each column, calculate the geometric mean of Ct values<Ct.max
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
510 #geo.mean <- apply(data, 2, function(x) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
511 # xx <- log2(subset(x, x<Ct.max))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
512 # 2^mean(xx)})
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
513 geo.mean <- apply(data, 2, function(x) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
514 xx <- subset(x, x<=Ct.max)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
515 geometric.mean(xx)})
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
516 # Which sample to scale to
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
517 #if (missing(geo.mean.ref))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
518 # geo.mean.ref <- 1
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
519 # Calculate the scaling factor
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
520 #geo.scale <- geo.mean/geo.mean[geo.mean.ref]
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
521 # Adjust the data accordingly
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
522 data.norm <- t(t(data) - geo.mean)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
523 if (verbose) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
524 cat(c("Scaling Ct values\n\tUsing geometric mean within each sample\n"))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
525 #cat(c("\tScaling factors:", format(geo.scale, digits=3), "\n"))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
526 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
527 } # switch
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
528 ,globalmean = {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
529 glo <- apply(data, 2, function(x) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
530 xx <- subset(x, x <= Ct.max)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
531 mean(xx)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
532 })
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
533 data.norm <- t(t(data) - glo)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
534 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
535 )
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
536 # Replace with the normalised Ct exprs
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
537 exprs(q) <- data.norm
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
538 # Add to the history of the object
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
539 if (nrow(getCtHistory(q))==0)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
540 setCtHistory(q) <- data.frame(history="Manually created qPCRset object.", stringsAsFactors=FALSE)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
541 setCtHistory(q) <- rbind(getCtHistory(q), capture.output(match.call(normalizeCtData)))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
542 # Return the normalised object
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
543 q
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
544 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
545
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
546
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
547 switch(normalizationMethod,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
548 "deltaCt"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
549 normalizedDataset <- normalizeCtDataDav(xFilter, norm="deltaCt", deltaCt.genes =explode(normalizers, sep = ","))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
550 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
551 "quantile"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
552 normalizedDataset <- normalizeCtDataDav(xFilter, norm=normalizationMethod)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
553 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
554 "scale.rankinvariant"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
555 normalizedDataset <- normalizeCtDataDav(xFilter, norm=normalizationMethod)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
556 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
557 "norm.rankinvariant"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
558 normalizedDataset <- normalizeCtDataDav(xFilter, norm=normalizationMethod)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
559 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
560 "geometric.mean"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
561 normalizedDataset <- normalizeCtDataDav(xFilter, norm=normalizationMethod)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
562 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
563 "globalmean"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
564 normalizedDataset <- normalizeCtDataDav(xFilter, norm=normalizationMethod)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
565 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
566 stop("Enter something that switches me!")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
567 )
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
568
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
569 #if (normalizationMethod=="deltaCt") {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
570 #normalize CT data
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
571
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
572 #normalizedDataset <- normalizeCtDataDav(xFilter, norm="deltaCt", deltaCt.genes =explode(normalizers, sep = ","))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
573 #} else {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
574 #normalizedDataset <- normalizeCtDataDav(xFilter, norm=normalizationMethod)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
575
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
576 #}
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
577 cat("\n Data normalized correctly! \n")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
578 write.table(exprs(normalizedDataset), file=outputNorm, quote=FALSE, row.names=TRUE, col.names=TRUE,sep = "\t")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
579
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
580
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
581 #normalizedDataset
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
582 ####################################################################################################################
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
583 #Check noise reduction by empirical cumulative distribution
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
584
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
585 #X = rnorm(100) # X is a sample of 100 normally distributed random variables
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
586 # P = ecdf(X) # P is a function giving the empirical CDF of X
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
587 #Y = rnorm(1000) # X is a sample of 100 normally distributed random variables
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
588 # PY = ecdf(Y)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
589 #plotâ„—
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
590
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
591 #lines(PY)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
592 png(outputECDF, # create PNG for the heat map
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
593 width = 10*300, # 5 x 300 pixels
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
594 height = 10*300,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
595 res = 300, # 300 pixels per inch
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
596 pointsize = 8) # smaller font size
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
597 vec=c()
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
598 for (i in 1:nrow(exprs(xFilter))){
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
599 CVX<-(sd(2^-exprs(xFilter)[i,], na.rm = TRUE)/mean(2^-exprs(xFilter)[i,], na.rm = TRUE))*100
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
600 vec=c(vec, c(CVX))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
601 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
602 vec<-na.omit(vec)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
603 P = ecdf(vec)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
604 gm=c()
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
605 for (i in 1:nrow(exprs(normalizedDataset))){
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
606 CVGM<-(sd(2^-exprs(normalizedDataset)[i,], na.rm = TRUE)/mean(2^-exprs(normalizedDataset)[i,], na.rm = TRUE))*100
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
607 gm=c(gm, c(CVGM))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
608 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
609 gm<-na.omit(gm)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
610
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
611 PY = ecdf(gm)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
612
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
613 plot_colors <- c(rgb(r=0.0,g=0.0,b=0.9), "red", "forestgreen",rgb(r=0.0,g=0.0,b=0.0),rgb(r=0.5,g=0.0,b=0.3),rgb(r=0.0,g=0.4,b=0.4))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
614
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
615 plot(P,col=plot_colors[1],xlim=c(0.0,600), ylim=c(0.0,1),xaxp = c(0.0, 600, 6),yaxp = c(0.0, 1, 10), cex=1.3, lwd=5, main=NULL,xlab="CV(%)",ylab="Empirical Cumulative Distribution")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
616 lines(PY, lwd=5, col=plot_colors[6],cex=1.3)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
617 legend("bottomright", c("not normalized", "normalized"), cex=1.3, col=c(plot_colors[1],plot_colors[6]), lwd=c(5,5));
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
618 dev.off()
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
619
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
620 #Two-sample Kolmogorov-Smirnov
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
621 ks.test(vec,gm)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
622
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
623
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
624 #write.table(exprs(qFiltNAs), file=outputIMP, quote=FALSE, row.names=TRUE, col.names=TRUE,sep = "\t")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
625 png(outputIMP, # create PNG for the heat map
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
626 width = 10*300, # 5 x 300 pixels
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
627 height = 10*300,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
628 res = 300, # 300 pixels per inch
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
629 pointsize = 8)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
630 plotCtBoxes(normalizedDataset, stratify=NULL, xlab = "Samples", ylab="DeltaCt", names=as.character(seq(1, ncol(normalizedDataset), 1))) # smaller font size
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
631 dev.off()
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
632
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
633 ################################################## Filtering based on number of NAs##################################################
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
634
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
635 #FILTERING on the basis of NAs
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
636 #qPCRset.R
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
637 setMethod("exprs", signature(object="qPCRset"), definition =
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
638 function (object) {x <- assayDataElement(object, "exprs"); rownames(x) <- featureNames(object); colnames(x) <- sampleNames(phenoData(object));x}
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
639 )
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
640 ncatn <- as.integer(n.samples(normalizedDataset))*as.integer(percentofnastoremove)/100
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
641
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
642 qFiltNAs <- filterCtData(normalizedDataset, remove.category=c("Undetermined","Unreliable"), n.category=as.integer(ncatn),remove.name=explode(filtnames, sep = ","))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
643
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
644 cat("\n Data filtered correctly! \n")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
645
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
646 if (is.na(exprs(qFiltNAs))){
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
647 switch(imputeMethod,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
648 "knn"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
649 imp<-impute.knn(exprs(qFiltNAs) ,k = as.integer(kappa), maxp = as.integer(macsp), rng.seed=362436069)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
650 exprs(qFiltNAs)=imp$data
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
651 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
652 "mestdagh"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
653 #Mesdagh
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
654 #sostituisce a NA -1000
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
655 for (i in 1:nrow(exprs(qFiltNAs))){
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
656 for(j in 1:ncol(exprs(qFiltNAs))){
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
657 if(is.na(exprs(qFiltNAs)[i,j])>0)exprs(qFiltNAs)[i,j]<- -1000
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
658 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
659 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
660 temp<-exprs(qFiltNAs)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
661 for (i in 1:nrow(exprs(qFiltNAs))){
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
662 for(j in 1:ncol(exprs(qFiltNAs))){
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
663 if(exprs(qFiltNAs)[i,j]<(-100))exprs(qFiltNAs)[i,j]<- max(temp[i,])+1
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
664 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
665 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
666 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
667 "cubic"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
668 exprs(qFiltNAs) <- na.spline(exprs(qFiltNAs))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
669 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
670 "mean"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
671 exprs(qFiltNAs)<-impute(exprs(qFiltNAs),mean)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
672 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
673 "median"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
674 exprs(qFiltNAs)<-impute(exprs(qFiltNAs),median)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
675 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
676 "nondetects"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
677 qFiltNAs <- qpcrImpute(qFiltNAs, outform=c("Single"),linkglm = c("logit"))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
678 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
679 stop("Enter something that switches me!")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
680 )
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
681
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
682 cat("\n Imputation completed! \n")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
683 }else{
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
684 cat("\n Nothing to impute! \n")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
685 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
686
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
687 write.table(exprs(qFiltNAs), file=outputRemaining, quote=FALSE, row.names=TRUE, col.names=TRUE, sep = "\t")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
688
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
689 if (DEAMethod=="ttest") {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
690 #Differential expression analysis (paired t test+BH). Returns Fold change in linear scale.
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
691 DEG<-ttestCtData(qFiltNAs, groups = files$Treatment, alternative = alternative, paired = ifelse(paired=="TRUE", TRUE, FALSE), replicates =ifelse(replicates=="TRUE", TRUE, FALSE), sort=ifelse(sort=="TRUE", TRUE, FALSE), stringent=ifelse(stringent=="TRUE", TRUE, FALSE), p.adjust=padjust)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
692 write.table(DEG, file=outputDEA, quote=FALSE, row.names=TRUE, col.names=TRUE,sep = "\t")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
693 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
694 if (DEAMethod=="rp") {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
695 DEG<-RP(exprs(qFiltNAs), as.numeric(pData(qFiltNAs)$Treatment)-1, num.perm = 1000,logged = TRUE, gene.names = featureNames(qFiltNAs), huge=TRUE, plot = FALSE, rand = 123)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
696 write.table(DEG[1:5], file=outputDEA, quote=FALSE, row.names=TRUE, col.names=TRUE,sep = "\t")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
697 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
698 cat("\n Differential expression analysis completed correctly! \n")
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
699 cat("\n Workflow ended correctly! \n")