2 ##First read in the arguments listed at the command line
5 ##args is now a list of character vectors
6 ## First check to see if arguments are passed.
7 ## Then cycle through each element of the list and evaluate the expressions.
9 print("No arguments supplied.")
10 ##supply default values
14 for(i in 1:length(args)){
15 eval(parse(text=args[[i]]))
19 workdir = dirname(datafile);
26 library(phenoAnalysis)
30 pd = read.csv(datafile, sep="\t")
31 source(paramfile) # should give us dependent_variable and the model
33 pd$studyYear = as.factor(pd$studyYear)
34 print(paste("MODEL :", model))
37 dependent_variable = gsub(" ", "\\.", dependent_variable) # replace space with "." in variable name
38 dependent_variable = gsub("\\|", "\\.", dependent_variable) # replace | with .
39 dependent_variable = gsub("\\:", "\\.", dependent_variable)
40 dependent_variable = gsub("\\-", "\\.", dependent_variable)
41 dependent_variable = gsub("\\/", "\\.", dependent_variable)
42 print(paste("Dependent variable : ", dependent_variable))
43 model_string = paste(dependent_variable, '~', model)
45 print(paste('MODEL STRING:', model_string));
46 model = lmer(as.formula(model_string), data=pd)
49 #model_summary = summary(allEffects(model,se=T))
54 genotypeEffectType = as.vector(str_match(model_string, '1\\|germplasmName'))
55 genotypeEffectType = ifelse(is.na(genotypeEffectType), 'fixed', 'random')
56 print(paste('modeling genotypes as: ', genotypeEffectType))
58 adjusted_means = getAdjMeans(modelOut=model,
59 traitName=dependent_variable,
60 genotypeEffectType=genotypeEffectType,
61 adjMeansVariable='germplasmName')
63 print(head(adjusted_means))
65 outfile = paste(datafile, ".results", sep="")
69 print(colnames(model))
73 #write.table(ranef(model)$germplasmName)
75 write.table(select(adjusted_means, 'germplasmName', dependent_variable), row.names = F)