annotate pipe-t.R @ 2:6cd22b1fbf6d draft

planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
author davidecangelosi
date Mon, 06 May 2019 05:37:40 -0400
parents 185ba61836ab
children e2fcf5a4609c
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
2
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
143 .readCtEDS <-
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
144 function(readfile=readfile, n.data=n.data, i=i, nspots=nspots, ...)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
145 {
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
146 # Scan through beginning of file, max 100 lines
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
147 file.header <- readLines(con=readfile, n=100)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
148 n.header <- grep("^Well", file.header)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
149 if (length(n.header)==0)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
150 n.header <- 0
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
151 # Read data, skip the required lines
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
152 out <- read.delim(file=readfile, header=TRUE, colClasses="character", nrows=nspots*n.data[i], skip=n.header-1, strip.white=TRUE, ...)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
153 out
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
154 } # .readCtEDS
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
155
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
156
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
157 .readCtPlain <-
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
158 function(readfile=readfile, header=header, n.features=n.features, n.data=n.data, i=i, ...)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
159 {
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
160 # A check for file dimensions. Read a single file.
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
161 sample <- read.delim(file=readfile, header=header, ...)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
162 nspots <- nrow(sample)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
163 if (nspots != n.features*n.data[1])
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
164 warning(paste(n.features, "gene names (rows) expected, got", nspots))
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
165 # Read in the required file
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
166 out <- read.delim(file=readfile, header=header, colClasses="character", nrows=nspots*n.data[i], ...)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
167 # Return
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
168 out
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
169 } # .readCtPlain
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
170
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
171 .readCtSDS <-
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
172 function(readfile=readfile, n.data=n.data, i=i, nspots=nspots, ...)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
173 {
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
174 # Scan through beginning of file, max 100 lines
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
175 file.header <- readLines(con=readfile, n=100)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
176 n.header <- grep("^#", file.header)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
177 if (length(n.header)==0)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
178 n.header <- 0
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
179 # Read data, skip the required lines
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
180 out <- read.delim(file=readfile, header=FALSE, colClasses="character", nrows=nspots*n.data[i], skip=n.header, strip.white=TRUE, ...)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
181 # Return
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
182 out
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
183 } # .readCtSDS
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
184
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
185 .readCtLightCycler <-
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
186 function(readfile=readfile, n.data=n.data, i=i, nspots=nspots, ...)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
187 {
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
188 # Read data, skip the required lines
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
189 out <- read.delim(file=readfile, header=TRUE, as.is=TRUE, nrows=nspots*n.data[i], skip=1, strip.white=TRUE, ...)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
190 # Return
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
191 out
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
192 } # .readCtLightCycler
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
193
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
194 .readCtCFX <- function(readfile=readfile, n.data=n.data, i=i, nspots=nspots, ...)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
195 {
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
196 # Read data, skip the required lines
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
197 out <- read.csv(file=readfile, header=TRUE, as.is=TRUE, nrows=nspots*n.data[i], strip.white=TRUE, ...)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
198 # Return
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
199 out
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
200 } # .readCtCFX
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
201
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
202 .readCtOpenArray <-
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
203 function(readfile=readfile, n.data=n.data, i=i, nspots=nspots, ...)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
204 {
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
205 # Read data
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
206 out <- read.csv(file=readfile, header=TRUE, as.is=TRUE, nrows=nspots*n.data[i], strip.white=TRUE, ...)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
207 # Regard those marked as outliers as "Unreliable"
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
208 out$ThroughHole.Outlier[out$ThroughHole.Outlier=="False"] <- "OK"
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
209 out$ThroughHole.Outlier[out$ThroughHole.Outlier=="True"] <- "Unreliable"
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
210 # Return
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
211 out
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
212 } # .readCtOpenArray
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
213
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
214 .readCtBioMark <-
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
215 function(readfile=readfile, n.data=n.data, i=i, nspots=nspots, ...)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
216 {
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
217 # Scan through beginning of file, max 100 lines
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
218 file.header <- readLines(con=readfile, n=100)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
219 n.header <- grep("^ID", file.header)-1
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
220 if (length(n.header)==0)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
221 n.header <- 0
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
222 # Read data, skip the required lines
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
223 out <- read.csv(file=readfile, header=TRUE, as.is=TRUE, nrows=nspots*n.data[i], skip=n.header, strip.white=TRUE, ...)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
224 # Convert the calls into flags
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
225 out$Call[out$Call=="Pass"] <- "OK"
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
226 out$Call[out$Call=="Fail"] <- "Undetermined"
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
227 # Return
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
228 out
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
229 } # .readCtBioMark
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
230
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
231
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
232
0
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
233 readCtDataDav<-
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
234 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
235 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
236 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
237 ...)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
238 {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
239 if (missing(files))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
240 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
241 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
242 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
243 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
244 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
245 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
246 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
247 s.names <- NULL
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
248 nspots <- n.features
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
249 if (SDS) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
250 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
251 format <- "SDS"
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
252 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
253 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
254 !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
255 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
256 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
257 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
258 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
259 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
260 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
261 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
262 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
263 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
264 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
265 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
266 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
267 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
268 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
269 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
270 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
271 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
272 stringsAsFactors = FALSE)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
273 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
274 if (i == 1) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
275 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
276 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
277 else {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
278 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
279 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
280 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
281 files[i]))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
282 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
283 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
284 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
285 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
286 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
287 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
288 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
289 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
290 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
291
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
292 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
293 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
294 "No Ct"))
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
295 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
296 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
297 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
298 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
299 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
300 else {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
301 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
302 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
303 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
304 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
305 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
306 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
307 flags[flags == "-"] <- "Failed"
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
308 flags[flags == "+"] <- "Passed"
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
309 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
310 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
311 else {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
312 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
313 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
314 if (format == "OpenArray") {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
315 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
316 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
317 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
318 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
319 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
320 else {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
321 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
322 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
323 if (i == 1) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
324 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
325 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
326 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
327 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
328 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
329 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
330 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
331 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
332 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
333 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
334 featurePos = featPos)
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("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
336 "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
337 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
338 }
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 if (!missing(samples)) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
341 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
342 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
343 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
344 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
345 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
346 samples <- samples
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 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
349 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
350 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
351 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
352 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
353 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
354 samples <- s.names
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
355 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
356 else {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
357 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
358 }
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 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
361 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
362 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
363 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
364 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
365 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
366 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
367 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
368 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
369 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
370 stringsAsFactors = FALSE)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
371 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
372 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
373 CtHistory = X.hist)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
374 out
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
375 }
2
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
376
0
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
377
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
378 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
379 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
380 switch(format,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
381 "EDS"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
382 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
383 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
384 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
385 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
386 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
387 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
388 "plain"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
389 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
390 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
391 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
392 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
393 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
394 "SDS"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
395 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
396 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
397 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
398 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
399 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
400 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
401 "LightCycler"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
402 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
403 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
404 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
405 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
406 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
407 "CFX"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
408 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
409 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
410 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
411 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
412 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
413 "OpenArray"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
414 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
415 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
416 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
417 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
418 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
419 "BioMark"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
420 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
421 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
422 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
423 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
424 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
425 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
426 )
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
427 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
428
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
429 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
430 ####################################################################################################################
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
431 #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
432 switch(format,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
433 "EDS"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
434 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
435 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
436 "plain"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
437 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
438 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
439 "SDS"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
440 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
441 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
442 "LightCycler"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
443 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
444 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
445 "CFX"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
446 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
447 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
448 "OpenArray"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
449 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
450 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
451 "BioMark"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
452 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
453 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
454 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
455 )
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
456 #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
457
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
458 ####################################################################################################################
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
459 #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
460 xFilter <- filterCategory(unreliable)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
461
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
462 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
463
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
464 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
465 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
466 height = 10*300,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
467 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
468 pointsize = 8)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
469 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
470 dev.off()
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
471
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
472 #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
473
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
474 ####################################################################################################################
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
475 #NORMALIZATION
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
476 #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
477 normalizeCtDataDav <-
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
478 function(q,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
479 norm = "deltaCt",
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
480 deltaCt.genes = NULL,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
481 scale.rank.samples,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
482 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
483 Ct.max = dcCtmax,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
484 geo.mean.ref,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
485 verbose = TRUE)
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 # Extract the data
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
488 data <- exprs(q)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
489 data.norm <- data
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
490 # 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
491 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
492 # 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
493 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
494 # 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
495 #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
496 data.Ctmax <- data
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
497 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
498 #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
499 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
500 # 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
501 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
502 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
503 } 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
504 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
505 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
506 # 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
507 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
508 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
509 # 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
510 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
511 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
512 # The actual normalisation
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
513 switch(method,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
514 quantile = {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
515 # 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
516 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
517 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
518 scale.rankinvariant = {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
519 # 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
520 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
521 # 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
522 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
523 # 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
524 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
525 # 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
526 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
527 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
528 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
529 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
530 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
531 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
532 # 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
533 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
534 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
535 # Correct the data
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
536 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
537 # Print info
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
538 if (verbose) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
539 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
540 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
541 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
542 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
543 norm.rankinvariant = {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
544 # Print info
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
545 if (verbose)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
546 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
547 # 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
548 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
549 # 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
550 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
551 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
552 # 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
553 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
554 # 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
555 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
556 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
557 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
558 next
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 # 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
561 if (verbose)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
562 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
563 # The actual correction
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
564 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
565 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
566 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
567 deltaCt = {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
568 # 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
569 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
570 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
571 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
572 if (verbose) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
573 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
574 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
575 # 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
576 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
577 # 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
578 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
579 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
580 # 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
581 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
582 # Print results
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
583 if (verbose)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
584 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
585 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
586 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
587 geometric.mean = {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
588 # 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
589 #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
590 # 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
591 # 2^mean(xx)})
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
592 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
593 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
594 geometric.mean(xx)})
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
595 # 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
596 #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
597 # 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
598 # 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
599 #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
600 # 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
601 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
602 if (verbose) {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
603 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
604 #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
605 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
606 } # switch
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
607 ,globalmean = {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
608 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
609 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
610 mean(xx)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
611 })
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
612 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
613 }
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 # 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
616 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
617 # 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
618 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
619 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
620 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
621 # 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
622 q
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
623 }
2
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
624 #library(NormqPCR)
0
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
625
2
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
626 #delete.na <- function(DF, n=0) {
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
627 # DF[rowSums(is.na(DF)) <= n,]
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
628 #}
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
629
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
630 #user_number=5
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
631 #genorm <- selectHKs(t(delete.na(as.matrix(exprs(xGlico)),0)), method = "geNorm", Symbols = rownames(as.matrix(delete.na(exprs(xGlico),0))), minNrHK = as.numeric(user_number), log = TRUE)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
632 #normfinder <- selectHKs(as.matrix(t(delete.na(exprs(xGlico),0))), group= files$Treatment , method = "NormFinder", Symbols =rownames(as.matrix(delete.na(exprs(xGlico),0))), minNrHK = as.numeric(user_number), log = TRUE)
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
633 #intersection= intersect(normfinder$ranking, genorm$ranking[1:as.numeric(user_number)])
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
634
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
635 #cat("\n GeNorm and NormFinder transcripts selected as housekeeping for normalization! \n")
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
636 #intersection
6cd22b1fbf6d planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 18d030f0c2e423a04617a3827ba5a652c8d7867a
davidecangelosi
parents: 0
diff changeset
637 #dnorm <- normalizeCtData(xGlico , norm="deltaCt", deltaCt.genes=as.vector(intersection))
0
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
638
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
639 switch(normalizationMethod,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
640 "deltaCt"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
641 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
642 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
643 "quantile"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
644 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
645 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
646 "scale.rankinvariant"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
647 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
648 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
649 "norm.rankinvariant"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
650 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
651 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
652 "geometric.mean"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
653 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
654 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
655 "globalmean"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
656 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
657 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
658 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
659 )
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
660
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
661 #if (normalizationMethod=="deltaCt") {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
662 #normalize CT data
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
663
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
664 #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
665 #} else {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
666 #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
667
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
668 #}
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
669 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
670 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
671
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 #normalizedDataset
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
674 ####################################################################################################################
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
675 #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
676
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
677 #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
678 # 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
679 #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
680 # PY = ecdf(Y)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
681 #plotâ„—
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
682
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
683 #lines(PY)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
684 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
685 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
686 height = 10*300,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
687 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
688 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
689 vec=c()
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
690 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
691 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
692 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
693 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
694 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
695 P = ecdf(vec)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
696 gm=c()
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
697 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
698 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
699 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
700 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
701 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
702
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
703 PY = ecdf(gm)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
704
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
705 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
706
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
707 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
708 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
709 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
710 dev.off()
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
711
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
712 #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
713 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
714
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
715
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
716 #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
717 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
718 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
719 height = 10*300,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
720 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
721 pointsize = 8)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
722 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
723 dev.off()
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
724
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
725 ################################################## 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
726
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
727 #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
728 #qPCRset.R
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
729 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
730 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
731 )
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
732 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
733
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
734 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
735
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
736 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
737
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
738 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
739 switch(imputeMethod,
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
740 "knn"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
741 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
742 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
743 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
744 "mestdagh"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
745 #Mesdagh
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
746 #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
747 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
748 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
749 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
750 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
751 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
752 temp<-exprs(qFiltNAs)
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
753 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
754 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
755 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
756 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
757 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
758 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
759 "cubic"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
760 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
761 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
762 "mean"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
763 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
764 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
765 "median"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
766 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
767 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
768 "nondetects"={
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
769 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
770 },
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
771 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
772 )
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
773
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
774 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
775 }else{
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
776 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
777 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
778
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
779 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
780
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
781 if (DEAMethod=="ttest") {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
782 #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
783 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
784 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
785 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
786 if (DEAMethod=="rp") {
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
787 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
788 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
789 }
185ba61836ab planemo upload for repository https://github.com/igg-molecular-biology-lab/pipe-t.git commit 04049039da97e1c9a8048e732afca48f2741cadf
davidecangelosi
parents:
diff changeset
790 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
791 cat("\n Workflow ended correctly! \n")