Error when constructing DESeqDataSetFromMatrix (Error in round(assay(se)): non-numeric argument to mathematical function)
Entering edit mode
Last seen 4.5 years ago

Hello all,

I'm very new to all of this so please bear with me, but I'm trying to do some RNA-seq data analysis using DESeq2. I am attempting to construct a DESeqDataSet using the DESeqDataSetFromMatrix command:

dds <- DESeqDataSetFromMatrix(countData = cts_clean,
                              colData = coldata,
                              design = ~ 1)

But when I run the command I receive the following error:

Error in round(assay(se)) : non-numeric argument to mathematical function

From all the Googling I've done it seems like this is caused by some non-numeric character somewhere throwing a wrench into things, but I can't figure out where the issue is coming from.

I understand I need two pieces to generate the dataset - a matrix of integers (cts_clean; 33602 rows corresponding to gene_id names and 32 columns corresponding to samples) and a table containing sample information (coldata; 32 rows corresponding to the 32 samples/columns in cts_clean and 4 columns corresponding to sample conditions: Gravity, Run, Position, and Dataset). In my colData table all the columns are integers with the exception of the Gravity column which contains decimal values between 0.00 and 0.88 (could this be the issue?). 

I've also made sure the rowname/colname rows and columns are not present in the dataframes I feed to the function: for the countData table, the gene_ids are the rownames and the samplenames are the colnames, so it should ostensibly be a 33602 x 32 table of integers. Likewise, the coldata table is a 32 x 4 table of integers with the exception of the Gravity column, which contains decimals. But no non-numeric characters.

Since it seems relevant from the Googling I've done, here are the results of running str() on both tables:

> str(cts_clean)
 chr [1:33602, 1:32] "   741" "   465" "    33" "  1299" ...
 - attr(*, "dimnames")=List of 2
  ..$ : chr [1:33602] "AT1G01010" "AT1G01020" "AT1G01030" "AT1G01040" ...
  ..$ : chr [1:32] "F02" "F04" "F06" "F08" ...


> str(coldata)
'data.frame':	32 obs. of  4 variables:
 $ Gravity : num  0.65 0.88 0.53 0.76 0.65 0.88 0.53 0.76 0 0 ...
 $ Run     : int  1 1 1 1 1 1 1 1 1 1 ...
 $ Position: int  2 4 1 3 2 4 1 3 2 4 ...
 $ Dataset : int  2 2 2 1 2 2 2 1 2 2 ...

Would appreciate some help determining what is causing this error! I'm happy to provide more information if necessary! 

Very new to this so please bear with me :)

Thanks for your time!


deseq2 R error • 2.0k views
Entering edit mode
Last seen 2 days ago
United States

It looks like your counts matrix is “chr”, a matrix of characters. The constructor should have printed a warning about this. But anyway maybe it hit a bug before printing a useful message. The solution is to provide integers.

Entering edit mode

I'm fixing this in the devel branch, the new error will say:

Error in DESeqDataSet(se, design = design, ignoreRank) :
counts matrix should be numeric, currently it is: character
Entering edit mode

Hi Michael,

Yup, that was the issue, thanks so much for the help! :)



Login before adding your answer.

Traffic: 196 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6