If you only have NAs, it should work.
library(DESeq2)
counts = matrix(rnbinom(1000,mu=50,size=1),100,10)
colnames(counts) = paste0("c",1:10)
counts[sample(length(counts),10)] = NA
counts[is.na(counts)] <- 0
DESeqDataSetFromMatrix(counts, colData = data.frame(colnames(counts)), design = ~1)
If you have infinite values, it gives you a slightly different error:
counts = matrix(rnbinom(1000,mu=100,size=1),100,10)
colnames(counts) = paste0("c",1:10)
counts[1] = 2.5e9
DESeqDataSetFromMatrix(counts, colData = data.frame(colnames(counts)), design = ~1)
It looks like this:
converting counts to integer mode
Error in validObject(.Object) :
invalid class “DESeqDataSet” object: NA values are not allowed in the count matrix
In addition: Warning message:
In mde(x) : NAs introduced by coercion to integer range
Error comes about because you cannot convert the large numbers to integer:
max(counts)
[1] 8007375876
as.integer(max(counts))
[1] NA
Warning message:
NAs introduced by coercion to integer range
And this is smaller than the maximum allowed:
.Machine$integer.max
[1] 2147483647
For analysis purpose, since you are more interested in the difference between genes, one way is to scale the matrix down
DESeqDataSetFromMatrix(round(counts/2), colData = data.frame(colnames(counts)), design = ~1)