Skip to content

[Bioc-devel] Valid classes for extraColumnSlots

8 messages · Michael Lawrence, Peter Hickey

#
Are the extraColumnSlots of a class that extends GenomicRanges limited to DataFrame objects?

Background: I wrote a class that extends the GRanges class. It has a matrix as the extraColumnSlots. When I use replaceROWS,GenomicRanges,GenomicRanges-method (via inheritance) it extracts this extraColumnSlots as a DataFrame object by use of GenomicRanges:::extraColumnSlotsAsDF. This means that the subsequent call to update() in replaceROWS,GenomicRanges,GenomicRanges-method fails because the class definition expects a matrix for the extraSlotNames but gets a DataFrame.

In this case, it's not a problem for me to change my extraColumnSlots element to a DataFrame in the class definition. However, more generally, some guidance on what classes are and are not allowed in extraColumnSlots would be appreciated.

Thanks,
Pete

This is using BioC devel:
sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-apple-darwin13.1.0 (64-bit)

locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8

attached base packages:
[1] parallel  stats     graphics  grDevices utils     datasets  methods  
[8] base

other attached packages:
[1] GenomicTuples_0.1.0   GenomicRanges_1.17.35 GenomeInfoDb_1.1.18  
[4] IRanges_1.99.24       S4Vectors_0.1.2       BiocGenerics_0.11.4  
[7] devtools_1.5

loaded via a namespace (and not attached):
 [1] Biobase_2.25.0   digest_0.6.4     evaluate_0.5.5   httr_0.4
 [5] memoise_0.2.1    packrat_0.4.0.12 Rcpp_0.11.2      RCurl_1.95-4.3  
 [9] stats4_3.1.1     stringr_0.6.2    tools_3.1.1      whisker_0.3-2

--------------------------------
Peter Hickey,
PhD Student/Research Assistant,
Bioinformatics Division,
Walter and Eliza Hall Institute of Medical Research,
1G Royal Parade, Parkville, Vic 3052, Australia.
Ph: +613 9345 2324

hickey at wehi.edu.au
http://www.wehi.edu.au

______________________________________________________________________
The information in this email is confidential and intend...{{dropped:6}}
#
Hi Peter,

Some code would help here.  I'm not sure what you mean by having a matrix
as your extraColumnSlots. A derivative of GenomicRanges should definel a
method for extraColumnSlotNames that returns a character vector of names
for actual slots that the class defines. It sounds like you're trying to
represent all of the extra column slots with a single matrix slot, which is
not how the mechanism was designed.

Michael
On Mon, Aug 25, 2014 at 7:57 PM, Peter Hickey <hickey at wehi.edu.au> wrote:

            
#
Hi Michael,
Sorry for my misunderstanding. Here is some code describing the class https://github.com/PeteHaitch/GenomicTuples/blob/master/R/GTuples-class.R(the package is not yet installable but hopefully the in-progress code shows you what I'm trying to achieve).
The relevant slot is called "internalPos" and extraColumnSlotNames does indeed return this as a character vector. What I meant is that originally the internalPos slot was a matrix (or NULL). I switched to DataFrame (or NULL) because I was running into some problems related to replaceROWS when it was a matrix.
Thanks,Pete


----- Original Message -----From: Michael Lawrence <lawrence.michael at gene.com>To: Peter Hickey <hickey at wehi.edu.au>Cc: bioc-devel at r-project.orgSent: Tue, 26 Aug 2014 13:35:35 +1000 (EST)Subject: Re: [Bioc-devel] Valid classes for extraColumnSlots

Hi Peter,

Some code would help here.  I'm not sure what you mean by having a matrix as your extraColumnSlots. A derivative of GenomicRanges should definel a method for extraColumnSlotNames that returns a character vector of names for actual slots that the class defines. It sounds like you're trying to represent all of the extra column slots with a single matrix slot, which is not how the mechanism was designed.

Michael
On Mon, Aug 25, 2014 at 7:57 PM, Peter Hickey <hickey at wehi.edu.au> wrote:
Are the extraColumnSlots of a class that extends GenomicRanges limited to DataFrame objects?

Background: I wrote a class that extends the GRanges class. It has a matrix as the extraColumnSlots. When I use replaceROWS,GenomicRanges,GenomicRanges-method (via inheritance) it extracts this extraColumnSlots as a DataFrame object by use of GenomicRanges:::extraColumnSlotsAsDF. This means that the subsequent call to update() in replaceROWS,GenomicRanges,GenomicRanges-method fails because the class definition expects a matrix for the extraSlotNames but gets a DataFrame.

In this case, it's not a problem for me to change my extraColumnSlots element to a DataFrame in the class definition. However, more generally, some guidance on what classes are and are not allowed in extraColumnSlots would be appreciated.

Thanks,

Pete

This is using BioC devel:

sessionInfo()

R version 3.1.1 (2014-07-10)

Platform: x86_64-apple-darwin13.1.0 (64-bit)

locale:

[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8

attached base packages:

[1] parallel  stats     graphics  grDevices utils     datasets  methods

[8] base

other attached packages:

[1] GenomicTuples_0.1.0   GenomicRanges_1.17.35 GenomeInfoDb_1.1.18

[4] IRanges_1.99.24       S4Vectors_0.1.2       BiocGenerics_0.11.4

[7] devtools_1.5

loaded via a namespace (and not attached):

 [1] Biobase_2.25.0   digest_0.6.4     evaluate_0.5.5   httr_0.4

 [5] memoise_0.2.1    packrat_0.4.0.12 Rcpp_0.11.2      RCurl_1.95-4.3

 [9] stats4_3.1.1     stringr_0.6.2    tools_3.1.1      whisker_0.3-2

--------------------------------

Peter Hickey,

PhD Student/Research Assistant,

Bioinformatics Division,

Walter and Eliza Hall Institute of Medical Research,

1G Royal Parade, Parkville, Vic 3052, Australia.

Ph: +613 9345 2324

hickey at wehi.edu.auhttp://www.wehi.edu.au

______________________________________________________________________

The information in this email is confidential and intend...{{dropped:15}}
#
Do you have the code that actually fails? Then I could use it to reproduce
the problem and fix things.

Thanks,
Michael
On Tue, Aug 26, 2014 at 4:25 AM, Peter Hickey <hickey at wehi.edu.au> wrote:

            
#
Hi Michael,

Thanks for your patience. Here is a self-contained example with comments https://gist.github.com/PeteHaitch/fdb66d360446ff96ed4b

Thanks,
Pete
On 27/08/2014, at 1:43 AM, Michael Lawrence <lawrence.michael at gene.com> wrote:

            
--------------------------------
Peter Hickey,
PhD Student/Research Assistant,
Bioinformatics Division,
Walter and Eliza Hall Institute of Medical Research,
1G Royal Parade, Parkville, Vic 3052, Australia.
Ph: +613 9345 2324

hickey at wehi.edu.au
http://www.wehi.edu.au

______________________________________________________________________
The information in this email is confidential and intended solely for the addressee.
You must not disclose, forward, print or use it without the permission of the sender.
1 day later
#
Sorry it took so long. Fixed in S4Vectors 0.1.3. Surprisingly, we were
missing a replaceROWs,matrix method.
On Tue, Aug 26, 2014 at 5:13 PM, Peter Hickey <hickey at wehi.edu.au> wrote:

            
#
Thanks, Michael. Do you think there's a general use case for a replaceROWs, NULL method or shall I just specify that in my package? I require it because the slot is matrixOrNULL via a setClassUnion but I don't know how common that is amongst other BioC devels.

setMethod("replaceROWS", 
          "NULL",
          function(x, i, value) {
            NULL
          }
)

Thanks,
Pete
On 29/08/2014, at 8:34 AM, Michael Lawrence <lawrence.michael at gene.com> wrote:

            
#
Added to S4Vectors. Thanks!
On Thu, Aug 28, 2014 at 5:04 PM, Peter Hickey <hickey at wehi.edu.au> wrote: