Skip to content

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

2 messages · Davide Rambaldi, Martin Morgan

#
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.

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

Best Regards

Davide
On Mar 31, 2011, at 11:14 PM, Nishant Gopalakrishnan wrote:

            
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
#
On 04/01/2011 01:13 AM, Davide Rambaldi wrote:
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