Skip to content

Adding a new assay forces dimnames on all existing assays #96

Description

@LTLA

Pretty much as it says in the title - if I add a new assay, all of the existing assays are modified with the SE dimnames slapped on top:

library(SummarizedExperiment)

se <- SummarizedExperiment(list(foo = matrix(runif(200), ncol=10)))
rownames(se) <- LETTERS[1:20]
rownames(se) <- letters[1:10]

is.null(rownames(assay(se, "foo", withDimnames=FALSE)))
## [1] TRUE

another <- matrix(runif(200), ncol=10)
dimnames(another) <- dimnames(se)
assay(se, "bar") <- another

is.null(rownames(assay(se, "foo", withDimnames=FALSE)))
## [1] FALSE 

Similar behavior when removing an assay, which forces dimnames on all remaining assays:

library(SummarizedExperiment)

se <- SummarizedExperiment(list(foo = matrix(runif(200), ncol=10), bar = matrix(runif(200), ncol=10)))
rownames(se) <- LETTERS[1:20]
rownames(se) <- letters[1:10]

is.null(rownames(assay(se, "foo", withDimnames=FALSE)))
## [1] TRUE

assay(se, "bar") <- NULL

is.null(rownames(assay(se, "foo", withDimnames=FALSE)))
## [1] FALSE 

This is mostly problematic when saving objects as it unnecessarily duplicates information. Also, previously pristine DelayedArray objects are now wrapped with a DelayedSetDimnames, which interferes with some optimizations that try to operate directly on the delayed seed.

I'd wager that there's an assays() call somewhere inside assay<- that didn't set withDimnames=FALSE.

Session information
R version 4.6.0 Patched (2026-05-01 r89994)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.5 LTS

Matrix products: default
BLAS:   /home/luna/Software/R/R-4-6-branch-copy/lib/libRblas.so 
LAPACK: /home/luna/Software/R/R-4-6-branch-copy/lib/libRlapack.so;  LAPACK version 3.12.1

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: Australia/Sydney
tzcode source: system (glibc)

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

other attached packages:
 [1] SummarizedExperiment_1.43.0 Biobase_2.73.2             
 [3] GenomicRanges_1.65.1        Seqinfo_1.3.0              
 [5] IRanges_2.47.2              S4Vectors_0.51.6           
 [7] BiocGenerics_0.59.10        generics_0.1.4             
 [9] MatrixGenerics_1.25.0       matrixStats_1.5.0          

loaded via a namespace (and not attached):
 [1] SparseArray_1.13.2  Matrix_1.7-6        lattice_0.22-9     
 [4] abind_1.4-8         S4Arrays_1.13.0     XVector_0.53.0     
 [7] grid_4.6.0          DelayedArray_0.39.3 compiler_4.6.0     
[10] tools_4.6.0        

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