[BioC] objects masked from packages
Joern Toedling
Joern.Toedling at curie.fr
Mon Feb 8 16:53:18 CET 2010
Hi Assa,
the optimal way to have a function "recognize" what to do depending on the
class of the input list is to use S4 methods:
1. define a generic method name and function structure using 'setGeneric'
2. define methods for object classes using 'setMethod'
I just checked and affyPLM's "preprocess" does not seem to be a method. So
it's a bit more tricky to use it with the same name. In general, you need to
use a Namespace and only import from the other package what you really need.
Then you can define a generic method for 'preprocess', and a method for your
class and another method for AffyBatch which calls 'affyPLM:::preprocess'.
The easier solution for now might be to rename your function. The better way
is to learn about using Namespaces, S4 methods and S4 classes, which allow you
much more control about which method or function to use at what level than S3
functions do. The book from R. Gentleman "R for Bioinformatics" and the
"Writing R extensions" manual that comes with R are good starting points for
for learning this.
For your problem, I am not sure if it's actually worth creating another class
for the preprocessed data altogether. You can add lots of additional
information to an object of class 'ExpressionSet' using 'phenoData',
'experimentData' or even 'attr'. However, if you really need custom classes,
you may want to think about creating S4 classes that "inherit" from
ExpressionSet and AffyBatch. This way you can directly use all the other
methods already defined for the inherited classes without the need to reinvent
everything.
Regards,
Joern
On Mon, 8 Feb 2010 15:17:24 +0100, Assa Yeroslaviz wrote
> dear all,
>
> I have a problem with a masked object in a package we created here.
>
> we make a package for a workflow of internal analysis of microarray data.
> to create the package we used:
>
> > install.packages(pkgs="affyAnalysis", repos=NULL)
> > R CMD INSTALL affyAnalysis
> Erzeuge Verzeichnisse ...
> Erzeuge DESCRIPTION ...
> Erzeuge NAMESPACE ...
> Erzeuge Read-and-delete-me ...
> Kopiere Code-Dateien ...
> Erzeuge Hilfedateien ...
> Fertig.
>
> one of the classes in the package is a S3 packge and has the name
> "preprocess".
> using the package require various packages. one of them is affyPLM, which
> also have a S3 class named preprocess.
> Each time I'm using the program i get the message:
>
> > library(affyPLM)
> Lade nötiges Paket: affy
> Lade nötiges Paket: Biobase
>
> Welcome to Bioconductor
>
> Vignettes contain introductory material. To view, type
> 'openVignette()'. To cite Bioconductor, see
> 'citation("Biobase")' and for packages 'citation(pkgname)'.
>
> Lade nötiges Paket: gcrma
> Lade nötiges Paket: preprocessCore
>
> Attache Paket: 'affyPLM'
>
> The following object(s) are masked from package:affyAnalysis :
>
> preprocess
>
> The following object(s) are masked from package:stats :
>
> resid,
> residuals,
> weights
>
> The preprocess command in the affyPLM package needs an affybatch
> object to work with. our preprocess is as such definiert:
>
> preprocess <- function(x,...) UseMethod("preprocessExpData")
> preprocessExpData.expData <- function(data){
> require("vsn")
> data <- list(ExpressionSet=vsnrma(data$AffyBatch),
> baseDir=data$baseDir,experimentName=data$experimentName,
> pData=pData(data$AffyBatch))
> class(data) <- c("expSet","list")
> return(data)
> }
>
> when using the workflow we have and coming to the point of
> preprocesswe get the following error message:
>
> > ex <- preprocess(ed)
> Fehler in preprocess(ed) :
> argument is expData threestep requires AffyBatch argument is list
> threestep requires AffyBatch
>
> I would like to know if there is a way of using both preprocess commands
> without the need to rename ours. They both use different object
> structure as an input and as far I understand the adventages of OOP
> in R it should be able to recognize this differences, but how?
>
> Thans in advance for your help
>
> Assa
---
Joern Toedling
Institut Curie -- U900
26 rue d'Ulm, 75005 Paris, FRANCE
Tel. +33 (0)156246927
More information about the Bioconductor
mailing list