Comments (5)
Done in SummarizedExperiment 1.15.5 (see commit 7df70dc).
@LTLA This addresses your original issue so I'm closing this. Feel free to re-open if I missed something.
from summarizedexperiment.
Hi Aaron,
The dimnames
setter for SE objects is at the root of the problem.
My understanding is that the inner dimnames (i.e. the dimnames on the individual assays) are only allowed to be NULL
or the same as the outer dimnames (i.e. the dimnames of the SE object itself). This is actually enforced by the SE constructor:
library(SummarizedExperiment)
m <- matrix(1:12, nrow=4)
rowData <- DataFrame(stuff=11:14, row.names=letters[1:4])
se1 <- SummarizedExperiment(m, rowData=rowData)
dimnames(se1)
# [[1]]
# [1] "a" "b" "c" "d"
#
# [[2]]
# NULL
colnames(m) <- LETTERS[1:3]
se2 <- SummarizedExperiment(m, rowData=rowData)
dimnames(se2)
# [[1]]
# [1] "a" "b" "c" "d"
#
# [[2]]
# [1] "A" "B" "C"
rownames(m) <- LETTERS[1:4]
se3 <- SummarizedExperiment(m, rowData=rowData)
# Error in .validate_names(rownames, ans_rownames, "assay rownames()", "rowData rownames() / rowRanges names()") :
# assay rownames() must be NULL or identical to rowData rownames() /
# rowRanges names()
Unfortunately, for some reason, this is not checked by the validity method for SummarizedExperiment objects.
Now when you do:
mat <- matrix(1,1,1, dimnames=list("B", "GENE2"))
se <- SummarizedExperiment(list(counts=mat))
dimnames(se) <- list("A", "GENE1")
you end up with an object that is "wrong" (even though validObject(se)
returns TRUE
):
dimnames(se)
# [[1]]
# [1] "GENE1"
#
# [[2]]
# [1] "A"
dimnames(assay(se, withDimnames=FALSE))
# [[1]]
# [1] "GENE2"
#
# [[2]]
# [1] "B"
validObject(se)
# [1] TRUE
This "wrong" object causes problems later when you do assayNames(se) <- "whee"
or simply do the following no-op:
assays(se, withDimnames=FALSE) <- assays(se, withDimnames=FALSE)
# Error in `assays<-`(`*tmp*`, withDimnames = FALSE, value = new("SimpleList", :
# current and replacement dimnames() differ
So one thing we can do is fix the dimnames
setter by having it adjust (or drop) the inner dimnames to keep them in sync with the new outer dimnames.
@mtmorgan: But why do we care about the inner dimnames in the first place? Never really understood the motivation for this constraint. It feels arbitrary and counter productive to me. Couldn't we just ignore the inner dimnames? Benefits: simpler conceptual validity, simpler implementation of the SE constructor and a few setters (dimnames<-
, assays<-
), faster code (adjusting the inner dimnames could be expensive in some situations), and no more problems of the sort Aaron ran into. What could the downsides be?
If Martin has no objection, I'll remove this constraint.
from summarizedexperiment.
I think the inner dimnames are there for efficiency -- the most common way to access the data is assay()
; having dimnames on the result is usually desired; it's expensive (causes the assay to be copied) to add them. This was motivated by a use case / problem Kasper Hansen had several years ago with large methylation arrays, I don't know whether his concerns are still relevant...
from summarizedexperiment.
Thanks Martin. Just to clarify: right now the inner dimnames can be NULL
so we already are in a situation where they don't necessarily match the outer dimnames. And assay()
is already triggering copies when setting the outer dimnames on the returned assay (unless withDimnames=FALSE
is used). I'm not proposing to change that. All I'm proposing is that we let the inner dimnames be anything,
from summarizedexperiment.
ok by me.
from summarizedexperiment.
Related Issues (20)
- Should the show() method for SummarizedExperiment objects suggest saveHDF5SummarizedExperiment()? HOT 1
- Enforce unique assay names HOT 2
- `combineCols()` and `combineRows()` not listed in 'Usage' section HOT 4
- Consider assayData DataFrame for assays HOT 6
- Constructor could check that assay is in matric format HOT 2
- `all.equal(x, y)` vs `all(x == y)` HOT 3
- Remove all dimnames in `combine_assays_by` to avoid constructor check failures HOT 3
- `combineCols` should keep names in metadata with `use.names=TRUE`
- Erroneous behaviour when colData is data.frame
- package(s) not installed when version(s) same as or greater than current; use `force = TRUE` to re-install: 'SummarizedExperiment' HOT 1
- Add an `assaybind()` method
- Curious about how Rd manuals are generated HOT 3
- Feature request: keep rownames(se) and rownames() of DataFrame nested in rowData(se) in sync HOT 4
- metadata function is not exported as others HOT 1
- colData Default in Constructor Inconsistency HOT 1
- Warning about dim, nrow and ncol deprecated methods.
- Warning and error message when using '$' operator on summarizedExperiment object HOT 5
- Depreciated function calls in DelayedArray HOT 4
- Rows being removed from ASV table when building SummarizedExperiment
- Clarify withDimnames=FALSE in the documentation HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from summarizedexperiment.