[BioC] implement a additional slot to the eSet class (Formar: Error in .local(.Object, ...) : could not find function "checkClass")
Ext-Elmar.Bucher at vtt.fi
Ext-Elmar.Bucher at vtt.fi
Wed Dec 9 15:42:03 CET 2009
Hi Martin,
Thank you for the prompt "not exported function" hint. It was what I want to do :).
To your question: " What specifically do you want to accomplish? "
I like to implement a additional slot to the eSet class. So it differs from the code you suggested to study. I list here the essential of the code I have written till now. The code is not working as I wished. The main problem is, that the additional slot (leukoData) shows the correct values inside the initialize-routine (observer by browser()), but the output of the initialize-routine shows for leukoData just a empty AnnotatedDataFrame. Do you have a clue what I do wrong there?
Elmar
/*** begin listing ****/
library(Biobase) # base library
### build class and methodes ####
removeClass("LeukoSet") # only for development reason
# define LeukoSet class, inhert eSet class
setClass("LeukoSet", contains = "eSet", representation(leukoData = "AnnotatedDataFrame"), prototype(new("VersionedBiobase", versions = c(classVersion("eSet"), classVersion("AnnotatedDataFrame"), LeukoSet = "0.1.0"))))
# manipulate generic functions
# initialize to set the input to the slots. signature LeukoSet.
setMethod("initialize", signature("LeukoSet"),
function(.Object, assayData, leukoData = new("AnnotatedDataFrame"), ... ) {
#function(.Object, ... ) {
#.local <- function(.Object, assayData, leukoData = annotatedDataFrameFrom(assayData, byaxis= 'z'), ... ) {
# ctrl assayData stolen from eSet Initialization method
mySlots <- slotNames(.Object)
dotArgs <- list(...)
isSlot <- names(dotArgs) %in% mySlots
if (missing(assayData)) assayData <- do.call(assayDataNew, dotArgs[!isSlot], envir = parent.frame())
else {
Biobase:::checkClass(assayData, "AssayData", class(.Object))
cat("hallo assayData \n")
nms <- if (storageMode(assayData) == "list") names(assayData)
else ls(assayData)
dupNames <- nms %in% names(dotArgs[!isSlot])
if (any(dupNames)) warning("initialize argument(s) '", paste(nms[dupNames], collapse = "' '"), "' also present in 'assayData'; argument(s) ignored")
}
# ctrl leukoData
if (!missing(leukoData)) {
Biobase:::checkClass(leukoData, "AnnotatedDataFrame", class(.Object))
cat("hallo leukoData \n")
dimLabels(leukoData) <- c("leukoNames", "leukoColumns")
}
# pass ctrl to the next methode in the linearization that was computed by the generic function and return
browser()
callNextMethod(.Object, assayData = assayData, ...)
#.Object <- callNextMethod(.Object, assayData = assayData, ...)
#do.call(callNextMethod, c(.Object, assayData = assayData, ...))
#}
#.local(.Object, ...)
})
# generic accessor function for the leukoData slot - abstract data type ADT
setGeneric("leukoData", function(object,...) standardGeneric("leukoData"))
setMethod("leukoData", signature("LeukoSet"), function(object,...) object at leukoData)
# TEST
# the environment
e1 = new.env(hash = TRUE)
e1$a0 <- matrix(0:8, nc = 3)
rownames(e1$a0) <- c("y0","y1","y2")
colnames(e1$a0) <- c("x0","x1","x2")
# the list
l1 = list(a0 = e1$a0)
# the matrix
m1 = e1$a0
# annotateddataframes
pd.df <- data.frame(abc = c("phe_null","phe_eins","phe_zwei"), numb = c("+0","+1.1","+2"))
fd.df <- data.frame(abc = c("fea_null","fea_eins","fea_zwei"), numb = c("0","1.1","2"))
ld.df <- data.frame(abc = c("leo_null","leo_eins","leo_zwei"), numb = c("-0","-1.1","-2"))
rownames(pd.df) <- c("x0","x1","x2")
rownames(fd.df) <- c("y0","y1","y2")
rownames(ld.df) <- c("a0","a1","a2")
mewe.df <- data.frame(labelDescription = c("alpha BETI c","nu MERI c"), row.names = c("abc","numb"))
pd.s4 <- new("AnnotatedDataFrame", data = pd.df, varMetadata = mewe.df)
fd.s4 <- new("AnnotatedDataFrame", data = fd.df, varMetadata = mewe.df)
ld.s4 <- new("AnnotatedDataFrame", data = ld.df, varMetadata = mewe.df)
# vectors
a.v <- "htsdb"
# miame
miame.s4 <- new('MIAME', name = "Elmar Bucher", lab = "VTT Technical Research Center of Finalnd - Medical Biotechnology", contact = "elmar.bucheratvtt.fi", title = "the LeukoSet", abstract = "crash test", url = "http://www.petzl.com/en/outdoor/petzl-tv", other = list(notes = "check it out!"))
# run
lset <- new("LeukoSet", assayData = e1, phenoData = pd.s4, featureData = fd.s4, leukoData = ld.s4, experimentData = miame.s4, annnotation = a.v)
# browser!
lset
leukoData(lset)
/*** end of listing ***/
-----Original Message-----
From: Martin Morgan [mailto:mtmorgan at fhcrc.org]
Sent: 08 December 2009 20:55
To: Bucher Elmar
Cc: bioconductor at stat.math.ethz.ch
Subject: Re: [BioC] Error in .local(.Object, ...) : could not find function "checkClass"
Hi Elmar --
Ext-Elmar.Bucher at vtt.fi wrote:
> Dear List,
>
> I'm writing on extension of the eSet class.
>
> getMethod("initialize","eSet") and getMethod("sampleNames<-","AssayData") from the Biobase package are particularly using functions like "checkClass", "assayDataEnvLock", "assayDataStorageMode".
>
> In my implementation I would like to use the same functions but I receive errors like:
> Error in .local(.Object, ...) : could not find function "checkClass"
>
> Why?
> How can I enable my code to use this functions? Because the eSet initialize code seems to be able to use this functions, whit the very same packages loaded.
> I have the same problem on linux and windows machines. See sessionInfo below.
These functions are defined in Biobase but not exported. They are
accessible with
Biobase:::checkClass
and the like, but probably you do not want to do this. Perhaps you want
to use callNextMethod() or similar, or the functions that are actually
exported? What specifically do you want to accomplish? Maybe some hints
in, e.g.,
library(oligoClasses)
selectMethod(initialize, "SnpCallSetPlus")
If I'd written a class to do something special with 'sampleNames', say
force them to be upper case, then I might do something like
setClass("A", contains="eSet")
setReplaceMethod("sampleNames", c("A", "character"),
function(object, value)
{
callNextMethod(object=object, value=toupper(value))
})
and then
> a = new("A", exprs=matrix(rnorm(200), 20))
> sampleNames(a)
[1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10"
> sampleNames(a) <- letters[1:10]
> sampleNames(a)
[1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J"
>
Martin
>
> Grateful for help, Elmar
>
>
>
>> sessionInfo()
> R version 2.10.0 (2009-10-26)
> x86_64-pc-linux-gnu
>
> locale:
> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
> [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8
> [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
> [9] LC_ADDRESS=C LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] RBioinf_1.6.0 graph_1.20.0 Biobase_2.6.0
>
> loaded via a namespace (and not attached):
> [1] cluster_1.12.1 tools_2.10.0
>
>> sessionInfo()
> R version 2.10.0 (2009-10-26)
> i386-pc-mingw32
>
> locale:
> [1] LC_COLLATE=English_United Kingdom.1252
> [2] LC_CTYPE=English_United Kingdom.1252
> [3] LC_MONETARY=English_United Kingdom.1252
> [4] LC_NUMERIC=C
> [5] LC_TIME=English_United Kingdom.1252
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] RBioinf_1.6.0 graph_1.24.1 Biobase_2.6.0
>
> loaded via a namespace (and not attached):
> [1] tools_2.10.0
>
> _______________________________________________
> 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
--
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109
Location: Arnold Building M1 B861
Phone: (206) 667-2793
More information about the Bioconductor
mailing list