[BioC] Repost of Error Message: Error in dim(data)<-dim: attempt to set an atrribute on NULL

James W. MacDonald jmacdon at med.umich.edu
Fri Feb 13 21:21:23 CET 2009


I think Martin found the problem. If you want to write out your results, 
you need to use write.fit(), not write.table().

Best,

Jim



Martin Morgan wrote:
> Sally -- I saw your earlier post and wanted to help, but your example
> is too long for me to work with, and I couldn't run it myself (I don't
> have your data!). Plus I couldn't see where in your original post the
> mistake was occurring, and below you don't have sessionInfo so you
> could be using some hodge-podge of packages that weren't designed to
> work together anyway..
> 
> I was going to suggest that you trim your example down to something
> small and reproducible. In thinking about how you might do that, I
> looked at where the error occurs
> 
>> fit2 <- eBayes(fit2)
>> write.table(fit2,file="fit2.txt",sep="\t")
> 
> and a possibility hit me. Here's my thought process -- what is the
> class of fit2?  what types of argument does write.table accept? in
> what package is the class of fit2 defined? is there another function
> in the package where the class of fit2 is defined that might be what
> you were looking for?
> 
> Hope that helps,
> 
> Martin
> 
> "Sally" <sagoldes at shaw.ca> writes:
> 
>> I have the following code, from which I get the following error message:
>>
>> Error in dim(data) <- dim : attempt to set an attribute on NULL
>>
>> The script works fine until I get to the ------ line below at the end of the data.
>>
>> #Load libraries
>> source("http://bioconductor.org/biocLite.R")
>> biocLite()
>>
>> library(limma)
>> library(Biobase)
>>
>> #change directory to folder where files are (c:/limmadegenes)
>> #Change to directory with original data files
>> #read in expression data file and phenotypic data.  
>> #Note that row.names=1 means that row names are #in column 1, 
>> exprdata<-read.table("exprsData.txt", header=TRUE,sep="\t",row.names=1,as.is=TRUE,fill=TRUE,)
>> class(exprdata)
>> #[1] "data.frame"
>> dim(exprdata)
>> #[1] 17328    28
>> colnames(exprdata)
>> head(exprdata)
>> #printout too long to paste
>> phenotypicdata<-read.table("phenotypicdata.txt",row.names=1,header=TRUE,sep="\t")
>> class(phenotypicdata) 
>> #returns: [1] "data.frame"
>> dim(phenotypicdata)
>> #returns: [1] 28  2
>> colnames(phenotypicdata)
>> #returns: [1] "Species" "Time"
>> rownames(phenotypicdata)
>> #Coerse exprdata into a matrix
>> myexprdata<-as.matrix(exprdata)
>> write.table(myexprdata,file="myexprdata.txt",sep="\t",col.names=NA)
>> class(myexprdata)
>> #[1] "matrix"
>> rownames(myexprdata)
>> colnames(myexprdata)
>> #Coerse phenotypicdata into a data frame
>> myphenotypicdata<-as.data.frame(phenotypicdata)
>> write.table(myphenotypicdata,file="myphenotypicdatacheck.txt",sep="\t",col.names=NA)
>> rownames(myphenotypicdata)
>> colnames(myphenotypicdata)
>> #[1] "species" "time"
>> summary(myphenotypicdata)
>> all(rownames(myphenotypicdata)==colnames(myexprdata)) 
>> #[1] TRUE
>> #Create annotated Data Frame
>> adf<-new("AnnotatedDataFrame",data=phenotypicdata)
>> #dim means: dimension of an object.
>> dim(adf)
>> #rowNames columnNames 
>> #     28           2
>> rownames(adf)
>> #NULL
>> #read in galfile
>> readGAL("Galfile.gal")
>> #Create eset object
>>
>> eSet<-new("ExpressionSet",exprs=myexprdata,phenoData=adf,annotation="Galfile.gal")
>>
>> #Read in targets file
>> targets <- readTargets("targets.txt")
>> targets
>> # Set up character list defining your arrays, include replicates
>> TS <- paste(targets$Species, targets$Time, sep=".")
>> #This script returns the following:
>> TS
>> # Turn TS into a factor variable which facilitates fitting
>> TS <- factor(TS)
>> #This script returns the following
>> design <- model.matrix(~0+TS)
>> #write design object to text file
>> write.table(design,file="design.txt",sep="\t",col.names=NA)
>> colnames(design) <- levels(TS)
>> #for eset put in your M values - see ?lmFit for object types
>> fit <- lmFit(eSet, design)
>> cont.matrix<-makeContrasts(s0vss24=s.0-s.24, s24vss48=s.24-s.48, s48vss96=s.48-s.96, c0vsc24=c.0-c.24, c24vsc48=c.24-c.48, c48vsc96=c.48-c.96, levels=design)
>> write.table(cont.matrix,file="cont.matrix.txt",sep="\t",col.names=NA)
>> # estimate the contrasts and put in fit2
>> fit2 <- contrasts.fit(fit, cont.matrix)
>> fit2 <- eBayes(fit2)
>>
>> #print fit2 table
>> write.table(fit2,file="fit2.txt",sep="\t")
>>
>> -------------------------------------------------------------------------------------------------------------------
>>
>> >From here on-down it does not work
>>
>> #I took the fit2 table and manually removed all empty and GFP rows, plus I deleted all rows where the Fpval was greated than 0.01.  This table is called
>> #fit2readformulttestFp01.txt
>>
>>
>> fit2<-read.table("fit2readyformulttestFp01.txt", header=TRUE, sep="\t") #WORKS
>> write.table(fit2, file="filteredfit2.txt",  sep="\t") #WORKS
>>
>>
>> s0vss24<-topTable(fit2,coef="s0vss24",number=3412,adjust.method="BH",p.value=1)
>>
>> write.table(s0vss24,file="s0vss24.txt",sep="\t")
>>
>>
>> s24vss48<-topTable(fit2,coef="s24vss48",number=3412,adjust.method="BH",p.value=1)
>>
>> write.table(s24vss48,file="s24vss48.txt",sep="\t")
>>
>>
>> s48vss96<-topTable(fit2,coef="s48vss96",number=3412,adjust.method="BH",p.value=1)
>>
>> write.table(s48vss96,file="s48vss96.txt",sep="\t")
>>
>>
>> c0vsc24<-topTable(fit2,coef="c0vsc24",number=3412,adjust.method="BH",p.value=1)
>>
>> write.table(c0vsc24,file="c0vsc24.txt",sep="\t")
>>
>>
>> c24vsc48<-topTable(fit2,coef="c24vsc48",number=3412,adjust.method="BH",p.value=1)
>>
>> write.table(c24vsc48,file="c24vsc48.txt",sep="\t")
>>
>>
>> c48vsc96<-topTable(fit2,coef="c48vsc96",number=3412,adjust.method="BH",p.value=1)
>>
>> write.table(c48vsc96,file="c48vsc96.txt",sep="\t")
>>
>> Thanks,  .../Sally
>>
>> 	[[alternative HTML version deleted]]
>>
>> _______________________________________________
>> Bioconductor mailing list
>> Bioconductor at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/bioconductor
>> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
> 

-- 
James W. MacDonald, M.S.
Biostatistician
Hildebrandt Lab
8220D MSRB III
1150 W. Medical Center Drive
Ann Arbor MI 48109-0646
734-936-8662



More information about the Bioconductor mailing list