# Calculating Jaccard similarity in R: all duo combinations for multiple groups and creating a matrix or cluster plotting with the index [closed]

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.

Thanks

## 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.

• 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? – ttnphns Dec 10 '17 at 18:02
• 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. – Vandka Dec 11 '17 at 2:04
• stats.stackexchange.com/q/49453/3277 – ttnphns Dec 11 '17 at 5:49

install.packages("ade4")