SummarizedExperiement extract assay with no name
2
0
Entering edit mode
georgina.fqw ▴ 10
@georginafqw-23788
Last seen 5 months ago

HI,

I got a SummarizedExperiment file and would like to extract gene expression for further analysis. However, there is no name for the assay, how I can change the name or subset data. Thank you

data

class: SummarizedExperiment 
dim: 15093 100 
metadata(0):
assays(1): ''
rownames(15093): ENSG00000000003 ENSG00000000419 ... ENSG00000273488 ENSG00000273489
rowData names(3): Ensembl_ID GeneID EntrezID 
colnames(100): 1 2 3 ... 99 100
colData names(14): number age ... status

assayNames(data)

NULL

assay(data, " ")[1:3,1:3]

'assay(<SummarizedExperiment>, i="character", ...)' invalid subscript 'i'
'''' not in names(assays(<SummarizedExperiment>))

If I want to subset data@assays[[1]]

Error in data@assays[[1]] : this S4 class is not subsettable
deseq2 • 167 views
ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen 6 hours ago
United States

Whenever you need to know something about an S4 class, you can (usually) do something like

?SummarizedExperiment-class

And which brings up the help page, which includes this


Usage:

     ## Constructor

     # See ?RangedSummarizedExperiment for the constructor function.

     ## Accessors

     assayNames(x, ...)
     assayNames(x, ...) <- value
     assays(x, withDimnames=TRUE, ...)
     assays(x, withDimnames=TRUE, ...) <- value

And further down, this


Accessors:

     In the following code snippets, 'x' is a SummarizedExperiment
     object.

     'assays(x)', 'assays(x) <- value': Get or set the assays. 'value'
          is a 'list' or 'SimpleList', each element of which is a
          matrix with the same dimensions as 'x'.

     'assay(x, i)', 'assay(x, i) <- value': A convenient alternative
          (to 'assays(x)[[i]]', 'assays(x)[[i]] <- value') to get or
          set the 'i'th (default first) assay element. 'value' must be
          a matrix of the same dimension as 'x', and with dimension
          names 'NULL' or consistent with those of 'x'.

     'assayNames(x)', 'assayNames(x) <- value': Get or set the names of
          'assay()' elements.

Which I believe answers your question.

ADD COMMENT
0
Entering edit mode

Hi James,

Yes, that helped. Thank you very much.

I did change the name

assayNames(data) <- "counts"

and changed the subsetting slightly and it worked.

assay(data, "counts")

Thanks again.

ADD REPLY
0
Entering edit mode
@martin-morgan-1513
Last seen 22 days ago
United States

Here's a no-name SummarizedExperiment

> se = SummarizedExperiment(matrix(1:10, 5))
> se
class: SummarizedExperiment
dim: 5 2
metadata(0):
assays(1): ''
rownames: NULL
rowData names(0):
colnames: NULL
colData names(0):

accessing the single assay is easy

> assay(se)
     [,1] [,2]
[1,]    1    6
[2,]    2    7
[3,]    3    8
[4,]    4    9
[5,]    5   10

as is subsetting

> assay(se[1:2,])
     [,1] [,2]
[1,]    1    6
[2,]    2    7
ADD COMMENT

Login before adding your answer.

Traffic: 422 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