#####################################################
#
# Processing of cell array data using cellHTS-package
#
#####################################################



library(cellHTS)
library(geneplotter)
library(annotate)

options(error=recover)

experimentName = "CIA_target"
filepath="P:/programme/R/My_R_Programs/Data/HTS/CIA"
dataPath = file.path(filepath, experimentName)
resultPath="P:/programme/R/My_R_Programs/Data/HTS/CIA/CIA_target/result"

### output of files

dataPath
rev(dir(dataPath))

x = readPlateData("Platelist.txt",plateType="96", name=experimentName, path=dataPath)

x

cellHTS:::tableOutput(file.path(dataPath, "Platelist.txt"), "plate list")
cellHTS:::tableOutput(file.path(dataPath, names(x$intensityFiles)[1]), "signal intensity",
        header=FALSE, dropColumns=1)

out = writeReport(x, outdir="P:/programme/R/My_R_Programs/Data/HTS/CIA/CIA_target/result", force=TRUE)

confFile = file.path(dataPath, "Plateconf.txt")
logFile  = file.path(dataPath, "Screenlog.txt")
descripFile  = file.path(dataPath, "Description.txt")
x = configure(x, confFile, logFile, descripFile)


cellHTS:::tableOutput(confFile, "plate configuration", selRows=25:28)
cellHTS:::tableOutput(logFile, "screen log", selRows=1:3)

table(x$plateConf$Content)


x = normalizePlateMedian(x,zscore="+") 
x = summarizeReplicates(x,  summary="min") 


geneIDFile = file.path(dataPath, "GeneIDs.txt")
x = annotate(x, geneIDFile)


cellHTS:::tableOutput(geneIDFile, "gene ID", selRows = 3:6)

x

writeReport(x, force=TRUE, 
  outdir="P:/programme/R/My_R_Programs/Data/HTS/CIA/CIA_target/result",
   plotPlateArgs   = list(xrange=c(0.5, 1.5)), 
  imageScreenArgs = list(zrange=c( -2, 6.5), ar=1)
  )
  
