Error with pheatmap - 'from' must be a finite number
1
0
Entering edit mode
6 months ago
vmpsb • 0

I need to prepare a heatmap on top 36 genes with pheatmap but I keep getting this error:

Error in seq.int(rx[1L], rx[2L], length.out = nb) :
    'from' must be a finite number
In addition:
Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf

This is my code:

top_36 <- head(results(dds, contrast = c ("strain", "mut", "wt")), n=36)

mat <- counts(dds, normalized = T)[rownames(top_36), ]
mat.z <- t(apply(mat, 1, scale))
colnames(mat.z) <- coldata$sample
df <- as.data.frame(colData(dds)[,c("hour","strain")])

pheatmap(mat.z, annotation_col = df)

Can anyone point me to the error?

pheatmap r deseq2 • 1.8k views
ADD COMMENT
1
Entering edit mode

Show us the output to

mat.z[1:10,1:10]
any(is.infinite(mat.z))
ADD REPLY
0
Entering edit mode
any(is.infinite(mat.z))
[1] FALSE
ADD REPLY
0
Entering edit mode

That answers half of what I asked you. Where's the output to the first command?

ADD REPLY
0
Entering edit mode

Please report

# all(is.finite(dist(mat.z)))  # removed as pointed by Ram
all(is.finite(dist(mat.z)))
pheatmap(mat.z, cluster_rows = FALSE, cluster_cols = FALSE)
pheatmap(mat.z)
ADD REPLY
0
Entering edit mode

You already have the response to the first one, so there was no need to include that.

ADD REPLY
0
Entering edit mode
6 months ago
zx8754 12k

Errors and warnings are clear, we can reproduce them with this simple example

Somewhere pheatmap is getting a minimum value excluding NA values, when all values are NA, min returns Inf:

min(c(NA,NA,NA), na.rm = TRUE)
# [1] Inf
# Warning message:
#   In min(c(NA, NA, NA), na.rm = TRUE) :
#   no non-missing arguments to min; returning Inf

Then when we want to get a sequence of integers with from set to Inf, as expected, we get an error:

seq.int(from = Inf, to = 10)
# Error in seq.int(from = Inf, to = 10) : 'from' must be a finite number
ADD COMMENT
0
Entering edit mode

Thanks, how should I proceed?

ADD REPLY
0
Entering edit mode

I am not familiar with deseq data, but if it makes sense, remove rows/columns that have only NAs.

#remove rows
x<- mat.z[ rowSums(is.na(mat.z)) != ncol(mat.z), ]
#remove cols
mat.z.clean <- x[, colSums(is.na(mat.z)) != nrow(mat.z) ]
ADD REPLY

Login before adding your answer.

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