Question: Add new columns to DESeqResults from text file by matching rownames.
gravatar for kirannbishwa01
4 months ago by
kirannbishwa010 wrote:

I have generated results from DESeq2 wihch is a S4 type R-object. I want to add new columns to it containing geneNames, contig and start position.

There is method using BioMart to do it, but I won't be using the BioMart method; instead I have the geneDatabase as a textfile,

I have tried merging these two databases by `matching rownames` using merge, cbind,  but no success.

  • The merge method won't more because it can't bind data.frame to DESeqResults.
  • With `cbind` I can't bind because I have differing number of rows. The `DeSeqResults` have less number of rows/rownames because several rows were filtered, but it's rownames are subset of `geneMap` rownames.

I have tried using this and several other methods explained in stackoverflow, but success yet.

> merge(result.ASE_Data, geneMap)
Error in as(merge(as(x, "data.frame"), y, ...), class(x)) :  no method or default for coercing “data.frame” to “DESeqResults”

>, list(result.ASE_Data, geneMap))
Error: All inputs to rbind.fill must be data.frames

>, list(result.ASE_Data, geneMap))
Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 1761, 1865

> cbind(result.ASE_Data, geneMap)
Error in DataFrame(...) : different row counts implied by arguments
ADD COMMENTlink modified 4 months ago by Michael Love16k • written 4 months ago by kirannbishwa010
gravatar for Michael Love
4 months ago by
Michael Love16k
United States
Michael Love16k wrote:
dds <- makeExampleDESeqDataSet(n=200)
dds <- DESeq(dds)
res <- results(dds)
anno <- data.frame(id = rownames(res)[(1:100)*2], 

A short, automated version (so safer):

res$id <- rownames(res)
res.sub <- merge(as(res,"data.frame"), anno, by="id")

A longer version with manual merge (less safe), keeping the metadata:

m <- match(anno$id, rownames(res))
res.sub <- res[m,]
res.sub$score <- anno$score
mcols(res.sub)[7,] <- DataFrame(type="annotation", 
                                description="a score value")
ADD COMMENTlink modified 4 months ago • written 4 months ago by Michael Love16k
gravatar for Steve Lianoglou
4 months ago by
Steve Lianoglou12k wrote:

Call on your DESqResults objects before the merge, ie.

out <- merge(, geneMap, ...)

merge doesn't match by rownames, though, so you will have to specify the correct value for by, or a by.x and by.y combination of the column names in your result.ASE_Data and geneMap don't match up


ADD COMMENTlink written 4 months ago by Steve Lianoglou12k

Hi Steve,

I knew about this method, but the problem is that if you convert the S4-object using you are loosing valuable metadata information that are used downstream in the workflow.

Any other ideas.


ADD REPLYlink modified 4 months ago • written 4 months ago by kirannbishwa010
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 129 users visited in the last hour