Civilized_Spectral_Clustering: Runs the spectral clustering algorithm on the sample points.

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/Civilized_Spectral_Clustering.R

Description

The representatives of communities are considered as the vertices of a graph. Assuming the edges have been weighted according to the equivalent conductance between them, this function runs the classic spectral clustering on the graph.

Usage

1
2
3
4
5
  Civilized_Spectral_Clustering(full, maximum.number.of.clusters, society, conductance,
				iterations=200, number.of.clusters="NA", 
				k.for_kmeans="NA", minimum.eigenvalue="NA", minimum.degree=0, 
				eigenvalues.num =NA, talk=TRUE,stabilizer=1000, one.line=FALSE,
				replace.inf.with.extremum=TRUE)

Arguments

full

The matrix containing the coordinates of all data points.

maximum.number.of.clusters

An integer used to automatically estimate the number of clusters by fitting 2 regression lines on the eigen values curve.

number.of.clusters

The default value is "NA" which leads to computating the number of spectral clusters automatically, otherwise this number will determine the number of spectral clusters.

k.for_kmeans

The number of clusters for running kmeans algorithm in spectral clustering. The default value of "NA" leads to automatic estimation based on eigen values curve.

minimum.eigenvalue

If not "NA", the number of spectral clusters will be determined such that corresponding eigenvalues are larger than this threshold.

minimum.degree

If a node in the graph has total edge sum less than this threshold, it will be considered as an isolated community.

society

The list of communities.

conductance

A matrix in which each entry is the conductance between two communities.

iterations

Number of iterations for the k-means algorithm used by the spectral procedure. 200 is an appropriate value.

talk

A boolean flag with default value TRUE. Setting it to FALSE will keep running the procedure quite with no messages.

eigenvalues.num

An integer with default value NA which prevents ploting the curve of eigenvalues. Otherwise, they will be ploted upto this number.

stabilizer

The larger this integer is, the final results will be more stable because the underlying kmeans will restart many more times.

one.line

If TRUE, the number of spectral clusters are estimated by fitting 1 line to the eigen values curve. Otherwise 2 lines are fitted.

replace.inf.with.extremum

If TRUE, the Inf and -Inf values will be replaced by maximum and minimum of data in each direction.

Value

A ClusteringResult class object with the following slots,

labels.for_num.of.clusters

The k'th element of this list is a vector containing the labels as result of clustering to k parts.

number.of.clusters

A list containing the desired cluster numbers.

eigen.space

The eigen vectors and eigen values of the normalized adjacency matrix computed by the eigen() function for spectral clustering.

Author(s)

Habil Zare, Nima Aghaeepour and Parisa Shooshtari

References

Zare, H. and Shooshtari, P. and Gupta, A. and Brinkman R.B: Data Reduction for Spectral Clustering to Analyse High Throughput Flow Cytometry Data. BMC Bioinformatics, 2010, 11:403.

See Also

SamSPECTRAL,check.SamSPECTRAL.input

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
	 ## Not run: 
	    library(SamSPECTRAL)

	   # Reading data file which has been transformed using log transform
	    data(small_data)
		full <- small
	
		# Parameters:
		m <- 3000; ns <- 200; sl <- 3; cwt <-1; precision <- 6; mnc <-30 
	
    	# Sample the data and build the communities
    	society <- Building_Communities(full=full,m=m, space.length=sl, community.weakness.threshold=cwt)
    	
	
    	# Compute conductance between communities
    	conductance <- Conductance_Calculation(full=full, normal.sigma=ns, space.length=sl, society=society, precision=precision)
    	
    	# Use spectral clustering to cluster the data
		# First example:
	    clust_result <- Civilized_Spectral_Clustering(full=full, maximum.number.of.clusters=mnc, society=society, conductance=conductance)    
    	number.of.clusters <- clust_result@number.of.clusters
    	labels.for_num.of.clusters <- clust_result@labels.for_num.of.clusters
		L <- labels.for_num.of.clusters[[number.of.clusters]]
    	# plot(full, pch='.', col= L)
		

		# Second example:
		number.of.clusters <- c(35,20)	
			# This is faster than runnig Civilized_Spectral_Clustering() twice because the eigen space is not needed to be computed again.     
		clust_result.not.automatic <- 
			Civilized_Spectral_Clustering(full=full, society=society, conductance=conductance, number.of.clusters =number.of.clusters, eigenvalues.num=60)    
	    labels.for_num.of.clusters <- clust_result.not.automatic@labels.for_num.of.clusters
		L35 <- labels.for_num.of.clusters[[35]]
		L20 <- labels.for_num.of.clusters[[20]]
	    # plot(full, pch='.', col= L35)
	
## End(Not run)

SamSPECTRAL documentation built on Nov. 8, 2020, 5:08 p.m.