objects masked from packages
2
0
Entering edit mode
Assa Yeroslaviz ★ 1.5k
@assa-yeroslaviz-1597
Last seen 25 days ago
Germany
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 [[alternative HTML version deleted]]
affyPLM affyPLM • 1.6k views
ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen 3 days ago
United States
Hi Assa, First off, please don't cross-post. This is really an R-help question, as it is about the R language rather than a specific BioC package. 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? You need to take advantage of the namespace mechanisms available to you. The affyPLM package has a NAMESPACE file, and your package should as well. If you need preprocess from affyPLM, you can simply call it as affyPLM::preprocess which will ensure that you get the function you want. You can do the same with the function from your package (affyAnalysis::preprocess). Best, Jim > > Thans in advance for your help > > Assa > > [[alternative HTML version deleted]] > > > > -------------------------------------------------------------------- ---- > > _______________________________________________ > 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 ********************************************************** Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues
ADD COMMENT
0
Entering edit mode
@joern-toedling-3465
Last seen 10.2 years ago
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
ADD COMMENT

Login before adding your answer.

Traffic: 529 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6