All the best
Gordon
On Mon, 5 May 2008, Martin Morgan wrote:
Martin Maechler <maechler at stat.math.ethz.ch> writes:
"GS" == Gordon K Smyth <smyth at wehi.edu.au>
on Thu, 1 May 2008 10:26:01 +1000 (E. Australia Standard
GS> Hi Martin,
GS> I have only just noticed that the methods package now has generic
GS> functions rbind2() and cbind2(), which it didn't when the
GS> function was first created for Biobase.
GS> I think it would be clearer and more elegant to implement
GS> cbind2() methods for ExpressionSet, and to retire combine()
GS> the track (not obviously for the imminent Bioconductor release).
GS> "combine" is a somewhat overused, e.g., it conflicts with the c()
GS> in base.
GS> What do you think?
(I'm another 'Martin' but nevertheless .. : )
I'm strongly in favor of providing rbind2() and cbind2()
methods, base combine() on these for now, and deprecate
combine().
(sorry Gordon for not getting back to you on this, I've actually been
mulling it over a bit...)
combine does more (or is supposed to, anyway) than rbind or cbind,
appending non-overlapping rows and columns simultaneously (and
introducing NAs in the implied missing values where features present
in only one eSet have to be aligned with samples present only in the
other, and vice versa).
In mulling this over I realized a bug in the current combine (fixed in
devel), and the more-or-less overly restrictive description of
combine,eSet,eSet-method.
I'm kind of wondering whether Gordon's original question was prompted
by a malfunctioning / misleading combine, or by a desire to have a
more consistent interface to rbind / cbind?
rbind2() and cbind2() had been introduced exactly for the
purpose of providing rbind() / cbind() - like methods for S4
objects.
I know 'why', but it's a little too bad that, for this design goal,
rbind2 is not named, well, rbind.
I have implemented rbind2 / cbind2 in my local copy of Biobase, and
will likely commit over the next day or so. The code is basically
setMethod("cbind2",
signature=signature(x="eSet", y="eSet"),
function(x, y) {
## check that featureNames the same, sampleNames differ,
## and then...
combine(x, y)
})
Gordon, is this the effect you're looking for?
Martin Morgan
Martin Maechler, ETH Zurich
GS> Cheers
GS> Gordon
GS> On Fri, 4 Apr 2008, Martin Morgan wrote:
>> Thanks for the suggestion and examples.
>>
>> I implemented this in Biobase 1.99.5. It is slightly different from
>> version in the beadarraySNP package, in that the content of
>> regions of the exprs arrays have to be identical (beadarraySNP
>> the second matrix).
>>
>> The functionality I implemented is consistent with the following
>> (hopefully self-explanatory).
>>
>> data(sample.ExpressionSet)
>> obj <- sample.ExpressionSet
>>
>> checkEquals(obj, combine(obj[1:250,], obj[251:500,]))
>> checkEquals(obj, combine(obj[,1:13], obj[,14:26]))
>> ## overlapping
>> checkEquals(obj, combine(obj[1:300,], obj[250:500,]))
>> checkEquals(obj, combine(obj[,1:20], obj[,15:26]))
>>
>>
>> The implementation introduces a combine method for matricies, which
>> consistent with these tests:
>>
>> ## dimnames
>> m <- matrix(1:20, nrow=5, dimnames=list(LETTERS[1:5],
>> checkEquals(m, combine(m, m))
>> checkEquals(m, combine(m[1:3,], m[4:5,]))
>> checkEquals(m, combine(m[,1:3], m[,4, drop=FALSE]))
>> ## overlap
>> checkEquals(m, combine(m[1:3,], m[3:5,]))
>> checkEquals(m, combine(m[,1:3], m[,3:4]))
>> checkEquals(matrix(c(1:3, NA, NA, 6:8, NA, NA,
>> 11:15, NA, NA, 18, NA, NA),
>> nrow=5,
>> dimnames=list(LETTERS[1:5], letters[1:4])),
>> combine(m[1:3,1:3], m[3:5, 3:4]))
>> ## row reordering
>> checkEquals(m[c(1,3,5,2,4),], combine(m[c(1,3,5),], m[c(2,4),]))
>> ## Exceptions
>> checkException(combine(m, matrix(0, nrow=5, ncol=4)),
>> silent=TRUE) # types differ
>> checkException(combine(m, matrix(0L, nrow=5, ncol=4)),
>> silent=TRUE) # attributes differ
>> m1 <- matrix(1:20, nrow=5)
>> checkException(combine(m, m1), silent=TRUE) # dimnames required
>>
>> Please let me know if you had something else in mind, or if there
>> problems with this.
>>
>> Martin
>>
>> Laurent Gautier wrote:
>>> That would be useful.
>>>
>>> I have been in a situation where it would have been useful, and
>>> time
>>> with combine as well before writing my own ad-hoc solution.
>>>
>>>
>>>
>>> Laurent
>>>
>>>
>>> 2008/4/4, Gordon K Smyth <smyth at wehi.edu.au>:
>>>> An rbind() method or an rbind-like function for ExpressionSet
>>>> would be useful. Any plans for such a function?
>>>>
>>>> At the moment, an ExpressionSet object can be subsetted by rows
>>>> columns. Column subsets can be put back together using
>>>> there's no way I think to put row subsets back together.
>>>>
>>>> BTW, the help page for the generic function combine() includes
>>>> of
>>>> combining by rows, but this concept is not honoured by the
>>
>>
>> --
>> Martin Morgan
>> Computational Biology / Fred Hutchinson Cancer Research Center
>> 1100 Fairview Ave. N.
>> PO Box 19024 Seattle, WA 98109
>>
>> Location: Arnold Building M2 B169
>> Phone: (206) 667-2793
>>
--
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109
Location: Arnold Building M2 B169
Phone: (206) 667-2793