annotate maaslin-4450aa4ecc84/src/test-BoostGLM/test-BoostGLM.R @ 2:589169d452c0

Uploaded
author george-weingart
date Sun, 08 Feb 2015 23:21:34 -0500
parents a87d5a5f2776
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
1 c_strDir <- file.path(getwd( ),"..")
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
2
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
3 source(file.path(c_strDir,"lib","Constants.R"))
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
4 source(file.path(c_strDir,"lib","Utility.R"))
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
5 source(file.path(c_strDir,"lib","AnalysisModules.R"))
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
6
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
7 # General setup
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
8 covX1 = c(44.4, 45.9, 41.9, 53.3, 44.7, 44.1, 50.7, 45.2, 60.1)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
9 covX2 = c(144.4, 245.9, 141.9, 253.3, 144.7, 244.1, 150.7, 245.2, 160.1)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
10 covX3 = as.factor(c(1,2,3,1,2,3,1,2,3))
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
11 covX4 = as.factor(c(1,1,1,1,2,2,2,2,2))
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
12 covX5 = as.factor(c(1,2,1,2,1,2,1,2,1))
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
13 covY = c(.26, .31, .25, .50, .36, .40, .52, .28, .38)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
14 frmeTmp = data.frame(Covariate1=covX1, Covariate2=covX2, Covariate3=covX3, Covariate4=covX4, Covariate5=covX5, adCur= covY)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
15 iTaxon = 6
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
16
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
17 lsCov1 = list()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
18 lsCov1$name = "Covariate1"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
19 lsCov1$orig = "Covariate1"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
20 lsCov1$taxon = "adCur"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
21 lsCov1$data = covY
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
22 lsCov1$factors = "Covariate1"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
23 lsCov1$metadata = covX1
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
24 vdCoef = c()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
25 vdCoef["(Intercept)"]=round(0.0345077486,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
26 vdCoef["Covariate1"]= round(0.0052097355,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
27 vdCoef["Covariate2"]= round(0.0005806568,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
28 vdCoef["Covariate32"]=round(-0.1333421874,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
29 vdCoef["Covariate33"]=round(-0.1072006419,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
30 vdCoef["Covariate42"]=round(0.0849198280,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
31 lsCov1$value = c(Covariate1=round(0.005209736,5))
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
32 lsCov1$std = round(0.0063781728,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
33 lsCov1$allCoefs = vdCoef
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
34 lsCov2 = list()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
35 lsCov2$name = "Covariate2"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
36 lsCov2$orig = "Covariate2"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
37 lsCov2$taxon = "adCur"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
38 lsCov2$data = covY
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
39 lsCov2$factors = "Covariate2"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
40 lsCov2$metadata = covX2
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
41 lsCov2$value = c(Covariate2=round(0.0005806568,5))
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
42 lsCov2$std = round(0.0006598436,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
43 lsCov2$allCoefs = vdCoef
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
44 lsCov3 = list()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
45 lsCov3$name = "Covariate3"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
46 lsCov3$orig = "Covariate32"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
47 lsCov3$taxon = "adCur"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
48 lsCov3$data = covY
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
49 lsCov3$factors = "Covariate3"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
50 lsCov3$metadata = covX3
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
51 lsCov3$value = c(Covariate32=round(-0.1333422,5))
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
52 lsCov3$std = round(0.0895657826,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
53 lsCov3$allCoefs = vdCoef
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
54 lsCov4 = list()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
55 lsCov4$name = "Covariate3"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
56 lsCov4$orig = "Covariate33"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
57 lsCov4$taxon = "adCur"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
58 lsCov4$data = covY
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
59 lsCov4$factors = "Covariate3"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
60 lsCov4$metadata = covX3
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
61 lsCov4$value = c(Covariate33=round(-0.1072006,5))
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
62 lsCov4$std = round(0.0792209541,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
63 lsCov4$allCoefs = vdCoef
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
64 lsCov5 = list()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
65 lsCov5$name = "Covariate4"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
66 lsCov5$orig = "Covariate42"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
67 lsCov5$taxon = "adCur"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
68 lsCov5$data = covY
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
69 lsCov5$factors = "Covariate4"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
70 lsCov5$metadata = covX4
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
71 lsCov5$value = c(Covariate42=round(0.08491983,5))
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
72 lsCov5$std = round(0.0701018621,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
73 lsCov5$allCoefs = vdCoef
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
74
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
75 context("Test funcClean")
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
76
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
77 context("Test funcBugHybrid")
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
78 # multiple covariates, one call lm
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
79 aiMetadata = c(1:5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
80 aiData = c(iTaxon)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
81 dFreq = 0.5 / length( aiMetadata )
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
82 dSig = 0.25
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
83 dMinSamp = 0.1
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
84 adP = c()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
85 lsSig = list()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
86 funcReg = NA
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
87 funcAnalysis = funcLM
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
88 funcGetResult = funcGetLMResults
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
89 lsData = list(frmeData=frmeTmp, aiMetadata=aiMetadata, aiData=aiData, lsQCCounts=list())
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
90 lsData$astrMetadata = names(frmeTmp)[aiMetadata]
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
91
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
92 adPExpected = round(c(0.4738687,0.4436566,0.4665972,0.5378693,0.3124672),5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
93 QCExpected = list(iLms=numeric(0))
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
94 lsSigExpected = list()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
95 lsSigExpected[[1]] = lsCov1
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
96 lsSigExpected[[2]] = lsCov2
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
97 lsSigExpected[[3]] = lsCov3
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
98 lsSigExpected[[4]] = lsCov4
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
99 lsSigExpected[[5]] = lsCov5
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
100 expectedReturn = list(adP=adPExpected,lsSig=lsSigExpected,lsQCCounts=QCExpected)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
101 receivedReturn = funcBugHybrid(iTaxon=iTaxon,frmeData=frmeTmp,lsData=lsData,aiMetadata=aiMetadata,dFreq=dFreq,dSig=dSig,dMinSamp=dMinSamp,adP=adP,lsSig=lsSig, strLog=NA,funcReg=funcReg,lsNonPenalizedPredictors=NULL,funcAnalysis=funcAnalysis,lsRandomCovariates=NULL,funcGetResult=funcGetResult)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
102 receivedReturn$adP = round(receivedReturn$adP,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
103
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
104 vCoefs=receivedReturn$lsSig[[1]]$allCoefs
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
105 vCoefs[1]=round(vCoefs[1],5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
106 vCoefs[2]=round(vCoefs[2],5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
107 vCoefs[3]=round(vCoefs[3],5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
108 vCoefs[4]=round(vCoefs[4],5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
109 vCoefs[5]=round(vCoefs[5],5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
110 vCoefs[6]=round(vCoefs[6],5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
111 receivedReturn$lsSig[[1]]$allCoefs=vCoefs
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
112 receivedReturn$lsSig[[2]]$allCoefs=vCoefs
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
113 receivedReturn$lsSig[[3]]$allCoefs=vCoefs
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
114 receivedReturn$lsSig[[4]]$allCoefs=vCoefs
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
115 receivedReturn$lsSig[[5]]$allCoefs=vCoefs
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
116 vValue=c()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
117 vValue[receivedReturn$lsSig[[1]]$orig]=round(receivedReturn$lsSig[[1]]$value[[1]],5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
118 receivedReturn$lsSig[[1]]$value=vValue
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
119 vValue=c()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
120 vValue[receivedReturn$lsSig[[2]]$orig]=round(receivedReturn$lsSig[[2]]$value[[1]],5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
121 receivedReturn$lsSig[[2]]$value=vValue
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
122 vValue=c()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
123 vValue[receivedReturn$lsSig[[3]]$orig]=round(receivedReturn$lsSig[[3]]$value[[1]],5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
124 receivedReturn$lsSig[[3]]$value=vValue
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
125 vValue=c()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
126 vValue[receivedReturn$lsSig[[4]]$orig]=round(receivedReturn$lsSig[[4]]$value[[1]],5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
127 receivedReturn$lsSig[[4]]$value=vValue
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
128 vValue=c()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
129 vValue[receivedReturn$lsSig[[5]]$orig]=round(receivedReturn$lsSig[[5]]$value[[1]],5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
130 receivedReturn$lsSig[[5]]$value=vValue
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
131 receivedReturn$lsSig[[1]]$std=round(receivedReturn$lsSig[[1]]$std,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
132 receivedReturn$lsSig[[2]]$std=round(receivedReturn$lsSig[[2]]$std,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
133 receivedReturn$lsSig[[3]]$std=round(receivedReturn$lsSig[[3]]$std,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
134 receivedReturn$lsSig[[4]]$std=round(receivedReturn$lsSig[[4]]$std,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
135 receivedReturn$lsSig[[5]]$std=round(receivedReturn$lsSig[[5]]$std,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
136 test_that("funcBugHybrid works with the lm option with multiple covariates.",{expect_equal(receivedReturn,expectedReturn)})
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
137
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
138
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
139 # single covariate, single call lm
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
140 aiMetadata = c(1)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
141 dFreq = 0.5 / length( aiMetadata )
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
142 lsData$astrMetadata = names(frmeTmp)[aiMetadata]
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
143 adPExpected = round(c(0.1081731),5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
144 QCExpected = list(iLms=numeric(0))
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
145 lsSigExpected = list()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
146 lsSigExpected[[1]] = lsCov1
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
147 lsSigExpected[[1]]$std=round(0.005278468,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
148 vdCoef = c()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
149 vdCoef["(Intercept)"]=round(-0.102410716,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
150 vdCoef["Covariate1"]= round(0.009718095,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
151 lsSigExpected[[1]]$allCoefs= vdCoef
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
152 lsSigExpected[[1]]$value = c(Covariate1=round(0.009718095,5))
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
153
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
154 expectedReturn = list(adP=adPExpected,lsSig=lsSigExpected,lsQCCounts=QCExpected)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
155 receivedReturn = funcBugHybrid(iTaxon=iTaxon,frmeData=frmeTmp,lsData=lsData,aiMetadata=aiMetadata,dFreq=dFreq,dSig=dSig,dMinSamp=dMinSamp,adP=adP,lsSig=lsSig, strLog=NA,funcReg=funcReg,lsNonPenalizedPredictors=NULL,funcAnalysis=funcAnalysis,lsRandomCovariates=NULL,funcGetResult=funcGetResult)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
156 receivedReturn$adP = round(receivedReturn$adP,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
157
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
158 vCoefs=receivedReturn$lsSig[[1]]$allCoefs
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
159 vCoefs[1]=round(vCoefs[1],5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
160 vCoefs[2]=round(vCoefs[2],5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
161 receivedReturn$lsSig[[1]]$allCoefs=vCoefs
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
162 vValue=c()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
163 vValue[receivedReturn$lsSig[[1]]$orig]=round(receivedReturn$lsSig[[1]]$value[[1]],5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
164 receivedReturn$lsSig[[1]]$value=vValue
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
165 receivedReturn$lsSig[[1]]$std=round(0.005278468,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
166 test_that("funcBugHybrid works with the lm option with 1 covariates.",{expect_equal(receivedReturn,expectedReturn)})
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
167
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
168
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
169 # multiple covariate, single call univariate
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
170 funcReg = NA
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
171 funcAnalysis = funcDoUnivariate
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
172 funcGetResult = NA
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
173 aiMetadata = c(3,1,2)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
174 dFreq = 0.5 / length( aiMetadata )
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
175 lsData$astrMetadata = names(frmeTmp)[aiMetadata]
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
176 adPExpected = round(c(1.0,1.0,0.09679784,0.21252205),5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
177 QCExpected = list(iLms=numeric(0))
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
178 lsSigExpected = list()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
179 lsCov1 = list()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
180 lsCov1$name = "Covariate3"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
181 lsCov1$orig = "Covariate32"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
182 lsCov1$taxon = "adCur"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
183 lsCov1$data = covY
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
184 lsCov1$factors = "Covariate3"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
185 lsCov1$metadata = frmeTmp[["Covariate3"]]
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
186 vdCoef = c(Covariate32=NA)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
187 lsCov1$value = vdCoef
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
188 lsCov1$std = sd(frmeTmp[["Covariate3"]])
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
189 lsCov1$allCoefs = vdCoef
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
190 lsCov2 = list()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
191 lsCov2$name = "Covariate3"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
192 lsCov2$orig = "Covariate33"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
193 lsCov2$taxon = "adCur"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
194 lsCov2$data = covY
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
195 lsCov2$factors = "Covariate3"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
196 lsCov2$metadata = frmeTmp[["Covariate3"]]
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
197 vdCoef = c(Covariate33=NA)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
198 lsCov2$value = vdCoef
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
199 lsCov2$std = sd(frmeTmp[["Covariate3"]])
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
200 lsCov2$allCoefs = vdCoef
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
201 lsCov3 = list()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
202 lsCov3$name = "Covariate1"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
203 lsCov3$orig = "Covariate1"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
204 lsCov3$taxon = "adCur"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
205 lsCov3$data = covY
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
206 lsCov3$factors = "Covariate1"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
207 lsCov3$metadata = frmeTmp[["Covariate1"]]
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
208 vdCoef = c(Covariate1=0.6)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
209 lsCov3$value = vdCoef
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
210 lsCov3$std = sd(frmeTmp[["Covariate1"]])
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
211 lsCov3$allCoefs = vdCoef
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
212 lsCov4 = list()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
213 lsCov4$name = "Covariate2"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
214 lsCov4$orig = "Covariate2"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
215 lsCov4$taxon = "adCur"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
216 lsCov4$data = covY
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
217 lsCov4$factors = "Covariate2"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
218 lsCov4$metadata = frmeTmp[["Covariate2"]]
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
219 vdCoef = c(Covariate2=0.46666667)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
220 lsCov4$value = vdCoef
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
221 lsCov4$std = sd(frmeTmp[["Covariate2"]])
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
222 lsCov4$allCoefs = vdCoef
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
223
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
224 lsSigExpected = list()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
225 lsSigExpected[[1]] = lsCov1
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
226 lsSigExpected[[2]] = lsCov2
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
227 lsSigExpected[[3]] = lsCov3
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
228 lsSigExpected[[4]] = lsCov4
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
229
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
230 expectedReturn = list(adP=adPExpected,lsSig=lsSigExpected,lsQCCounts=QCExpected)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
231 receivedReturn = funcBugHybrid(iTaxon=iTaxon,frmeData=frmeTmp,lsData=lsData,aiMetadata=aiMetadata,dFreq=dFreq,dSig=dSig,dMinSamp=dMinSamp,adP=adP,lsSig=lsSig, strLog=NA,funcReg=funcReg,lsNonPenalizedPredictors=NULL,funcAnalysis=funcAnalysis,lsRandomCovariates=NULL,funcGetResult=funcGetResult)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
232 receivedReturn$adP = round(receivedReturn$adP,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
233 test_that("funcBugHybrid works with the univariate option with 3 covariates.",{expect_equal(receivedReturn,expectedReturn)})
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
234
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
235
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
236 # single covariate, single call univariate
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
237 funcReg = NA
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
238 funcAnalysis = funcDoUnivariate
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
239 funcGetResult = NA
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
240 aiMetadata = c(1)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
241 dFreq = 0.5 / length( aiMetadata )
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
242 lsData$astrMetadata = names(frmeTmp)[aiMetadata]
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
243 adPExpected = round(c(0.09679784),5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
244 QCExpected = list(iLms=numeric(0))
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
245 lsSigExpected = list()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
246 lsSigExpected[[1]] = lsCov3
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
247
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
248 expectedReturn = list(adP=adPExpected,lsSig=lsSigExpected,lsQCCounts=QCExpected)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
249 receivedReturn = funcBugHybrid(iTaxon=iTaxon,frmeData=frmeTmp,lsData=lsData,aiMetadata=aiMetadata,dFreq=dFreq,dSig=dSig,dMinSamp=dMinSamp,adP=adP,lsSig=lsSig, strLog=NA,funcReg=funcReg,lsNonPenalizedPredictors=NULL,funcAnalysis=funcAnalysis,lsRandomCovariates=NULL,funcGetResult=funcGetResult)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
250 receivedReturn$adP = round(receivedReturn$adP,5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
251 test_that("funcBugHybrid works with the univariate option with 1 covariates.",{expect_equal(receivedReturn,expectedReturn)})
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
252
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
253
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
254 context("Test funcBugs")
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
255 #One LM run
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
256 frmeData=frmeTmp
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
257 aiMetadata=c(1)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
258 aiData=c(iTaxon)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
259 strData=NA
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
260 dFreq= 0.5 / length( aiMetadata )
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
261 dSig=0.25
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
262 dMinSamp=0.1
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
263 strDirOut=NA
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
264 funcReg=NA
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
265 lsNonPenalizedPredictors=NULL
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
266 lsRandomCovariates=NULL
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
267 funcAnalysis=funcLM
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
268 funcGetResults=funcGetLMResults
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
269 fDoRPlot=FALSE
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
270 lsData = list(frmeData=frmeData, aiMetadata=aiMetadata, aiData=aiData, lsQCCounts=list())
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
271 lsData$astrMetadata = names(frmeTmp)[aiMetadata]
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
272 QCExpected = list(iLms=numeric(0))
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
273
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
274 expectedReturn = list(aiReturnBugs=aiData,lsQCCounts=QCExpected)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
275 receivedReturn = funcBugs(frmeData=frmeData, lsData=lsData, aiMetadata=aiMetadata, aiData=aiData, strData=strData, dFreq=dFreq, dSig=dSig, dMinSamp=dMinSamp,strDirOut=strDirOut, funcReg=funcReg,lsNonPenalizedPredictors=lsNonPenalizedPredictors,funcAnalysis=funcAnalysis,lsRandomCovariates=lsRandomCovariates,funcGetResults=funcGetResults,fDoRPlot=fDoRPlot)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
276
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
277 test_that("funcBugs works with the lm option with 1 covariate.",{expect_equal(receivedReturn,expectedReturn)})
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
278
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
279 #multiple LM run
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
280 frmeData=frmeTmp
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
281 aiMetadata=c(1:5)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
282 aiData=c(iTaxon)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
283 strData=NA
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
284 dFreq= 0.5 / length( aiMetadata )
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
285 dSig=0.25
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
286 dMinSamp=0.1
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
287 strDirOut=NA
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
288 funcReg=NA
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
289 lsNonPenalizedPredictors=NULL
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
290 lsRandomCovariates=NULL
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
291 funcAnalysis=funcLM
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
292 funcGetResults=funcGetLMResults
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
293 fDoRPlot=FALSE
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
294 lsData = list(frmeData=frmeData, aiMetadata=aiMetadata, aiData=aiData, lsQCCounts=list())
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
295 lsData$astrMetadata = names(frmeTmp)[aiMetadata]
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
296 QCExpected = list(iLms=numeric(0))
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
297
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
298 expectedReturn = list(aiReturnBugs=aiData,lsQCCounts=QCExpected)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
299 receivedReturn = funcBugs(frmeData=frmeData, lsData=lsData, aiMetadata=aiMetadata, aiData=aiData, strData=strData, dFreq=dFreq, dSig=dSig, dMinSamp=dMinSamp,strDirOut=strDirOut, funcReg=funcReg,lsNonPenalizedPredictors=lsNonPenalizedPredictors,funcAnalysis=funcAnalysis,lsRandomCovariates=lsRandomCovariates,funcGetResults=funcGetResults,fDoRPlot=fDoRPlot)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
300
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
301 print("START START")
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
302 print(expectedReturn)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
303 print("RECEIVED")
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
304 print(receivedReturn)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
305 print("STOP STOP")
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
306
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
307 test_that("funcBugs works with the lm option with multiple covariates.",{expect_equal(receivedReturn,expectedReturn)})