Mercurial > repos > lecorguille > anova
annotate abims_anova.r @ 11:102049093b7d draft default tip
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 4922313a0e9569326b7723c41babb89f998dbfd9
author | lecorguille |
---|---|
date | Tue, 13 Mar 2018 09:47:21 -0400 |
parents | b147b17759a6 |
children |
rev | line source |
---|---|
0 | 1 #!/usr/local/public/bin/Rscript |
2 # version="1.1" | |
3 | |
4 # date: 06-06-2012 | |
5 # update: 18-02-2014 | |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
6 # **Authors** Gildas Le Corguille ABiMS - UPMC/CNRS - Station Biologique de Roscoff - gildas.lecorguille|at|sb-roscoff.fr |
0 | 7 |
8 # abims_anova.r version 20140218 | |
9 | |
10 library(batch) | |
11 | |
12 | |
13 # function avova | |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
14 anova = function (file, sampleinfo, varinfo, mode="column", condition=1, interaction=F, method="BH", threshold=0.01, selection_method="intersection", sep=";", dec=".", outputdatapvalue="anova.data.output", outputdatasignif="anova.datasignif.output") { |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
15 |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
16 |
0 | 17 if (sep=="tabulation") sep="\t" |
18 if (sep=="semicolon") sep=";" | |
19 if (sep=="comma") sep="," | |
20 | |
21 anova_formula_operator = "+" | |
22 if (interaction) anova_formula_operator = "*" | |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
23 |
0 | 24 # -- import -- |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
25 data=read.table(file, header = TRUE, row.names=1, sep = sep, quote="\"", dec = dec, fill = TRUE, comment.char="",na.strings = "NA", check.names=FALSE) |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
26 |
11
102049093b7d
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 4922313a0e9569326b7723c41babb89f998dbfd9
lecorguille
parents:
10
diff
changeset
|
27 if (mode == "row") {data=t(data)} else {data=as.matrix(data)} |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
28 |
0 | 29 sampleinfoTab=read.table(sampleinfo, header = TRUE, row.names=1, sep = sep, quote="\"") |
30 rownames(sampleinfoTab) = make.names(rownames(sampleinfoTab)) | |
31 | |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
32 varinfoTab=read.table(varinfo, header = TRUE, sep = sep, quote="\"") |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
33 if(sum(colnames(data)!=varinfoTab[,1])!=0){ # if ID not exactly identical |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
34 if(sum(colnames(data)[order(colnames(data))]!=varinfoTab[order(varinfoTab[,1]),1])==0){ |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
35 # reorder data matrix to match variable metadata order |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
36 data = data[,match(varinfoTab[,1],colnames(data))] |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
37 }else{ |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
38 stop(paste0("\nVariables' ID do not match between your data matrix and your variable", |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
39 "metadata file. \nPlease check your data.")) |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
40 } |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
41 } |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
42 |
0 | 43 # -- group -- |
44 match_data_sampleinfoTab = match(rownames(data),rownames(sampleinfoTab)) | |
45 if (sum(is.na(match_data_sampleinfoTab)) > 0) { | |
46 write("ERROR: There is a problem during to match sample names from the data matrix and from the sample info (presence of NA).", stderr()) | |
47 write("You may need to use change the mode (column/row)", stderr()) | |
48 write("10 first sample names in the data matrix:", stderr()) | |
49 write(head(colnames(data)), stderr()) | |
50 write("10 first sample names in the sample info:", stderr()) | |
51 write(head(rownames(sampleinfoTab)), stderr()) | |
52 quit("no",status=10) | |
53 } | |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
54 |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
55 |
0 | 56 # -- anova -- |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
57 |
0 | 58 # formula |
59 grps=list() | |
60 anova_formula_s = "data ~ " | |
61 cat("\ncontrasts:\n") | |
62 for (i in 1:length(condition)) { | |
63 grps[[i]] = factor(sampleinfoTab[,condition[i]][match_data_sampleinfoTab]) | |
64 anova_formula_s = paste(anova_formula_s, "grps[[",i,"]]",anova_formula_operator, sep="") | |
65 cat(condition[i],"\t",levels(grps[[i]]),"\n") | |
66 # write("Current groups: ", stderr()) | |
67 # write(grp[[i]], stderr()) | |
68 } | |
69 anova_formula_s = substr(anova_formula_s, 1, nchar(anova_formula_s)-1) | |
70 anova_formula = as.formula(anova_formula_s) | |
71 | |
72 | |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
73 |
0 | 74 # anova |
75 manovaObjectList = manova(anova_formula) | |
76 manovaList = summary.aov(manovaObjectList) | |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
77 |
0 | 78 # condition renaming |
79 manovaRownames = gsub(" ","",rownames(manovaList[[1]])) | |
80 manovaNbrPvalue = length(manovaRownames)-1 | |
81 manovaRownames = manovaRownames[-(manovaNbrPvalue+1)] | |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
82 |
0 | 83 for (i in 1:length(condition)) { |
84 manovaRownames = sub(paste("grps\\[\\[",i,"\\]\\]",sep=""),condition[i],manovaRownames) | |
85 anova_formula_s = sub(paste("grps\\[\\[",i,"\\]\\]",sep=""),condition[i],anova_formula_s) | |
86 } | |
87 | |
88 # log | |
89 cat("\nanova_formula",anova_formula_s,"\n") | |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
90 |
0 | 91 # p-value |
92 aovPValue = sapply(manovaList,function(x){x[-(manovaNbrPvalue+1),5]}) | |
93 if(length(condition) == 1) aovPValue = t(aovPValue) | |
94 rownames(aovPValue) = paste("pvalue_",manovaRownames,sep="") | |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
95 |
0 | 96 # p-value adjusted |
97 if(length(condition) == 1) { | |
98 aovAdjPValue = t(p.adjust(aovPValue,method=method)) | |
99 } else { | |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
100 aovAdjPValue = t(apply(aovPValue,1,p.adjust, method=method)) |
0 | 101 } |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
102 rownames(aovAdjPValue) = paste("pval.",method,".",manovaRownames,sep="") |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
103 |
0 | 104 # selection |
105 colSumThreshold = colSums(aovAdjPValue <= threshold) | |
106 if (selection_method == "intersection") { | |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
107 datafiltered = data[,colSumThreshold == nrow(aovAdjPValue ), drop=FALSE] |
0 | 108 } else { |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
109 datafiltered = data[,colSumThreshold != 0, drop=FALSE] |
0 | 110 } |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
111 selected.var = rep("no",ncol(data)) |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
112 selected.var[colnames(data)%in%colnames(datafiltered)] = "yes" |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
113 |
0 | 114 #data=rbind(data, aovPValue, aovAdjPValue) |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
115 varinfoTab=cbind(varinfoTab, round(t(aovAdjPValue),10), selected.var) |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
116 |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
117 # group means |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
118 for (i in 1:length(condition)) { |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
119 for(j in levels(grps[[i]])){ |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
120 subgp = rownames(sampleinfoTab[which(sampleinfoTab[,condition[i]]==j),]) |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
121 modmean = colMeans(data[which(rownames(data)%in%subgp),],na.rm=TRUE) |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
122 varinfoTab=cbind(varinfoTab, modmean) |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
123 colnames(varinfoTab)[ncol(varinfoTab)] = paste0("Mean_",condition[i],".",j) |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
124 } |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
125 } |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
126 colnames(varinfoTab) = make.unique(colnames(varinfoTab)) |
0 | 127 |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
128 # pdf for significant variables |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
129 pdf(outputdatasignif) |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
130 ### Venn diagram |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
131 if(nrow(aovAdjPValue)>5){ |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
132 pie(100,labels=NA,main=paste0("Venn diagram only available for maximum 5 terms\n", |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
133 "(your analysis concerns ",nrow(aovAdjPValue)," terms)\n\n", |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
134 "Number of significant variables relatively to\nyour chosen threshold and ", |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
135 "selection method: ",ncol(datafiltered)),cex.main=0.8) |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
136 }else{ |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
137 vennlist = list(NULL) |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
138 names(vennlist) = rownames(aovAdjPValue)[1] |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
139 if(length(colnames(aovAdjPValue))==0){colnames(aovAdjPValue)=varinfoTab[,1]} |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
140 for(i in 1:nrow(aovAdjPValue)){ |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
141 vennlist[[rownames(aovAdjPValue)[i]]]=colnames(aovAdjPValue[i,which(aovAdjPValue[i,]<=threshold),drop=FALSE]) |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
142 } |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
143 if(length(vennlist)==0){ pie(100,labels=NA,main="No significant ions was found.") |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
144 }else{ library(venn) ; venn(vennlist, zcolor="style", cexil=2, cexsn=1.5) } |
0 | 145 } |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
146 ### Boxplot |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
147 par(mfrow=c(2,2),mai=rep(0.5,4)) |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
148 data <- as.data.frame(data) |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
149 for(i in 1:nrow(aovAdjPValue)){ |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
150 factmain = gsub(paste0("pval.",method,"."),"",rownames(aovAdjPValue)[i]) |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
151 factsignif = aovAdjPValue[i,which(aovAdjPValue[i,]<=threshold),drop=FALSE] |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
152 if((ncol(factsignif)!=0)&(factmain%in%colnames(sampleinfoTab))){ |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
153 for(j in 1:ncol(factsignif)){ |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
154 varsignif = gsub(" Response ","",colnames(factsignif)[j]) |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
155 boxplot(as.formula(paste0("data$",varsignif," ~ sampleinfoTab$",factmain)), |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
156 main=paste0(factmain,"\n",varsignif), col="grey", mai=7) |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
157 } |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
158 } |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
159 } |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
160 dev.off() |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
161 |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
162 # summary for significant variables |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
163 cat("\n\n- - - - - - - number of significant variables - - - - - - -\n\n") |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
164 for(i in 1:nrow(aovAdjPValue)){ |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
165 cat(rownames(aovAdjPValue)[i],"-", |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
166 sum(aovAdjPValue[i,]<=threshold),"significant variable(s)\n") |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
167 } |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
168 cat("\nIf some of your factors are missing here, this may be due to\neffects", |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
169 "not estimable; your design may not be balanced enough.\n") |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
170 |
0 | 171 # -- output / return -- |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
172 write.table(varinfoTab, outputdatapvalue, sep=sep, quote=F, row.names=FALSE) |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
173 |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
174 # log |
0 | 175 cat("\nthreshold:",threshold,"\n") |
10
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
176 cat("result:",ncol(datafiltered),"/",ncol(data),"\n\n") |
b147b17759a6
planemo upload for repository https://github.com/workflow4metabolomics/anova commit 28838bb8dafd6d286157db77f181ed8a1b586664
lecorguille
parents:
0
diff
changeset
|
177 |
0 | 178 quit("no",status=0) |
179 } | |
180 | |
181 # log | |
182 cat("ANOVA\n\n") | |
183 cat("Arguments\n") | |
184 args <- commandArgs(trailingOnly = TRUE) | |
185 print(args) | |
186 | |
187 listArguments = parseCommandArgs(evaluate=FALSE) | |
188 do.call(anova, listArguments) |