[DeSeq2] some values in assay are negative
2
1
Entering edit mode
6.7 years ago

Hi, I'm trying to use DeSeq2 to calculate gene expression levels.

My count table (all_counts) looks like this

gene cell1 cell2
1 ENSMUST00000000001 712   1613
2 ENSMUST00000000003   0      0
3 ENSMUST00000000010   2      3
4 ENSMUST00000000028   0      0
5 ENSMUST00000000033   0      0

I'm call DESeqDataSetFromMatrix

dds <- DESeqDataSetFromMatrix(countData = all_counts,
                              colData = data.frame(c('gene', 'cell1', 'cell2')))

But I'm always getting this error

Error in DESeqDataSet(se, design = design, ignoreRank) : 
some values in assay are negative

But there are no negative values. I verified this by

> any (!is.integer(all_counts[,2]))
[1] FALSE
> any (!is.integer(all_counts[,3]))
[1] FALSE 
> any (all_counts[,2] < 0)
[1] FALSE
> any (all_counts[,3] < 0)
[1] FALSE

Any ideas what I'm doing wrong?

RNA-Seq DeSeq2 R • 22k views
ADD COMMENT
10
Entering edit mode
6.7 years ago
zx8754 12k

From the manuals the countData must be a numeric matrix, from your example all_counts, it looks like a dataframe.

Try to convert it to matrix:

countDataMatrix <- as.matrix(all_counts[ , -1])

And keep the names of the genes in the rownames (as suggested by @DevonRyan in the comments):

rownames(countDataMatrix) <- all_counts[ , 1]
ADD COMMENT
0
Entering edit mode

Thx for your reply. I tried changing the call to

dds <- DESeqDataSetFromMatrix(countData = as.matrix(all_counts),
                          colData = data.frame(c('gene', 'cell1', 'cell2')))

But I'm still getting the same error message.

ADD REPLY
1
Entering edit mode

Try dropping the first column: countData = as.matrix(all_counts[ , -1]

ADD REPLY
0
Entering edit mode

Thank you very much, this works. So do I have to store the gene ids by my self in an extra vector or is there a better way how to keep the gene ids associated with the rows?

In this example they don't have to drop the gene ids but I don't know why it's not working in my case: https://informatics.fas.harvard.edu/differential-expression-with-deseq2.html

ADD REPLY
2
Entering edit mode

Set the gene IDs to be the row names of the matrix.

ADD REPLY
0
Entering edit mode
23 months ago
Oliver • 0

I had the same problem, but also needed to set the column names explicitely and set the matrix content to integers. So I also want share what worked for me:

ctsTable <- read.table(ctsFile_path, sep="\t", header=FALSE, stringsAsFactors=FALSE)
countDataMatrix <- as.matrix(ctsTable[-1,-1])   # Extract counts & Ignore first column (geneID) and first row (sample names)
mode(countDataMatrix) <- "integer"   # Convert to integer
rownames(countDataMatrix) <- ctsTable[-1,1]     # Set rownames to geneIDs
colnames(countDataMatrix) <- ctsTable[1,-1]      # Set colnames to sample names

dds <-  DESeqDataSetFromMatrix(countData = countDataMatrix)
ADD COMMENT

Login before adding your answer.

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