[Bioc-devel] Building a package that depends on flowCore

Martin Morgan mtmorgan at fhcrc.org
Fri Apr 1 16:30:37 CEST 2011


On 04/01/2011 01:13 AM, Davide Rambaldi wrote:
> Hi All and thanks for the help.... (yes I know I must RTFM but...)
>
> Anyway I have made this workaround, not sure if it is a good idea:
>
> representation=representation(
> 		DATA = "environment"
> )
>
> With this initializer:
>
> setMethod (
> 	f = "initialize",
> 	signature = "GenData",
> 	definition = function(.Object, flowframe, stain,  ... ) {
> 		# check data
> 		flowCore:::checkClass(flowframe, c("flowFrame"))
> 		.Object at DATA[["Frame"]]<- flowframe
> 		mt<- stain %in% colnames(flowframe)
> 		if(!mt) {
>          	stop("Invalid stain not matching the flowSet:\n    ", paste(stain, collapse=", "))
>          }
> 		return(.Object)
> 	}
> )
>
>
> If I have understood the concept of enviroment: I have created a pointer (reference) to our flowFrame.
>

Hi Davide -- Unfortunately this is not a good idea.

As Nishant indicated, there seemed to be an issue with flowFrame and it 
has been addressed. So use flowCore 1.17.5 or later (this requires using 
R-2-13-beta or R-devel) available through svn or, probably after 
midnight PST today, via biocLite.

There are two issues with your approach.

One is that you've changed the semantics from copy-on-change to 
reference. This  will surprise your users -- if the user sets 'b' equal 
to 'a', and then modifies 'b', they are not expecting, in R, to see 'a' 
change, but this is what happens with environments.

The other has to do with the issue Nishant discovered. It is a little 
bit complicated to explain, but note that new("flowFrame") fails (try 
it!). This means that a class with a 'flowFrame' slot produces invalid 
objects

   setClass("A", representation=representation(f="flowFrame"))
   validObject(new("A")) # FALSE !

and this in turns leads to the difficulties (inadequately reported by R) 
that you see. Nishant addressed the flowFrame issue, so that in flowCore 
1.17.5 or later new("flowFrame") works and new("A") produces valid 
objects. A package with

   DESCRIPTION
   Imports: flowCore

   NAMESPACE:
   importClassesFrom(flowCore, "flowFrame")

   R/AllClasses.R:
   setClass("A", representation=representation(f="flowFrame"))

will now install.

The class you use above has the same issue as the original flowFrame -- 
new("GeneData") fails, and so your class cannot be used in another package!

This suggests a basic unit test for all classes -- that 
validObject(new("Class")) is TRUE.

 > Not sure if it is coorect but it pass R CMD check now :

So even better, correct and passes R CMD check!

Martin

>
> Best Regards
>
> Davide
>
>
>
>
> On Mar 31, 2011, at 11:14 PM, Nishant Gopalakrishnan wrote:
>
>> Hi Davide,
>>
>> Its hard to guess exactly what the problem is considering that you have not even provided the error message.  It would have been easier for others to help you out if you provided a  snippet of code using which people can reproduce the error you get.
>>
>> Before you put your class into a package, I would recommend sourcing your code for the class into an R session with the flowCore package loaded and making sure things work without errors.
>>
>> representation=representation(
>>       flowframe = "flowFrame",
>>       [...]
>> )
>>
>>  From your example above, it appears that you are  trying to create a new class with a flowFrame as one of its slots. After going through the code for the flowCore package,  I have noticed a bug in the initialize method for flowFrame class which would have prevented you from creating a flowFrame object using just new("flowFrame"). My guess is that you would have done the same for the prototype function for your class. You had to pass in a valid value for the exprs and parameters and description slots to instantiate an object.
>>
>> I have checked in a fix for this in Version flowCore 1.17.5 and now you should be able to do new("flowFrame") to instantiate an object for filling the slot flowFrame in the prototype for your new class.
>>
>> Nishant
>>
>> On 03/30/2011 09:19 AM, Finak, Greg wrote:
>>> Hi, Davide
>>> I'm not as familiar with the R package build system as others on the list, so it's difficult for me to diagnose your problem from the information given, but I can offer a few suggestions. In the Namespace file, try explicitly importing just the classes, methods and functions from flowCore that your package actually uses. I think you woukd want flowCore in the Depends field of your Description file. Finally, have a look at other packages that extend flowCore, like the flowMerge package for example, and see how they handle it. In my experience, masked methods don't usually lead to installation failure. Perhaps you could provide more output from R CMD check, and the content of your Namespace and Description files.
>>> Cheers
>>> Greg
>>>
>>> Sent from my iPhone
>>>
>>> On 2011-03-30, at 2:10 AM, "Davide Rambaldi"<davide.rambaldi at ifom-ieo-campus.it>   wrote:
>>>
>>>> Hi all, I am trying to pack my code in a package for submission to bioconductor.
>>>>
>>>> The package depends on flowCore, so for example I have an S4 class with a "slot" that is a flowFrame object.
>>>>
>>>> representation=representation(
>>>>        flowframe = "flowFrame",
>>>>        [...]
>>>> )
>>>>
>>>> Now I am trying to build the package:
>>>>
>>>> without depends in DESCRIPTION or NAMESPACE:
>>>>
>>>> If I omit the dependecy from flowCore in the DESCRIPTION file I get this warning during R CMD check:
>>>>
>>>> Warning: undefined slot classes in definition of "GenData": flowframe(class "flowFrame")
>>>>
>>>>
>>>> Then I tried to define the dependency from flowCore:
>>>>
>>>> If I put the
>>>>
>>>> Depends: flowCore
>>>>
>>>> in DESCRIPTION
>>>>
>>>> I get:
>>>>
>>>> checking whether package ‘flowFit’ can be installed ... ERROR
>>>> Installation failed.
>>>>
>>>> The log file say:
>>>>
>>>> Attaching package: 'flowCore'
>>>>
>>>> The following object(s) are masked from 'package:stats':
>>>>
>>>>    alias, filter
>>>>
>>>> Execution halted
>>>>
>>>>
>>>> I tried to add in NAMESPACE:
>>>>
>>>> import(flowCore)
>>>>
>>>> I tried also to move flowCore from Depends to Imports in DESCRIPTION but seems that it always halt at that point.
>>>>
>>>> What I should try now?
>>>>
>>>> Thanks and Best Regards
>>>>
>>>>
>>>>
>>>>
>>>> Davide Rambaldi, Bioinformatics PostDoc.
>>>> -----------------------------------------------------
>>>> IFOM-IEO Campus
>>>> Via Adamello 16, Milano
>>>> I-20139 Italy
>>>> [t] +39 02574303870
>>>> [e] davide.rambaldi at ifom-ieo-campus.it
>>>>
>>>>
>>>>    [[alternative HTML version deleted]]
>>>>
>>>> _______________________________________________
>>>> Bioc-devel at r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/bioc-devel
>>> _______________________________________________
>>> Bioc-devel at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/bioc-devel
>> aa
>
> Davide Rambaldi, Bioinformatics PostDoc.
> -----------------------------------------------------
> IFOM-IEO Campus
> Via Adamello 16, Milano
> I-20139 Italy
> [t] +39 02574303870
> [e] davide.rambaldi at ifom-ieo-campus.it
>
> _______________________________________________
> Bioc-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/bioc-devel


-- 
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793



More information about the Bioc-devel mailing list