calSI: Calculate the Silhouette Coefficient of the result of a...

Description Usage Arguments Value Examples

View source: R/calSI.R

Description

Calculate the silhouette coefficient of each sample, and take the average value.

Usage

1
calSI(x, a, type = 0)

Arguments

x

A data matrix with columns as features (e.g. genes) and rows as samples (e.g, patients).

a

A vector that contains the cluster label of each sample.

type

Choose from 0, 1 or 2, which means the data matrix x is the raw data matrix, similarity matrix, and distance matrix respectively.

Value

A real number that means the silhouette coefficient of the cluster.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#sample one
s1=c(3,1,6,4,8)
#sample two
s2=c(6,7,1,3,4)
#sample three
s3=c(2,8,7,2,3)
label=c(1,1,3)

x=as.matrix(rbind(s1,s2,s3))

#the first parameter is row data
calSI(x,label,0)

#the first parameter is similarity matrix
calSI(1/dist(x),label,1)

#the first parameter is distance matrix
calSI(dist(x),label,2)

GaoLabXDU/CEPICS documentation built on June 9, 2020, 2:31 a.m.