Mercurial > repos > vmarcon > normalization
annotate normalization.R @ 0:79f00bc83ecc draft default tip
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
author | vmarcon |
---|---|
date | Thu, 18 Jan 2018 06:20:30 -0500 |
parents | |
children |
rev | line source |
---|---|
0
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
1 # R Script implementing different kind of normalisation |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
2 # Input : a file containing a table with numeric values |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
3 # except for the first column containing sample names |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
4 # and the first line containing variable names |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
5 # separator expected is <TAB> |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
6 # |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
7 # Normalization method : |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
8 # log, DESeq2, Rlog, Standard_score, Pareto, TSS, TSS+CLR, Pareto |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
9 # |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
10 # Ouptut : input table with values normalized according |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
11 # to the normalization procedure chosen |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
12 #----------------------------------------------------------------- |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
13 # Authors : luc.jouneau(at)inra.fr |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
14 # valentin.marcon(at)inra.fr |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
15 # Version : 0.9 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
16 # Date : 30/08/2017 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
17 #----------------------------------------------------------------- |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
18 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
19 normalization=function( |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
20 ########################################################## |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
21 # Function input |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
22 ########################################################## |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
23 #Possible values : "log", "DESeq2", "Rlog", "Standard_score", "Pareto", "TSS", "TSS_CLR" |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
24 transformation_method="Standard_score", |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
25 na_encoding="NA", |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
26 #Path to file containg table of values (separator="tab") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
27 input_file="", |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
28 #Path to file produced after transformation |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
29 output_file="out/table_out.txt", |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
30 #Path to file containing messages for user if something bad happens |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
31 log_file="log/normalization_report.html", |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
32 #Boolean flag (0/1) indicating if variables are in line or in columns |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
33 variable_in_line="1") { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
34 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
35 ########################################################## |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
36 # Read and verify data |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
37 ########################################################## |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
38 #1°) Checks valids for all modules |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
39 if (variable_in_line=="1") { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
40 column_use="individual" |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
41 line_use="variable" |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
42 } else { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
43 line_use="individual" |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
44 column_use="variable" |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
45 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
46 log_error=function(message="") { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
47 cat("<HTML><HEAD><TITLE>Normalization report</TITLE></HEAD><BODY>\n",file=log_file,append=F,sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
48 cat("⚠ An error occurred while trying to read your table.\n<BR>",file=log_file,append=T,sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
49 cat("Please check that:\n<BR>",file=log_file,append=T,sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
50 cat("<UL>\n",file=log_file,append=T,sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
51 cat(" <LI> the table you want to process contains the same number of columns for each line</LI>\n",file=log_file,append=T,sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
52 cat(" <LI> the first line of your table is a header line (specifying the name of each ",column_use,")</LI>\n",file=log_file,append=T,sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
53 cat(" <LI> the first column of your table specifies the name of each ",line_use,"</LI>\n",file=log_file,append=T,sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
54 cat(" <LI> both individual and variable names should be unique</LI>\n",file=log_file,append=T,sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
55 cat(" <LI> each value is separated from the other by a <B>TAB</B> character</LI>\n",file=log_file,append=T,sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
56 cat(" <LI> except for first line and first column, table should contain a numeric value</LI>\n",file=log_file,append=T,sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
57 cat(" <LI> this value may contain character '.' as decimal separator or '",na_encoding,"' for missing values</LI>\n",file=log_file,append=T,sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
58 cat("</UL>\n",file=log_file,append=T,sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
59 cat("-------<BR>\nError messages recieved :<BR><FONT color=red>\n",conditionMessage(message),"</FONT>\n",file=log_file,append=T,sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
60 cat("</BODY></HTML>\n",file=log_file,append=T,sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
61 q(save="no",status=1) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
62 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
63 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
64 tab_in=tryCatch( |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
65 { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
66 tab_in=read.table(file=input_file,sep="\t",header=T,quote="\"",na.strings=na_encoding,check.names=FALSE) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
67 }, |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
68 error=function(cond) { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
69 log_error(message=cond) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
70 return(NA) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
71 }, |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
72 warning=function(cond) { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
73 log_error(message=cond) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
74 return(NA) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
75 }, |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
76 finally={ |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
77 #Do nothing special |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
78 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
79 ) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
80 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
81 if (ncol(tab_in)<2) { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
82 log_error(simpleCondition("The table you want to normalize contains less than two columns.")) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
83 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
84 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
85 rn=as.character(tab_in[,1]) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
86 if (length(rn)!=length(unique(rn))) { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
87 duplicated_rownames=table(rn) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
88 duplicated_rownames=duplicated_rownames[duplicated_rownames>1] |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
89 duplicated_rownames=names(duplicated_rownames) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
90 if (length(duplicated_rownames)>3) { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
91 duplicated_rownames=c(duplicated_rownames[1:3],"...") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
92 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
93 duplicated_rownames=paste(duplicated_rownames,collapse=", ") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
94 log_error(simpleCondition( |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
95 paste("The table you want to normalize have duplicated values in the first column (", |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
96 line_use," names) - duplicated ",line_use," names : ",duplicated_rownames,sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
97 )) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
98 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
99 tab=tab_in[,-1] |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
100 rownames(tab)=rn |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
101 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
102 #Check all columns are numeric |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
103 tab=as.matrix(tab) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
104 cell.with.na=c() |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
105 for (i in 1:ncol(tab)) { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
106 na.v1=is.na(tab[,i]) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
107 na.v2=is.na(as.numeric(tab[,i])) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
108 if (sum(na.v1)!=sum(na.v2)) { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
109 sel=which(na.v1!=na.v2) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
110 sel=sel[1] |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
111 value=tab[sel,i] |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
112 log_error(simpleCondition( |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
113 paste("Column '",colnames(tab)[i],"' of your table contains non numeric values. Please check its content (on line #",sel," : value='",value,"').",sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
114 )) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
115 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
116 if (length(cell.with.na)==0 & sum(na.v1)!=0) { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
117 cell.with.na=c(i,which(na.v1)[1]) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
118 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
119 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
120 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
121 #2°) Checks only valid for normalization module |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
122 if (transformation_method %in% c("DESeq2","Rlog")) { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
123 #Check there is no missing values |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
124 if (length(cell.with.na)!=0) { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
125 log_error(simpleCondition( |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
126 paste("Column '",colnames(tab)[cell.with.na[1]],"' of your table contains missing values (see line #",cell.with.na[2],").\n", |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
127 transformation_method," normalization does not accept missing values. ",sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
128 )) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
129 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
130 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
131 if (transformation_method %in% c("DESeq2","Rlog","TSS","TSS_CLR")) { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
132 #Check values are integer |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
133 for (i in 1:ncol(tab)) { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
134 if (!is.integer(tab[,i])) { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
135 sel=which(!is.integer(tab[,i])) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
136 sel=sel[1] |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
137 value=tab[sel,i] |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
138 log_error(simpleCondition( |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
139 paste("Column '",colnames(tab)[i],"' of your table contains non integer values.\n", |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
140 transformation_method," normalization only accepts integer values. ", |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
141 "Please check its content (on line #",sel," : value=",value,").",sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
142 )) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
143 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
144 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
145 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
146 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
147 if (transformation_method %in% c("log","TSS","TSS_CLR","DESeq2","Rlog")) { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
148 #Check values are positive |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
149 for (i in 1:ncol(tab)) { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
150 if (sum(tab[,i]>=0 | is.na(tab[,i]))!=nrow(tab)) { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
151 sel=which(tab[,i]<0) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
152 sel=sel[1] |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
153 value=tab[sel,i] |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
154 log_error(simpleCondition( |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
155 paste("Column '",colnames(tab)[i],"' of your table contains negative values.\n", |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
156 transformation_method," normalization only accepts positive or null values. ", |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
157 "Please check its content (on line #",sel," : value=",value,").",sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
158 )) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
159 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
160 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
161 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
162 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
163 ########################################################## |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
164 # End of data checks |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
165 ########################################################## |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
166 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
167 ### Transpose if variable are in line ### |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
168 if (variable_in_line=="1") { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
169 #Transpose matrix |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
170 tab=t(tab) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
171 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
172 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
173 ########################################################## |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
174 ### Value transformation |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
175 ########################################################## |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
176 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
177 #Avoid null values when there is a log transformation |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
178 na.replaced=c() |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
179 log.transformed=FALSE |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
180 if (transformation_method %in% c("log","TSS_CLR")) { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
181 log.transformed=TRUE |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
182 for (idx_col in 1:ncol(tab)) { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
183 sel=tab[,idx_col]==0 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
184 na.replaced=cbind(na.replaced,sel) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
185 tab[sel,idx_col]=1e-2 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
186 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
187 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
188 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
189 ### log ### |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
190 if (transformation_method=="log") { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
191 tab=log2(tab) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
192 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
193 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
194 ### DESeq2 or Rlog ### |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
195 if (transformation_method %in% c("DESeq2","Rlog")) { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
196 library(DESeq2) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
197 n <- ncol(tab) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
198 dds <- DESeqDataSetFromMatrix(tab, |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
199 colData = data.frame(condition = c("a", rep("b", n - 1))), |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
200 design = formula(~ condition)) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
201 colnames(dds) <- colnames(tab) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
202 dds <- estimateSizeFactors(dds) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
203 tab <- switch(transformation_method, |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
204 DESeq2 = counts(dds, normalized = TRUE), |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
205 Rlog = assay(rlogTransformation(dds)) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
206 ) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
207 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
208 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
209 ### Standard_score ### |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
210 if (transformation_method=="Standard_score") { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
211 tab=scale(tab) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
212 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
213 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
214 ### Pareto ### |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
215 if (transformation_method=="Pareto") { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
216 tab.centered <- apply(tab, 2, function(x) x - mean(x,na.rm=TRUE)) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
217 tab.sc <- apply(tab.centered, 2, function(x) x/sqrt(sd(x,na.rm=TRUE))) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
218 tab=tab.sc |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
219 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
220 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
221 ### TSS ### |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
222 if (transformation_method=="TSS") { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
223 tab= t(apply(tab, 1, function(x) x/sum(x,na.rm=TRUE))) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
224 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
225 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
226 ### TSS + CLR avec function de mixOmics ### |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
227 if (transformation_method=="TSS_CLR") { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
228 #From http://stackoverflow.com/questions/2602583/geometric-mean-is-there-a-built-in |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
229 geometric.mean = function(x, na.rm=TRUE){ |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
230 exp(sum(log(x[x > 0]), na.rm=na.rm) / length(x)) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
231 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
232 tab = t(apply(tab+1e-2,1,function(x) log(x/geometric.mean(x,na.rm=TRUE)))) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
233 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
234 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
235 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
236 #If there is a log transformation put 0 where there was NA |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
237 if (log.transformed) { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
238 for (idx_col in 1:ncol(tab)) { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
239 tab[na.replaced[,idx_col],idx_col]=0 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
240 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
241 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
242 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
243 #If there are missing values, replace it with NA_enconding |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
244 for (idx_col in 1:ncol(tab)) { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
245 sel=is.na(tab[,idx_col]) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
246 tab[sel,idx_col]=na_encoding |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
247 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
248 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
249 ########################################################## |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
250 # Prepare and write output table |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
251 ########################################################## |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
252 if (variable_in_line=="1") { |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
253 #Transpose matrix again |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
254 tab=t(tab) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
255 } |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
256 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
257 tab_out=cbind(rownames(tab),tab) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
258 colnames(tab_out)[1]=colnames(tab_in)[1] |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
259 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
260 write.table(file=output_file,tab_out,sep="\t",row.names=F,quote=F) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
261 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
262 ########################################################## |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
263 # Treatment successfull |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
264 ########################################################## |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
265 cat("<HTML><HEAD><TITLE>Normalization report</TITLE></HEAD><BODY>\n",file=log_file,append=F,sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
266 cat(paste("➔ You choose to apply the transformation method :",transformation_method,"<BR>"),file=log_file,append=F,sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
267 cat("✓ Your normalization process is successfull !<BR>",file=log_file,append=T,sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
268 cat("</BODY></HTML>\n",file=log_file,append=T,sep="") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
269 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
270 q(save="no",status=0) |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
271 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
272 } # end of function |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
273 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
274 ########################################################## |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
275 # Test |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
276 ########################################################## |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
277 #Used for debug : LJO 6/3/2017 |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
278 #normalization() |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
279 #setwd("H:/INRA/cati/groupe stats/Galaxy/normalisation") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
280 #normalization(transformation_method="Standard_score",na_encoding="NA",input_file="datasets/valid - decathlon.txt",output_file="out/table_out.txt",log_file="log/normalization.html",variable_in_line="0") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
281 #normalization(transformation_method="Pareto",na_encoding="NA",input_file="datasets/valid - decathlon.txt",output_file="out/table_out.txt",log_file="log/normalization.html",variable_in_line="1") |
79f00bc83ecc
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
282 |