Hi Everyone!!
I am trying to save multiple assays and their altered form and then store all of it in an organised way in summarized experiment object. For example, saving both raw gene counts and log-normalised counts in a single summarized experiment.
Here is a bit of the code I tried but I am unsure what's way forward?
## Preparing 3 dummy assays m, n, o
set.seed(123)
m <- matrix(
rnorm(12), nrow = 4, ncol = 3,
dimnames = list(letters[1:4], LETTERS[1:3])
)
n <- matrix(
rnorm(12), nrow = 4, ncol = 3,
dimnames = list(letters[1:4], LETTERS[1:3])
)
o <- matrix(
rnorm(12), nrow = 4, ncol = 3,
dimnames = list(letters[1:4], LETTERS[1:3])
)
## storing multiple assays in form of list
l <- list(assay1=m,assay2=n,assay3=o)
## Creating summarized experiment object
colData <- DataFrame(Count=c("P001A","P001B","P001C"),
row.names=LETTERS[1:3])
rowData <- DataFrame(Genes=c("Gene1","Gene2","Gene3","Gene4"), row.names=LETTERS[1:4])
sm <- SummarizedExperiment(assays=l,
rowData=rowData, colData=colData)
## adding one to all the assays
add <- function(i){abs(assays(sm)[[i]]) + 1}
lst <- list(1,2,3)
lapply(lst,add)
Now I wish to add these altered matrices to the existing SummarizedExperiment
object sm
so as to update it with suitable names so that they can be accessed later on. Do I need to recreate the sm
object every time I need to update it using the SummarizedExperiment
function and updating the assay
argument with extended list l
?
Really many thanks!! Laurent
I also wish to understand if we can add multiple colData and rowData for multiple assay to the same SE object?
No, there's a single col/rowData per SE, which makes sense if you think that the different assays represent the same set of features/samples (and must, I believe, be of identical dimensions)