I'm very sorry for the incomplete example on the wrong channel. I'm new to this. Thank you anyway for helping me. Removing rows with zero-variance solved the problem for me. Thanks!
Hi all,
I get the following Error:
Error in do_one(nmeth) : NA/NaN/Inf in foreign function call (arg 1)
I'm trying to make a heatmap (pheatmap package) using K means. I have a large matrix (x) and I did the following:
x[x < 0] <- NA
x2 <- x[complete.cases(x),]
RedBlue <- colorRampPalette(c("blue", "white", "red")) (20)
pheatmap(x2, scale="row", kmeans_k=100, cluster_rows=TRUE, cluster_cols=TRUE, clustering_method = "ward.D2",color=RedBlue, legend=FALSE, show_colnames=TRUE, fontsize=15, fontface="bold", border_color=NA, width=20, heigth=100, cellwidth=30, cellheight = 5, show_rownames = FALSE, filename = "Heatmap.tiff")
I checked for NA/NaN/Inf but I don't have this is my matrix. What can be another reason for this error?
Thanks!
2 answers
This is not a bioinformatics question. Also before posting in a more appropriate channel, provide a reproducible example.
Now since I am here...
This error can happen for several reasons the most common being:
- presence of NAs, including those produced by scale() in the case of variables with 0 variance
- presence of non-numerical values
first of all clear those variables that have a unique value from you CSV file.
then use this code X2 [is.na(X2)] = 0 before you call the pheatmap (x2 is your file name)
and make sure that, your scale is in "row" not column.
Log in to answer this question.