I have been trying to compute Jaccard similarity index for all possible duo combinations for 7 communities and to create a matrix, or preferably Cluster plotting with the similarity index.

There are 21 combinations like Community1 vs Community2, Community1 vs Control and Control vs Community2 etc...

Data is like below:

Communities     AllM    AllP AnBr ArHe  ArFi    ArXa    AsGo
Community1      1   1   1   0   0   0   1
Community2      1   0   1   0   0   0   1
Community3      1   1   1   0   0   1   1
Community4      1   1   1   0   0   0   0
Community5      1   1   1   0   0   1   0
Community6      1   1   1   0   0   0   0
Control         1   0   1   0   0   0   1

Each rows represent different communities and the columns show species in the communities. 1 is presence of the species in the community, 0 is absence of the species in the community

My main goal is to create a Cluster plot using similarity index and I want to show which community is most similar with the control community in terms of species composition and which one is very different etc. How can I compute Jaccard similarity index for all possible duo combinations and create a matrix? or it would be great to create cluster plot to show similarity using this data in R, which is my preferred way of doing that. I am not sure the data is formatted correctly for the analysis.

or you can recommend best software and tools to do that easily.



closed as off-topic by shadowtalker, kjetil b halvorsen, Michael Chernick, Peter Flom - Reinstate Monica Dec 11 '17 at 11:20

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – Michael Chernick, Peter Flom - Reinstate Monica
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ All possible combinations by what number of communities? Will you want, for example, combination KHRO1_A_110m KHRO1_B_10m KHRO1_B_110m? How are you defining Jaccard similarity between the three? $\endgroup$ – ttnphns Dec 10 '17 at 18:02
  • $\begingroup$ Of course there is no such way to calculate similarity among 3 or more groups. I meant, similarity index calculation between two communities and for all possible combinations of duo. There are 21 combinations, and I am looking to calculate them all in one go and create a cluster plot. Because manually it requires to repeat same process for 21 times to calculate. $\endgroup$ – Vandka Dec 11 '17 at 2:04
  • $\begingroup$ stats.stackexchange.com/q/49453/3277 $\endgroup$ – ttnphns Dec 11 '17 at 5:49

I just found a very simple way to do that, after searching for a while. It calculates similarities for all duo combinations and creates matrix and also a hierarchical cluster plot with "ade" package in R.

m <- read.table("./similarity/Data_pres&abs.tab", header=TRUE)
m1 <- read.table("./Similarity/Data_pres&abs_no_head.tab", header=F)
d <- dist.binary(m1, method = 1, diag = FALSE, upper = FALSE) #method 1 is Jaccard index (1901) S3 coefficient of Gower & Legendre
hc <- hclust(d)               # apply hierarchical clustering 
plot(hc, labels=m$ID)    # plot the dendrogram

Not the answer you're looking for? Browse other questions tagged or ask your own question.