Question

I am trying to cluster a data matrix produced from scientific data. I know how I want the clustering done, but am not sure how to accomplish this feat in R.

Here is what the data looks like:

            A1     A2     A3     B1     B2     B3     C1     C2     C3
sample1      1      9     10      2      1     29      2      5     44
sample2      8      1     82      2      8      2      8      2     28
sample3      9      9     19      2      8      1      7      2     27

Please consider A1,A2,A3 to be three replicates of a single treatment, and likewise with B and C. Sample1 are different tested variables. So, I want to hierarchically cluster this matrix in order to see the over all differences between the columns, specifically I will be making a dendrogram (tree) to observe the relatedness of the columns.

Does anyone know how to appropriately cluster something like this? I tried doing this with this:

raw.data <- read.delim("test.txt",header=FALSE,stringsAsFactors=FALSE)
dist.mat<-vegdist(raw.data,method="jaccard")
clust.res<-hclust(dist.mat)
plot(clust.res)

...However, this resulted in a tree with branches for each sample variable, instead of each column. Thanks for any suggestions!

Was it helpful?

Solution

Just transpose your data set:

raw.data <- t(raw.data)
require(vegan)
dist.mat<-vegdist(raw.data,method="jaccard")
clust.res<-hclust(dist.mat)
plot(clust.res)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top