File: silhouette.NMF.Rd

package info (click to toggle)
r-cran-nmf 0.23.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,344 kB
  • sloc: cpp: 680; ansic: 7; makefile: 2
file content (75 lines) | stat: -rw-r--r-- 2,282 bytes parent folder | download | duplicates (3)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
\name{silhouette.NMF}
\alias{silhouette.NMF}
\title{Silhouette of NMF Clustering}
\usage{
  \method{silhouette}{NMF} (x, what = NULL, order = NULL,
    ...)
}
\arguments{
  \item{x}{an NMF object, as returned by
  \code{\link{nmf}}.}

  \item{what}{defines the type of clustering the computed
  silhouettes are meant to assess: \code{'samples'} for the
  clustering of samples (i.e. the columns of the target
  matrix), \code{'features'} for the clustering of features
  (i.e. the rows of the target matrix), and \code{'chc'}
  for the consensus clustering of samples as defined by
  hierarchical clustering dendrogram, \code{'consensus'}
  for the consensus clustering of samples, with clustered
  ordered as in the \strong{default} hierarchical
  clustering used by \code{\link{consensusmap}} when
  plotting the heatmap of the consensus matrix (for
  multi-run NMF fits). That is \code{dist = 1 -
  consensus(x)}, average linkage and reordering based on
  row means.}

  \item{order}{integer indexing vector that can be used to
  force the silhouette order.}

  \item{...}{extra arguments not used.}
}
\description{
  Silhouette of NMF Clustering
}
\examples{
\dontshow{# roxygen generated flag
options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
}

x <- rmatrix(75, 15, dimnames = list(paste0('a', 1:75), letters[1:15]))
# NB: using low value for maxIter for the example purpose only
res <- nmf(x, 4, nrun = 3, maxIter = 20)

# sample clustering from best fit
plot(silhouette(res))

# average silhouette are computed in summary measures
summary(res)

# consensus silhouettes are ordered as on default consensusmap heatmap
\dontrun{ op <- par(mfrow = c(1,2)) }
consensusmap(res)
si <- silhouette(res, what = 'consensus')
plot(si)
\dontrun{ par(op) }

# if the order is based on some custom numeric weights
\dontrun{ op <- par(mfrow = c(1,2)) }
cm <- consensusmap(res, Rowv = runif(ncol(res)))
# NB: use reverse order because silhouettes are plotted top-down
si <- silhouette(res, what = 'consensus', order = rev(cm$rowInd))
plot(si)
\dontrun{ par(op) }

# do the reverse: order the heatmap as a set of silhouettes
si <- silhouette(res, what = 'features')
\dontrun{ op <- par(mfrow = c(1,2)) }
basismap(res, Rowv = si)
plot(si)
\dontrun{ par(op) }
}
\seealso{
  \code{\link[NMF]{predict}}
}