Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pheatmap scale="row" giving Error in hclust(d, method = method) : NA/NaN/Inf in foreign function call

I am trying to create a heatmap with gene expression values with the package pheatmap in R. I have used the code numerous times and never had a problem untill today. It seems when I do the scale="row" , I end up with this error. I cannot create the z-scores. So probably some rows have no variability for which this is happening. How can I get rid of this. The matrix is having 1100 rows and 9 columns. My code:

data  <- read.table("~path/DEGs_DESeq.txt",sep="\t")
data2 <- as.matrix(data[,2:9])
data3 <- data2[-1,]
samples <- data2[1,]
genes <- data[2:length(data2[,1]),1]
vett <- as.numeric(data3)
data4 <- matrix(vett, length(genes), length(samples), dimnames=list(paste(genes),paste(samples))) 
head(data4)

pheatmap(as.matrix(data4), col=bluered(200), scale="row", key=T, keysize=1.5,
    density.info="none", trace="none",cexCol=0.6, fontsize_row=8, fontsize_col=10)

Error in hclust(d, method = method) : NA/NaN/Inf in foreign function call (arg 11)

How can I get rid of this error?

like image 238
ivivek_ngs Avatar asked Sep 27 '22 21:09

ivivek_ngs


1 Answers

I infact worked it out.. i had to remove the rows for which no SD was coming up while performing the z score calculation and it reconstructed the heatmap. Thanks

like image 111
ivivek_ngs Avatar answered Oct 18 '22 14:10

ivivek_ngs