6 # Isaak Y Tecle (iyt2@cornell.edu)
14 library(phenoAnalysis
)
18 allArgs
<- commandArgs()
20 outputFiles
<- scan(grep("output_files", allArgs
, value
= TRUE),
23 inputFiles
<- scan(grep("input_files", allArgs
, value
= TRUE),
26 phenoDataFile
<- grep("phenotype_data", inputFiles
, value
= TRUE)
27 message('pheno file: ', phenoDataFile
)
29 traitsFile
<- grep("traits", inputFiles
, value
= TRUE)
30 message('traits file: ', traitsFile
)
33 phenoData
<- fread(phenoDataFile
,
34 na
.strings
=c("NA", "-", " ", ".", ".."))
36 phenoData
<- data
.frame(phenoData
)
38 traits
<- scan(traitsFile
,
41 traits
<- strsplit(traits
, "\t")
44 #needs more work for multi traits anova
45 for (trait
in traits
) {
47 message('trait: ', trait
)
48 anovaFiles
<- grep("anova_table",
52 message('anova file: ', anovaFiles
)
53 anovaHtmlFile
<- grep("html",
57 message('anova html file: ', anovaHtmlFile
)
58 anovaTxtFile
<- grep("txt",
62 message('anova txt file: ', anovaTxtFile
)
63 modelSummFile
<- grep("anova_model",
67 message('model file: ', modelSummFile
)
68 adjMeansFile
<- grep("adj_means",
72 message('means file: ', adjMeansFile
)
75 diagnosticsFile
<- grep("anova_diagnostics",
79 errorFile
<- grep("anova_error",
83 anovaOut
<- runAnova(phenoData
, trait
)
85 if (class(anovaOut
)[1] == 'merModLmerTest') {
87 png(diagnosticsFile
, 960, 480)
89 plot(fitted(anovaOut
), resid(anovaOut
),
92 main
="Fitted values vs Residuals")
94 qqnorm(resid(anovaOut
))
97 anovaTable
<- getAnovaTable(anovaOut
,
102 anovaTable
<- getAnovaTable(anovaOut
,
107 adjMeans
<- getAdjMeans(phenoData
, trait
)
120 cat(anovaOut
, file
=errorFile
)
126 q(save
= "no", runLast
= FALSE)