[R] Object problems with Generic and rematchDefinition

From: H. Paul Benton <hpbenton_at_scripps.edu>
Date: Mon 02 Apr 2007 - 17:43:14 GMT


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@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@env$MSMSmz[Pcount[i-1]:Pcount[i]])
        rtMSpeaks<-as.vector(object@env$MSMSrt[i])
        preMZ<-as.vector(object@env$MSMSpremz[i])
        preZ<-as.vector(object@env$MSMSpreZ[i])
        }else{
        MSMSpeaks<-as.vector(object@env$MSMSmz[1:Pcount[i]])
        rtMSpeaks<-as.vector(object@env$MSMSrt[i])
        preMZ<-as.vector(object@env$MSMSpremz[i])
        preZ<-as.vector(object@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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Tue Apr 03 03:47:49 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 02 Apr 2007 - 18:30:35 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.