How to save multiple assays and subsequent processed data in single SummarizedExperiment Object
1
0
Entering edit mode
@rohitsatyam102-24390
Last seen 6 days ago
India

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
lst <- list(1,2,3)


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?

SummarizedExperiment • 132 views
3
Entering edit mode
@laurent-gatto-5645
Last seen 13 hours ago
Belgium

The following seem to work

> assays(sm) <- c(assays(sm), lapply(lst,add))
> assays(sm)
List of length 6
> validObject(sm)
[1] TRUE

0
Entering edit mode

Really many thanks!! Laurent

0
Entering edit mode

I also wish to understand if we can add multiple colData and rowData for multiple assay to the same SE object?

1
Entering edit mode

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)