# 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
if (FALSE) op <- par(mfrow = c(1,2))
consensusmap(res)
si <- silhouette(res, what = 'consensus')
plot(si)
if (FALSE) par(op)
# if the order is based on some custom numeric weights
if (FALSE) 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)
if (FALSE) par(op)
# do the reverse: order the heatmap as a set of silhouettes
si <- silhouette(res, what = 'features')
if (FALSE) op <- par(mfrow = c(1,2))
basismap(res, Rowv = si)
plot(si)
if (FALSE) par(op)
Run the code above in your browser using DataLab