###################################################
### chunk number 1: 
###################################################
options(width=65)


###################################################
### chunk number 2: 
###################################################
library(maCorrPlot)


###################################################
### chunk number 3: 
###################################################
data(oligodata)
ls()


###################################################
### chunk number 4: 
###################################################
dim(datA.mas5)
datA.mas5[1:5, 1:5]


###################################################
### chunk number 5: 
###################################################
corrA.rma = CorrSample(datA.rma, np=1000, seed=213)


###################################################
### chunk number 6:  eval=FALSE
###################################################
## plot(corrA.rma)


###################################################
### chunk number 7: 
###################################################
corrA.rma[1:5,]


###################################################
### chunk number 8: 
###################################################
jj = plot(corrA.rma)
print(jj)


###################################################
### chunk number 9: 
###################################################
jj = plot(corrA.rma, scatter=TRUE, curve=TRUE)
print(jj)


###################################################
### chunk number 10: 
###################################################
corrA.mas5 = CorrSample(datA.mas5, np=1000, seed=213)


###################################################
### chunk number 11:  eval=FALSE
###################################################
## plot(corrA.mas5, corrA.rma, cond=c("MAS5","RMA"))


###################################################
### chunk number 12: 
###################################################
corrB.rma = CorrSample(datB.rma, np=1000, seed=214)
corrB.mas5 = CorrSample(datB.mas5, np=1000, seed=214)


###################################################
### chunk number 13:  eval=FALSE
###################################################
## plot(corrA.mas5, corrA.rma, corrB.mas5, corrB.rma, cond=c("MAS5/A","RMA/A","MAS5/B","RMA/B"))


###################################################
### chunk number 14:  eval=FALSE
###################################################
## plot(corrA.mas5, corrA.rma, corrB.mas5, corrB.rma, cond=list(c("MAS5","RMA","MAS5","RMA"), c("A","A","B","B")))


###################################################
### chunk number 15: 
###################################################
jj = plot(corrA.mas5, corrA.rma, cond=c("MAS5","RMA"))
print(jj)


###################################################
### chunk number 16: 
###################################################
jj = plot(corrA.mas5, corrA.rma, corrB.mas5, corrB.rma, cond=list(c("MAS5","RMA","MAS5","RMA"), c("A","A","B","B")))
print(jj)


###################################################
### chunk number 17: 
###################################################
pcntA = rowSums(datA.amp=="P")


###################################################
### chunk number 18: 
###################################################
pcntA.pairs = (pcntA[corrA.rma$ndx1]+pcntA[corrA.rma$ndx2])/2


###################################################
### chunk number 19: 
###################################################
pgrpA.pairs = cut(pcntA.pairs, c(0, 10, 20, 30), include.lowest=TRUE)
table(pgrpA.pairs)


###################################################
### chunk number 20:  eval=FALSE
###################################################
## plot(corrA.rma, groups=pgrpA.pairs, auto.key=TRUE)


###################################################
### chunk number 21: 
###################################################
par(mfrow=c(1,2))
hist(pcntA, main="(a) pcntA", xlab="No. of present calls")
hist(pcntA.pairs, main="(b) pcntA.pairs", xlab="Average no. of present calls")


###################################################
### chunk number 22: 
###################################################
jj = plot(corrA.rma, groups=pgrpA.pairs, auto.key=TRUE)
print(jj)


###################################################
### chunk number 23: 
###################################################
jj = plot(corrA.mas5, corrA.rma, cond=c("MAS5","RMA"), groups=list(pgrpA.pairs, pgrpA.pairs), nint=5, ylim=c(-0.25, 0.4))
print(jj)