How to add a column to metadata in SummarizedExperiment for DESeq2 type objects?
1
0
Entering edit mode
mschmidt ▴ 10
@mschmidt-18923
Last seen 7 months ago
Poznan

Is it possible to a add column directly to metadata in SummarizedExperiment? I tried to add a column named Other to metadata and later fill it with my additional data. I did:

experimentSummary$rnaseq = cbind(mcols(experimentSummary$rnaseq),"Other")

Which seem like removing all original metadata and only "Other" exists, original metadata is lost

I tried also:

experimentSummary$rnaseq = cbind(colData(experimentSummary$rnaseq),"Other")

which seems to work inspecting the object with View(experimentSummary) but there is something wrong with format of the metadata. Also column name is "Other" with quotation marks and all rows in that column are filled with "Other" string.

DESeq2 SummarizedExperiment • 3.1k views
ADD COMMENT
0
Entering edit mode
@mikelove
Last seen 11 hours ago
United States

Can you try:

mcols(x)$newCol <- y
ADD COMMENT
0
Entering edit mode

Hi Michael, it didn't work. I also tried to rename one spare (empty, the 5th) column with

rename(names(colData(experimentSummary$rnaseq))[5], "Other")

also, didn't work, than got the vector of names using

nameses = names(colData(experimentSummary$rnaseq))

then changed name of the 5th (empty) column into my "Other"

nameses[5] = "Other"

than tried to rename all the columns

rename(experimentSummary$rnaseq, nameses)

again no result, so I tried

names(colData(experimentSummary$rnaseq)) = nameses

it seems to work but the experimentSummary object changed its volume from 5MB to 61.9MB ?!!!

I am not sure is it OK, I think such operation should not affect the object size.

What could be wrong?

Best regards, Marcin

ADD REPLY
2
Entering edit mode

I'm a little confused why my suggestion didn't work, can you make a reproducible example and provide the error output?

library(SummarizedExperiment)
se <- SummarizedExperiment(matrix(1:4,ncol=2), rowData=DataFrame(x=1:2))
> mcols(se)
DataFrame with 2 rows and 1 column
          x
  <integer>
1         1
2         2

> mcols(se)$y <- 3:4

> mcols(se)
DataFrame with 2 rows and 2 columns
          x         y
  <integer> <integer>
1         1         3
2         2         4
ADD REPLY
0
Entering edit mode

Hi, your example worked exactly as you expected. But not my case. Could you download https://www.ebi.ac.uk/gxa/experiments-content/E-MTAB-2836/static/E-MTAB-2836-atlasExperimentSummary.Rdata

get(load('E-MTAB-2836-atlasExperimentSummary.Rdata'))
names(colData(experimentSummary$rnaseq))

and add there one column

ADD REPLY
3
Entering edit mode
load("E-MTAB-2836-atlasExperimentSummary.Rdata")
se <- experimentSummary[[1]]
mcols(se)$new <- rep(0,nrow(se)) # a rowData column
colData(se)$new <- rep(0,ncol(se)) # a colData column
ADD REPLY
0
Entering edit mode

Great, thank you very much! That is what I was looking for! Best regards, Marcin

ADD REPLY

Login before adding your answer.

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