[R] Object problems with Generic and rematchDefinition
H. Paul Benton
hpbenton at scripps.edu
Mon Apr 2 19:43:14 CEST 2007
Hello all,
Let me try this again with some code.
I am trying to make a new object and it's not working. I get :
Error in rematchDefinition(definition, fdef, mnames, fnames, signature) :
methods can add arguments to the generic only if '...' is an
argument to the generic
as my error. I have included my code. It is from the xcms package.
Any help would be great even if it's just telling me what the error
means. I know that if I make "searchM" a normal function that it works
but I would really like a method.
Thank
Paul
require(methods) || stop("Couldn't load package methods")
setClass("xcmsRaw", representation(env = "environment", tic = "numeric",
scantime = "numeric", scanindex =
"integer",
profmethod = "character", profparam =
"list",
mzrange = "numeric", gradient =
"matrix",
msmsinfo = "matrix",MSMSmz= "vector",
MSMSpreMZ = "vector",
MSMSint = "vector", MSMSrt = "vector", MSMSpreZ =
"vector",
MSMScount= "vector"),
prototype(env = new.env(parent=.GlobalEnv), tic = numeric(0),
scantime = numeric(0), scanindex = integer(0),
profmethod = "bin", profparam = list(),
mzrange = numeric(0),
gradient = matrix(nrow=0, ncol=0),
msmsinfo = matrix(nrow=0, ncol=0),
MSMSmz= vector(), MSMSpreMZ = vector(),
MSMSint = vector(), MSMSrt = vector(),
MSMSpreZ = vector(), MSMScount= vector() ))
if ( !isGeneric("searchM") )
setGeneric("searchM", function(object, ...) standardGeneric("searchM"))
setMethod("searchMetlin", "xcmsRaw", function(object, cost=5, ppm=10) {
metlinfile<-url("http://") # need to add URL
met.xml<-read.metlin(metlinfile)
Pcount<-object at env$peaksCount
values<-matrix(nrow=length(Pcount), ncol= 6)
colnames(values)<-c("Name", "Distance", "precursor MZ", "precursor
Z", "rt", "MS/MS peaks")
for(i in length(Pcount)){
if(MSMSpeaks){
MSMSpeaks<-as.vector(object at env$MSMSmz[Pcount[i-1]:Pcount[i]])
rtMSpeaks<-as.vector(object at env$MSMSrt[i])
preMZ<-as.vector(object at env$MSMSpremz[i])
preZ<-as.vector(object at env$MSMSpreZ[i])
}else{
MSMSpeaks<-as.vector(object at env$MSMSmz[1:Pcount[i]])
rtMSpeaks<-as.vector(object at env$MSMSrt[i])
preMZ<-as.vector(object at env$MSMSpremz[i])
preZ<-as.vector(object at env$MSMSpreZ[i])
}
decide<-decideBest(met.xml, MSMSpeaks, cost, ppm)
if(decide$levenshtein<5){
print(preMZ)
temp.values<-c(met.xml[decide$indexNum,1], decide$levenshtein,
preMZ, preZ,rtMSpeaks,
paste(MSMSpeaks, collapse=":"))
values<-rbind(values,temp.values)
} #else cat(".") ?
}
return(values)
write.csv(values, file="xcms.tsv", col.names=NA, sep="\t")
})
--
Research Technician
Mass Spectrometry
o The
/
o Scripps
\
o Research
/
o Institute
More information about the R-help
mailing list