Question: Add new columns to DESeqResults from text file by matching rownames.
0
gravatar for kirannbishwa01
20 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”

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

> do.call(cbind.data.frame, 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 20 months ago by Michael Love24k • written 20 months ago by kirannbishwa010
Answer: Add new columns to DESeqResults from text file by matching rownames.
3
gravatar for Michael Love
20 months ago by
Michael Love24k
United States
Michael Love24k wrote:
dds <- makeExampleDESeqDataSet(n=200)
dds <- DESeq(dds)
res <- results(dds)
anno <- data.frame(id = rownames(res)[(1:100)*2], 
                   score=runif(100))

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")
​mcols(res.sub)
ADD COMMENTlink modified 20 months ago • written 20 months ago by Michael Love24k
Answer: Add new columns to DESeqResults from text file by matching rownames.
1
gravatar for Steve Lianoglou
20 months ago by
Denali
Steve Lianoglou12k wrote:

Call as.data.frame on your DESqResults objects before the merge, ie.

out <- merge(as.data.frame(result.ASE_Data), 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 20 months ago by Steve Lianoglou12k

Hi Steve,

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

Any other ideas.

 

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

Help
Access

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