Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

I am using R for a simple hierarchical clustering method for finding protein sequence similarities. I already have a distance matrix computed. I am using the hclust method to run it (thus I dont want to use dist method). Could anyone tell me what format does my distance matrix need to be for hclust to run?

I used the read.xls method to read my Excel file. I need only the lower triangular portion of the matrix, and this is what I am sending to hclust to be clustered.

d= as.matrix(mat)
hc =hclust(d, method="single")

However this is the error I get:

Error in if (n < 2) stop("must have n >= 2 objects to cluster") : 
argument is of length zero
share|improve this question
Can't you just replace as.matrix by as.dist? – chl Aug 20 '11 at 9:14
@chl I tried as.dist function. But I got the error like this.Error in hclust(as.dist(mat), method = "single") : NA/NaN/Inf in foreign function call (arg 11) – vigneswaran Aug 20 '11 at 9:20
1  
I suspect you have some missing value(s) in your distance matrix (which doesn't hurt as.dist but hclust). You may want to impute them or try hybridHclust (never used myself). – chl Aug 20 '11 at 9:40
Any progress on your problem? – chl Aug 21 '11 at 12:34

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.