knitr::opts_chunk$set(
  collapse = TRUE,
  eval=TRUE,
  comment = "#>"
)

This is the first version of the graphcluster package. This vignette provides a guideline for using this package.

Setting up

library(graphcluster)
library(stringr)
library(igraph)

Loading data and preparing annotations. Use Iris data as the test dataset.

graphcluster requires inputting the dataset in the form of a dataframe or a matrix

data(iris)
data=iris[,-5]
ann=iris[,5]
names(ann)<-rownames(data)
f=factor(ann)
ann=as.numeric(f)

Perform clustering parallely

Call the parallel_cluster function with suitable parameters. The following is an example:

system.time(elist_p<-parallel_cluster(5,50,4,data,0.65))

Final Step before merging subgraphs

After all iterations are over, make graphs for the points that were not sampled even once. A sample code is as follows:

l=length(elist_p)
l
sub=as.character("",l*2)
for(i in 1:l)
{
  sub[i]=word(elist_p[i])
  sub[i+l]=word(elist_p[i],2)
}
usub=unique(sub)
if(length(usub)!=nrow(data))
{
  reducedbench_data <- data[!(rownames(data) %in% usub),]

  system.time(elist_p1<-parallel_cluster(1,nrow(reducedbench_data),4,reducedbench_data,0.65))
  elist_p=append(elist_p,elist_p1)

}
elist_p2=append(elist_p,elist_p1)
system.time(K<-graphcommunity(elist_p, ann))

Plotting the final clustered dataset.

```r mygr=K$graph table(data.frame("PREDICT" = K$comm$membership,"TRUE" = V(mygr)$color))

V(mygr)$color = K$comm$membership

set.seed(555)

plot(K$comm,mygr,vertex.size=5, vertex.label=NA,edge.color=NA)



Riddhiz/graphcluster documentation built on March 21, 2020, 2:11 p.m.