raivokolde / pheatmap

Pretty heatmaps
225 stars 83 forks source link

na_col doesn't work #93

Open Ruiqi-CUB opened 1 year ago

Ruiqi-CUB commented 1 year ago

Hi there, pheatmap gives me the error below when there is NA in my input. I installed it via github install_github("raivokolder/pheatmap"). Thanks a lot!

packageVersion("pheatmap") [1] ‘1.0.12’

> pheatmap(as.matrix(ktable), na_col="black",clustering_distance_cols="correlation")
Error in hclust(d, method = method) : 
  NA/NaN/Inf in foreign function call (arg 10)
AlexWeinreb commented 4 months ago

This error indicates that the clustering fails because of NA. You can still get the (unclustered) heatmap with:

pheatmap(as.matrix(ktable),
         cluster_rows = FALSE,
         cluster_cols = FALSE,
         na_col="black")

To perform clustering in the presence of missing values, you have to make some decisions (removing them, imputing them, ...), which pheatmap() can not do for you. There is discussion elsewhere, e.g. here or there.