error in hcluster although there is no NA/NAN/infinite
1
0
Entering edit mode
4.4 years ago
Kai_Qi ▴ 130

I have big datamatrix and I want to learn to set the clustering before drawing heatmap.

> hc <- hclust(as.dist(1-cor(t(mydat1))))
Error in hclust(as.dist(1 - cor(t(mydat1)))) : 
  NA/NaN/Inf in foreign function call (arg 10)
In addition: Warning message:
In cor(t(mydat1)) : the standard deviation is zero

I have tested the matrix using:

> sumis.na(mydat1))
[1] 0
> sum(is.nan(mydat1))
[1] 0
> sum(is.infinite(mydat1))
[1] 0

What happened in my situation? It looks that the warning is that the standard deviation is zero. What does it mean, will it affect the following steps?

If warning is a big issue why not set it as error?

Thanks

R Heatmap clustering • 4.6k views
ADD COMMENT
2
Entering edit mode
4.4 years ago

This is not really a bioinformatics question, more of an R programming one. The warning tells you that you have at least one constant row in your matrix (i.e constant column of the transpose). That's not a problem in itself. However, remember how correlation is computed: there's a division by the standard deviation. R is happy to divide by 0, it just produces NA. Now a distance matrix can contain NA but hclust doesn't know how to deal with it so that's where the error happens.

ADD COMMENT
0
Entering edit mode

Thank you very much for your comments. It looks that I need to learn some mathematics. I was trying to understand how to use different way to cluster the gene expression level. I know some methods like pearson/speraman but I cannot understand them. Also R learning is still not there yet.

Thank you again

ADD REPLY

Login before adding your answer.

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