Skip to content

replacing dimnames with identical values demotes >2-dim DelayedArray derivatives into DelayedArray #54

@Liubuntu

Description

@Liubuntu

Hi @hpages ,

To continue with the slack conversion, I'm opening an issue here for better track.

In my case of GDSArray, if already a 2-dimensional GDSMatrix, replacing the dimnames with identical values is expected as no-op. However, for >2-dimensional GDSArray, replacing dimnames[1:2] with identical values demotes the object into DelayedDimnames.

library(SeqArray)
library(GDSArray)

gds <- SeqArray::seqExampleFileName("gds")
ga1 <- GDSArray(gds, "genotype/data")
ga2 <- GDSArray(gds, "phase/data")

names(dimnames(ga2))
## [1] "variant.id" "sample.id"                                                                                                                                                                                                                              
names(dimnames(ga1))
## [1] "variant.id" "sample.id"  "ploidy.id"                                                                                                                                                                                                                 
identical(dimnames(ga1)[1:2], dimnames(ga2))
## [1] TRUE                                                                                                                                                                                                                                                  

dnames <- dimnames(ga2)
dimnames(ga2) <- dnames
is(ga2, "GDSMatrix")
## [1] TRUE                                                                                                                                                                                                                                                  
str(ga2)
## no-op                                                                                                                                                                                                                                                     

dimnames(ga1)[1:2] <- dnames  ## demoted as "DelayedDimnames", not a no-op.                                                                                                                                                                                  
is(ga1, "GDSArray")
## [1] FALSE                                                                                                                                                                                                                                                 
str(ga1)
## Demoted into "DelayedDimnames"                                                                                                                                                                                                                            

I was mainly curious about this performance. In your development of DelayedArray, was it something expected? Or are you also expecting no-op for this kind of operation?

The question comes from the assay,SummarizedExperiment method, when I put the 3-dimensional GDSArray into the @assay slot, each time calling of assays(se) will demotes the object inside @assays into DelayedArray (internally as DelayedDimnames).

!> selectMethod(assays, "SummarizedExperiment")
 Method Definition:

 function (x, ..., withDimnames = TRUE)
 {
     assays <- as(x@assays, "SimpleList")
     if (withDimnames) {
         assays <- endoapply(assays, function(assay) {
             dimnames(assay)[1:2] <- dimnames(x)
             assay
         })
     }
     assays
 }

For the source of this question from my package VariantExperiment, It doesn't really matter to check is(, "GDSArray") or is(, "DelayedArray"), and I also think your idea for an updated show method would be nice. Like your example in slack:

<6 x 2 x 90354753> DelayedArray object of type "list" with a seed of class GDSArraySeed: 

Thanks,
Qian

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions