[BioC] Functions

Ipsitha [guest] guest at bioconductor.org
Fri Jun 7 18:26:25 CEST 2013


I am trying to do some data analysis using R and Bioconductor.  I have a function to read my data called "ReadAffyData" and a function to plot the data called "preqc".  I want to know if there is any way I can extract information (read: Data) from the ReadAffyData function into preqc in order to produce plots? I have not completely understood the inheritance in R and I am getting errors similar to the one below. I am new to R and could do with any help in this aspect! 

ReadAffyData <- function( filename ) { 

        Cov <- read.table( filename, sep="\t", header=1, quote="", comment="" ) 
    if( ! all( c( "Filename", "Label", "Repl", "Trt" ) %in% colnames( Cov ) ) ) 
        stop( "Missing mandatory column" ) 
        Cov <- Cov[order(Cov$Trt),] 
        i <- table(Cov$Trt) 
        Cov$Repl <- unlist( lapply( i, function( j ) 1:j ) ) 
        Cov$Label <- paste( as.character( Cov$Trt ), Cov$Repl, sep=":" ) 
        rownames(Cov) <- as.character(Cov$Label) 
        tmp1 <- colnames( Cov ) 
    tmp2 <- rep( "", length( Cov ) ) 
        for( i in 1:length( tmp2 ) ) 
        tmp2[i] <- paste( sort( unique( as.character( Cov[,i] ) ) ), collapse="/" ) 
        labelDescription <- data.frame( labelDescription=tmp2 ) 
    rownames( labelDescription ) <- tmp1 
    tmp <- new( "AnnotatedDataFrame", data=Cov, varMetadata=labelDescription) 

        Data <- ReadAffy( sampleNames=as.character( Cov$Label ),phenoData=tmp, verbose=TRUE ) 

preQC <- function(name){ 
plotDensity( log2( pm( Data ) ), xlab="Log2( Intensity )", ylab="Density", main="Raw(PM)") 

1 reading C:/CEL/GSM311471.CEL ...instantiating an AffyBatch (intensity a 506944x24 matrix)...done. 
Reading in : C:/CEL/GSM311471.CEL 
Reading in : C:/CEL/GSM311472.CEL 
Reading in : C:/CEL/GSM311473.CEL 
Reading in : C:/CEL/GSM311474.CEL 
Reading in : C:/CEL/GSM311475.CEL 
Error in pm(Data) : 
  error in evaluating the argument 'object' in selecting a method for function 'pm': Error: object 'Data' not found 

 -- output of sessionInfo(): 

R version 3.0.1 (2013-05-16) 
Platform: i386-w64-mingw32/i386 (32-bit) 

[1] LC_COLLATE=English_India.1252  LC_CTYPE=English_India.1252    LC_MONETARY=English_India.1252 
[4] LC_NUMERIC=C                   LC_TIME=English_India.1252     

attached base packages: 
[1] parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages: 
[1] annotate_1.38.0      AnnotationDbi_1.22.6 affy_1.38.1          Biobase_2.20.0       BiocGenerics_0.6.0   

loaded via a namespace (and not attached): 
 [1] affyio_1.28.0         BiocInstaller_1.10.1  DBI_0.2-7             IRanges_1.18.1        preprocessCore_1.22.0 
 [6] RSQLite_0.11.4        stats4_3.0.1          tools_3.0.1           XML_3.96-1.1          xtable_1.7-1         
[11] zlibbioc_1.6.0     

Sent via the guest posting facility at bioconductor.org.

More information about the Bioconductor mailing list