-
Notifications
You must be signed in to change notification settings - Fork 0
/
polySegratioMM-overview.R
151 lines (112 loc) · 5.89 KB
/
polySegratioMM-overview.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
### R code from vignette source 'polySegratioMM-overview.Rnw'
###################################################
### code chunk number 1: polySegratioMM-overview.Rnw:64-65
###################################################
library(polySegratioMM)
###################################################
### code chunk number 2: polySegratioMM-overview.Rnw:68-73
###################################################
##library(cacheSweave) # comment this out after development phase
## to use: Sweave("polySegratioMM-overview.Rnw", driver=cacheSweaveDriver)
## or without cache: Sweave("polySegratioMM-overview.Rnw")
op <- options()
options(width=70, digits=4)
###################################################
### code chunk number 3: polySegratioMM-overview.Rnw:91-92
###################################################
data(hexmarkers)
###################################################
### code chunk number 4: polySegratioMM-overview.Rnw:94-101
###################################################
##<<simData, cache=true>>=
## simulate small autohexaploid data set of 500 markers for 200 individuals
## with %70 Single, %20 Double and %10 Triple Dose markers
## created with
## hexmarkers <- sim.autoMarkers(6,c(0.7,0.2,0.1),n.markers=500,n.individuals=200)
## save(hexmarkers, file="../../data/hexmarkers.RData")
print(hexmarkers)
###################################################
### code chunk number 5: polySegratioMM-overview.Rnw:109-110
###################################################
sr <- segregationRatios(hexmarkers$markers)
###################################################
### code chunk number 6: polySegratioMM-overview.Rnw:116-119
###################################################
print(plotTheoretical(ploidy.level=6, seg.ratios=sr, main="",
expected.segratio=NULL, proportions=c(0.7,0.2,0.1),
n.individuals=200))
###################################################
### code chunk number 7: polySegratioMM-overview.Rnw:142-149
###################################################
##<<simDataOver, cache=true>>=
## simulate small autohexaploid data set of 500 markers for 200 individuals
## with %70 Single, %20 Double and %10 Triple Dose markers
## hexmarkers.overdisp <- sim.autoMarkers(6,c(0.7,0.2,0.1),overdispersion=TRUE, shape1=30,n.markers=500,n.individuals=200)
## save(hexmarkers.overdisp, file="../../data/hexmarkers.overdisp.RData")
data(hexmarkers.overdisp)
##print(hexmarkers.overdisp)
###################################################
### code chunk number 8: polySegratioMM-overview.Rnw:155-156
###################################################
sr.overdisp <- segregationRatios(hexmarkers.overdisp$markers)
###################################################
### code chunk number 9: polySegratioMM-overview.Rnw:161-164
###################################################
print(plotTheoretical(ploidy.level=6, seg.ratios=sr.overdisp, main="",
expected.segratio=NULL, proportions=c(0.7,0.2,0.1),
n.individuals=200))
###################################################
### code chunk number 10: polySegratioMM-overview.Rnw:268-269
###################################################
x.mod1 <- setModel(3,6) # autohexaploid model with 3 components
###################################################
### code chunk number 11: polySegratioMM-overview.Rnw:293-298
###################################################
## produced using the following but loaded as data to avoid the run time on slow machines
##mcmcHexRun <- runSegratioMM(sr.overdisp, x.mod1, burn.in=200, sample=500, plots=FALSE)
##mcmcHexRun <- runSegratioMM(sr.overdisp, x.mod1, plots=FALSE)
## save(mcmcHexRun, file="../../data/mcmcHexRun.RData")
data(mcmcHexRun)
###################################################
### code chunk number 12: polySegratioMM-overview.Rnw:309-310
###################################################
print(mcmcHexRun$run.jags)
###################################################
### code chunk number 13: polySegratioMM-overview.Rnw:314-315
###################################################
print(mcmcHexRun$summary)
###################################################
### code chunk number 14: polySegratioMM-overview.Rnw:322-323
###################################################
print(mcmcHexRun$diagnostics)
###################################################
### code chunk number 15: polySegratioMM-overview.Rnw:327-328
###################################################
print(mcmcHexRun$doses)
###################################################
### code chunk number 16: polySegratioMM-overview.Rnw:339-340
###################################################
print(plot(mcmcHexRun$mcmc.mixture$mcmc.list[[1]][,c("P[1]","mu[1]","sigma","T[140]")]))
###################################################
### code chunk number 17: polySegratioMM-overview.Rnw:365-366
###################################################
print(plot(mcmcHexRun, theoretical=TRUE, main=""))
###################################################
### code chunk number 18: polySegratioMM-overview.Rnw:397-401
###################################################
cat("Employing maximum posterior probability\n")
table(Dose=mcmcHexRun$doses$max.post.dosage, exclude=NULL)
cat("Employing posterior probability > 0.8\n")
table(Dose=mcmcHexRun$doses$dosage[,"0.8"], exclude=NULL)
###################################################
### code chunk number 19: polySegratioMM-overview.Rnw:410-419
###################################################
cat("Employing theChi squared test\n")
dose.chi <- test.segRatio(sr.overdisp, ploidy.level = 6)
table(Chi2Dose=dose.chi$dosage, True=hexmarkers.overdisp$true.doses$dosage, exclude=NULL)
cat("Employing maximum posterior probability\n")
table(MixtureDose=mcmcHexRun$doses$max.post.dosage, True=hexmarkers.overdisp$true.doses$dosage,
exclude=NULL)
cat("Employing posterior probability > 0.8\n")
table(MixtureDose=mcmcHexRun$doses$dosage[,"0.8"], True=hexmarkers.overdisp$true.doses$dosage,
exclude=NULL)