Biostar Beta. Not for public use.
How to edit count matrix of a DESeq object?
0
Entering edit mode
2.4 years ago
kjkjindal • 0

Hi,

In the counts documentation (https://www.rdocumentation.org/packages/DESeq2/versions/1.12.3/topics/counts) there is a line which implies the count matrix of a deseq object can be edited:

## S4 replacement method for signature 'DESeqDataSet,matrix'
counts(object) <- value

However, when I try this, I get the following error:

Error in (function (classes, fdef, mtable)  : 
unable to find an inherited method for function ‘counts<-’ for signature ‘"DESeqDataSet", "data.frame"’

Does anyone know how to solve this?

P.S. I am using the tximport function of DESeq2, so I can't plug in a custom count matrix, unlike the 'import from Matrix' function.

ADD COMMENTlink
0
Entering edit mode

Why would you want to edit it as opposed to just modifying your source data and then reading in whatever data you want?

ADD REPLYlink
0
Entering edit mode
2.0 years ago
YaGalbi ♦ 1.4k
Biocomputing, MRC Harwell Institute, Ox…

Apart from the documentation, I suggest posting this in Bioconductor.

ADD COMMENTlink
0
Entering edit mode
16 months ago
Limoges, CBRS, France

From the DESeq2 documentation

The argument minReplicatesForReplace is used to decide which samples are eligible for automatic replacement in the case of extreme Cook’s distance. By default, DESeq will replace outliers if the Cook’s distance is large for a sample which has 7 or more replicates (including itself). This replacement is performed by the replaceOutliers function. This default behavior helps to prevent filtering genes based on Cook’s distance when there are many degrees of freedom. See results for more information about filtering using Cook’s distance, and the ’Dealing with outliers’ section of the vignette. Unlike the behavior of replaceOutliers, here original counts are kept in the matrix returned by counts, original Cook’s distances are kept in assays(dds)[["cooks"]], and the replacement counts used for fitting are kept in assays(dds)[["replaceCounts"]].

As you can read it is not about editing the counts by yourself but a DESeq behaviour when you have extreme Cook’s distance.

If minReplicatesForReplace is used by DESeq, you have an option in counts function to use these replaceCounts or not.

ADD COMMENTlink
0
Entering edit mode
16 months ago
United States

try:

counts(object) <- as.matrix(value)

As the error message implies, the function counts does not know how to handle a data.frame, which I'm assuming value is.

ADD COMMENTlink

Login before adding your answer.

Similar Posts
Loading Similar Posts
Powered by the version 2.3.1