Skip to contents

Computes a recommendation for the number of subclones K using the average silhouette on an MDS embedding derived from CNV data. Optionally fuses spatial distances from obj@location with CNV distances (weight alpha) before embedding. Saves two figures and prints the silhouette-vs-K plot to the device. Pick K that obtaions the largest average silhoutte score.

Usage

suggest_k(
  obj,
  ref,
  ref.id = NULL,
  tumor,
  tumor.id = NULL,
  k_range = 2:8,
  n_sub = 5000,
  alpha = 0.7,
  seed = 123,
  out_dir = "figs_k"
)

Arguments

obj

a highSpaClone object

ref

Character vector of reference (normal) cell labels.

ref.id

Character vector of reference cell IDs.

tumor

Character vector of tumor cell labels.

tumor.id

Character vector of tumor cell IDs. If both tumor label/IDs are absent, all non-reference cells are used.

k_range

Integer vector of K values to evaluate.

n_sub

Integer. Max number of cells to subsample for evaluation (default: 5000).

alpha

NULL for CNV-only. If a number in [0,1], fuse CNV and spatial distances: \(d = alpha * d_{CNV} + (1-alpha) * d_{spatial}\) (default: 0.7).

seed

Integer seed for reproducibility.

out_dir

Output directory for figures.

Details

Two figures are saved to out_dir:

  • silhouette_vs_k.png: Average silhouette vs K.

  • silhouette_bars_k_recommended.png: Silhouette bars at the recommended K.