This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Error while using ComplexHeatmap

Hi,

I am using the ComplexHeatmap library to obtain the heatmap of the data. There are 19 rows (samples- different timepoints) and 264 genes (columns). There are few missing values in the data frame. I keep getting the below error message. Also attached is the screenshot of the data. Please assist me in resolving this error.

library(ComplexHeatmap)
library(circlize)

Neg_Dct <- read.csv(file = "./NegDCt_Subject_B1.csv",stringsAsFactors = FALSE)

## Check missing values ##
is.na(Neg_Dct)

## Create a data frame by ignoring columns 1 to 4- categorical data###
df = Neg_Dct[,-c(1:4)]

my_matrix <- as.matrix(df)

class(df)
[1] "data.frame"
class(my_matrix)
[1] "matrix"

Heatmap(my_matrix)

Error in hclust(get_dist(t(mat), distance), method = method) : 
  NA/NaN/Inf in foreign function call (arg 11)

Imgur

complexheatmap missing values r library

1 answer

The NAs in your data are causing the clustering to fail. If you want clustering, you could either restrict to complete cases or do the clustering over imputed values; then I think you can pass in the cluster object to ComplexHeatmap (Can't quite remember TBH)

Log in to answer this question.