Comments (6)
I think it is a good idea to produce a small demonstration of what you are hoping for, with the extra information going into the metadata element. Define your operations as plain R functions and then we can evaluate what infrastructure changes and methods might be warranted.
from summarizedexperiment.
I was thinking I could test a small R package that populates assayData as a DataFrame in the metadata slot. I would try to implement a 3-dimension subset method that would also keep the assayData in sync with the assays.
Iβm not sure how to intercept adding an assay, I guess a custom function like:
addSEassay(se, assaylist, assayData=NULL)
Itβs tricky to add an empty row to assayData. If user supplies assayData the simplest approach would be to require it to contain the same colnames already in the se object.
Is there a similar utility to add a row to rowData or colData? I donβt remember seeing one.
from summarizedexperiment.
I don't know how people expect to have a productive discussion, especially a technical one, on Twitter
@jmw86069 The assays()
getter returns the assays in a SimpleList which is something that can hold metadata columns (like any other Vector derivative):
library(SummarizedExperiment)
se <- SummarizedExperiment(list(A1=matrix(1:12, ncol=3), A2=matrix(101:112, ncol=3)))
assays(se)
# List of length 2
# names(2): A1 A2
class(assays(se))
# [1] "SimpleList"
# attr(,"package")
# [1] "S4Vectors"
mcols(assays(se)) <- DataFrame(assayid=c("id1", "id2"), isnormalized=c(TRUE, FALSE), otherstuff=c("X", "Y"))
mcols(assays(se))
# DataFrame with 2 rows and 3 columns
# assayid isnormalized otherstuff
# <character> <logical> <character>
# A1 id1 TRUE X
# A2 id2 FALSE Y
Is this what you are after?
from summarizedexperiment.
Wow that's actually very helpful, thank you! @hpages
You're right about tech discussions on Twitter, but it did (eventually) get enough visibility for a response! Also, I didn't know where to ask at first. I was hoping something existed already, and at least that part was correct.
I've been a longtime user of Bioc classes, and of SummarizedExperiment. It never occurred to me that List would also have metadata columns. That's my fault.
The only little issue is that adding to assays(se) <-
does not update the mcols(assays(se))
and so it has to be done in a second step. Not a big deal, I can work with that.
For my purposes, I don't have a driving reason to request any changes to the infrastructure, I'll close this issue.
from summarizedexperiment.
The only little issue is that adding to assays(se) <- does not update the mcols(assays(se))
Not sure what you mean by "adding to assays(se) <-
".
With assays(se) <-
assays(se) <- c(assays(se), rev(assays(se)))
mcols(assays(se))
# DataFrame with 4 rows and 3 columns
# assayid isnormalized otherstuff
# <character> <logical> <character>
# A1 id1 TRUE X
# A2 id2 FALSE Y
# A2 id2 FALSE Y
# A1 id1 TRUE X
and with assay(se, i) <-
:
assay(se, 5L) <- matrix(201:212, ncol=3)
mcols(assays(se))
# DataFrame with 5 rows and 3 columns
# assayid isnormalized otherstuff
# <character> <logical> <character>
# A1 id1 TRUE X
# A2 id2 FALSE Y
# A2 id2 FALSE Y
# A1 id1 TRUE X
# NA NA NA
Looks fine to me.
Please open a new issue and provide details if this doesn't work for you or if you were expecting something else.
H.
from summarizedexperiment.
Yes, I should have clarified - I think current behavior is working as expected now that I understand about mcols
here. :) All good.
The "only little issue" was practical for me: adding an assay as a numeric matrix directly (shown in your second example) creates NA
values in the mcols
DataFrame. Not a problem at all, just a thing for me to handle accordingly.
I like your first example, which requires creating a SimpleList
with the new assay. I understand this is how to add a new assay with metadata:
# A. start as before
se <- SummarizedExperiment(list(A1=matrix(1:12, ncol=3),
A2=matrix(101:112, ncol=3)))
mcols(assays(se)) <- DataFrame(assayid=c("id1", "id2"),
isnormalized=c(TRUE, FALSE),
otherstuff=c("X", "Y"))
# B. new assay matrix
new_matrix <- assays(se)[[1]] + 100
# new mcols for this assay matrix
new_mcols <- DataFrame(assayid="id1_plus10",
isnormalized=TRUE,
otherstuff="Z")
# make a SimpleList for the new assay
new_assays <- SimpleList(A1_plus10=new_matrix)
# add mcols in a second step
mcols(new_assays) <- new_mcols
# C. add the assay
assays(se) <- c(assays(se), new_assays);
mcols(assays(se))
# DataFrame with 3 rows and 3 columns
# assayid isnormalized otherstuff
# <character> <logical> <character>
# A1 id1 TRUE X
# A2 id2 FALSE Y
# A1_plus10 id1_plus10 TRUE Z
The SimpleList(...)
step is interesting, there is no constructor that also includes the metadata.
For example something like SimpleList(..., mcols=DataFrame())
Do you recommend the two step process, or is there a fancier approach?
new_assays <- SimpleList(new_assay=new_assay)
mcols(new_assays) <- new_mcols
from summarizedexperiment.
Related Issues (20)
- Adding checkDimnames=FALSE to the SE constructor HOT 1
- subset fails when subsetting a SummarizedExperiment object with no samples HOT 11
- 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
- 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
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.