Error in do_one(nmeth) : NA/NaN/Inf in foreign function call (arg 1)
2
1
Entering edit mode
4.7 years ago
AP ▴ 20

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!

kmeans R pheatmap • 16k views
ADD COMMENT
1
Entering edit mode
4.7 years ago

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

ADD COMMENT
1
Entering edit mode

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!

ADD REPLY
0
Entering edit mode
4.3 years ago
aymaigoro • 0

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.

ADD COMMENT

Login before adding your answer.

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