### R code from vignette source 'Codelink_Introduction.Rnw'
### Encoding: UTF-8

###################################################
### code chunk number 1: Codelink_Introduction.Rnw:20-26
###################################################
library(codelink)
library(knitr)
opts_chunk$set(fig.align = 'center', concordance=TRUE,width=50,fig.show="hold", tidy = TRUE, comment = "", highlight = FALSE, prompt = TRUE)
knit_hooks$set(no.mar = function(before, options, envir) {
    if (before) par(mar = rep(0,4))  # no margins.
})


###################################################
### code chunk number 2: Codelink_Introduction.Rnw:90-96 (eval = FALSE)
###################################################
## # NOT RUN #
## library(codelink)
## # to read data as CodelinkSet object:
## f = list.files(pattern="TXT")
## codset = readCodelinkSet(filename=f)
## # NOT RUN #


###################################################
### code chunk number 3: Codelink_Introduction.Rnw:101-105 (eval = FALSE)
###################################################
## # NOT RUN #
## pdata=read.AnnotatedDataFrame("targets.txt")
## codset=readCodelinkSet(filename=pdata$FileName, phenoData=pdata)
## # NOT RUN #


###################################################
### code chunk number 4: Codelink_Introduction.Rnw:108-111
###################################################
# sample dataset.
data(codset)
codset


###################################################
### code chunk number 5: Codelink_Introduction.Rnw:116-120
###################################################
data(codelink.example)
print(is(codelink.example))
tmp=Codelink2CodelinkSet(codelink.example)
tmp


###################################################
### code chunk number 6: Codelink_Introduction.Rnw:130-133
###################################################
w = createWeights(codset)
## NOTE: a proper replacement function will be provided later:
assayDataElement(codset,"weight")=w


###################################################
### code chunk number 7: Codelink_Introduction.Rnw:139-157
###################################################
# get signal intensities. alias: getInt()
head(exprs(codset))

# get background intensities.
head(getBkg(codset))

# get SNR values.
head(getSNR(codset))

# get flags.
head(getFlag(codset))

# get weights.
head(getWeight(codset))

# get phenoData:
head(pData(codset))



###################################################
### code chunk number 8: Codelink_Introduction.Rnw:164-165
###################################################
codset = codCorrect(codset, method = "half", offset = 0)


###################################################
### code chunk number 9: Codelink_Introduction.Rnw:173-174
###################################################
codset = codNormalize(codset, method = "quantile")


###################################################
### code chunk number 10: Codelink_Introduction.Rnw:179-182 (eval = FALSE)
###################################################
## # NOT RUN
## codset = codNormalize(codset, method = "loess", weights=getWeight(codset), loess.method="fast")
## # NOT RUN


###################################################
### code chunk number 11: Codelink_Introduction.Rnw:190-192
###################################################
codPlot(codset) # by default MA plot.
codPlot(codset, what="density")


###################################################
### code chunk number 12: Codelink_Introduction.Rnw:198-199
###################################################
codPlot(codset, what="image")


###################################################
### code chunk number 13: Codelink_Introduction.Rnw:207-210
###################################################
fit = lmFit(codset, design=c(1,1,2,2), weights=getWeight(codset))
fit2 = eBayes(fit)
topTable(fit2)


###################################################
### code chunk number 14: Codelink_Introduction.Rnw:215-216
###################################################
citation(package="codelink")


###################################################
### code chunk number 15: Codelink_Introduction.Rnw:221-222
###################################################
sessionInfo()