Hi all,
I have to perform hierarchical clustering in R. I tried the following code to import data from excel file and I created a diagonal matrix.
n_seq <- 15
mat <- matrix(NA, ncol=n_seq, nrow=n_seq)
for (idx in 1:n_seq) {
mat[idx,idx] <- 0.0
}
for(idx in 1:(n_seq-1) ) {
intemp <- read.xls("C://clustal.xls", sheet = idx );
mat[(1+idx):n_seq,idx] <- intemp[1:(n_seq-idx), 11]
}
After this , when I use hclust function I am getting the following error.
hclust(mat)
Error in if (n < 2) stop("must have n >= 2 objects to cluster") :
argument is of length zero
How to remove this error? Please help me.
As it stands this is an R usage question, more suited to StackOverflow than here. Please indicate the relevance to bioinformatics.
Your matrix object might be null. Also make sure you have Perl installed.
read.xls()
runs perl in the backend.This is off topic imho. It's a pure R question.
Also, check the contents of your matrix, mat. It may not contain what you think it should contain.