Difference between revisions of "ReadAgilent.R"

From Organic Design wiki
m
 
Line 1: Line 1:
 +
# {{R}}
 
readAgilent <- function(dataDir="/Volumes/HD2/Data/Nutrigenomics/MultipleScans/Agilent"){
 
readAgilent <- function(dataDir="/Volumes/HD2/Data/Nutrigenomics/MultipleScans/Agilent"){
 
   require(limma)
 
   require(limma)

Latest revision as of 00:44, 6 June 2007

Code snipits and programs written in R, S or S-PLUS readAgilent <- function(dataDir="/Volumes/HD2/Data/Nutrigenomics/MultipleScans/Agilent"){

 require(limma)
  1. 1) Read in data using limma
 if(exists("targets", inherits=FALSE)) {
   RGsub <- read.maimages(targets$Filename, path = dataDir, source="agilent", name=targets$Filetype)
 } else {
   RGsub <- read.maimages(dir(dataDir, pattern=".txt"), path = dataDir, source="agilent")
 }
  1. 2) Find Agilent indices from x ,y coords

getInd <- function(x,y, nx, byrow=T) {

 return( (x-1)* nx + y)

}

 ind <- getInd(RGsub$genes$Row, RGsub$genes$Col, nx=215)
  1. 3) Construct complete RGList
 RGfull <- new("RGList")
 RGfull$R <-RGfull$G <-RGfull$Rb <-RGfull$Gb <- matrix(NA, nc=ncol(RGsub), nr=max(ind))
 RGfull$genes <- data.frame(matrix(NA, nc=7, nr=max(ind), dimnames = list(NULL, names(RGsub$genes))))
 matrixNames <- dimnames(RGsub$R)
  1. 4) Populate complete list
 RGfull$R[ind,]     <- RGsub$R
 RGfull$Rb[ind,]    <- RGsub$Rb
 RGfull$G[ind,]     <- RGsub$G
 RGfull$Gb[ind,]    <- RGsub$Gb
 RGfull$genes[ind,] <- RGsub$genes
 RGfull$targets <- RGsub$targets
 
 dimnames(RGfull$R) <- dimnames(RGfull$Rb) <- dimnames(RGfull$G) <- dimnames(RGfull$Gb) <- matrixNames
  1. Checking the rows that needed padding
 rowstopad <- as.numeric(rownames(RGsub$genes) [ !(rownames(RGsub$genes) %in% ind) ])
 rowstopad
  1. Indexing looks ok
 RGfull[rowstopad,]
 RGfull$printer <- structure(list(ngrid.r=1, ngrid.c=1, nspot.r=105, nspot.c=215), class = "PrintLayout")
 rm(RGsub)
 return(RGfull)

}