Entering edit mode
Sally
▴
250
@sally-2430
Last seen 10.2 years ago
I wrote a script for LIMMA about 9 months ago, which worked fine.
Today ran it again (I've updated to the current R version) But got the
following error message after this script:
adf<-new("AnnotatedDataFrame",data=phenotypicdata)
Error in getClass(Class, where = topenv(parent.frame())) :
"AnnotatedDataFrame" is not a defined class
The entire script is below. The offending script is in red.
#Load libraries
source("http://bioconductor.org/biocLite.R")
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)
dim(exprdata)
colnames(exprdata)
head(exprdata)
#printout too long to paste
phenotypicdata<-read.table("phenotypicdata.txt",row.names=1,header=TRU
E,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)
class(myexprdata)
#[1] "matrix"
rownames(myexprdata)
colnames(myexprdata)
#Coerse phenotypicdata into a data frame
myphenotypicdata<-as.data.frame(phenotypicdata)
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
#Create eset object
eset<-new("ExpressionSet",exprs=myexprdata,phenoData=adf)
#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)
#contrast matrix
cont.matrix<-makeContrasts(s24vss0=s.24-s.0, s48vss24=s.48-s.24,
s96vss48=s.96-s.48, c24vsc0=c.24-c.0, c48vsc24=c.48-c.24,
c96vsc48=c.96-c.48, c0vss0=c.0-s.0, c24vss24=c.24-s.24,
c48vss48=c.48-s.48, c96vss96=c.96-s.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)
s24vss0<-topTable(fit2,coef="s24vss0",number=400,adjust.method="BH",p.
value=1)
write.table(s24vss0,file="s24vss0.txt",sep="\t")
s48vss24<-topTable(fit2,coef="s48vss24",number=400,adjust.method="BH",
p.value=1)
write.table(s48vss24,file="s48vss24.txt",sep="\t")
s96vss48<-topTable(fit2,coef="s96vss48",number=400,adjust.method="BH",
p.value=1)
write.table(s96vss48,file="s96vss48.txt",sep="\t")
c24vsc0<-topTable(fit2,coef="c24vsc0",number=400,adjust.method="BH",p.
value=1)
write.table(c24vsc0,file="c24vsc0.txt",sep="\t")
c48vsc24<-topTable(fit2,coef="c48vsc24",number=400,adjust.method="BH",
p.value=1)
write.table(c48vsc24,file="c24vsc48.txt",sep="\t")
c96vsc48<-topTable(fit2,coef="c96vsc48",number=400,adjust.method="BH",
p.value=1)
write.table(c96vsc48,file="c96vsc48.txt",sep="\t")
c0vss0<-topTable(fit2,coef="c0vss0",number=400,adjust.method="BH",p.va
lue=1)
write.table(c0vss0,file="c0vss0.txt",sep="\t")
c24vss24<-topTable(fit2,coef="c24vss24",number=400,adjust.method="BH",
p.value=1)
write.table(c24vss24,file="c24vss24.txt",sep="\t")
c48vss48<-topTable(fit2,coef="c48vss48",number=400,adjust.method="BH",
p.value=1)
write.table(c48vss48,file="c48vss48.txt",sep="\t")
c96vss96<-topTable(fit2,coef="c96vss96",number=400,adjust.method="BH",
p.value=1)
write.table(c96vss96,file="c96vss96.txt",sep="\t")
Thank-you
Sally
[[alternative HTML version deleted]]