We infer the number of patterns based on two metrics that have been implemented in the NMF R package, including Cophenetic and Silhouette. Both metrics measure the stability for a particular number of patterns based on a hierarchical clustering of the consensus matrix. For a range of the number of patterns, a suitable number of patterns is the one at which Cophenetic and Silhouette values begin to drop suddenly.
selectK(
object,
slot.name = "netP",
pattern = c("outgoing", "incoming"),
title.name = NULL,
do.facet = TRUE,
k.range = seq(2, 10),
nrun = 30,
seed.use = 10
)
CellChat object
the slot name of object that is used to compute centrality measures of signaling networks
"outgoing" or "incoming"
title of plot
whether use facet plot showing the two measures
a range of the number of patterns
number of runs when performing NMF
seed when performing NMF
a ggplot object