Skip to contents

This function performs phenotype-stratified hierarchical clustering of cell type proportions using Jensen-Shannon Divergence (JSD) as the distance metric. It then visualizes average cell type distributions across identified clusters/domains.

Usage

PhenotypeHclust(
  PhenotypeMap_result,
  phenotype = c("phenotype-", "phenotype+"),
  coordinate,
  k = 2,
  size = 2
)

Arguments

PhenotypeMap_result

A list with at least:

  • cell_type_distribution: Matrix or data.frame of cell type proportions (rows = spots).

  • pred_score: Data.frame with phenotype labels. Row names must match the distribution matrix.

phenotype

Character string indicating phenotype label to subset. Default is "phenotype-".

coordinate

A data.frame of spatial coordinates for each spot/cell. Used for spatial plotting.

k

Integer; number of clusters/domains to define. Default is 2.

size

Numeric; point size used in SpaDo::DomainPlot. Default is 2.

Value

A ggplot2 object displaying mean cell type proportions per identified domain.

Details

The function filters spots/cells by a specified phenotype label, computes pairwise JSD distances, applies hierarchical clustering, and visualizes the mean cell type profiles of each domain. Requires the SpaDo package for clustering and plotting domains. devtools::install_github("bm2-lab/SpaDo").

Author

Bin Duan

Examples

if (FALSE) { # \dontrun{
res <- list(
  cell_type_distribution = cell_type_df,
  pred_score = phenotype_df
)
PhenotypeHclust(res, phenotype = "phenotype+", coordinate = coord_df, k = 3)
} # }