How to save multiple assays and subsequent processed data in single SummarizedExperiment Object
1
0
Entering edit mode
@rohitsatyam102-24390
Last seen 5 weeks 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
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?

SummarizedExperiment • 1.4k views
ADD COMMENT
3
Entering edit mode
@laurent-gatto-5645
Last seen 1 day 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
ADD COMMENT
0
Entering edit mode

Really many thanks!! Laurent

ADD REPLY
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?

ADD REPLY
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)

ADD REPLY

Login before adding your answer.

Traffic: 1087 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6