Learn R Programming

PopComm (version 1.0.0)

heatmap_sample: Generate Heatmap of Ligand-Receptor Interaction Scores

Description

This function generates a heatmap to visualize the ligand-receptor (LR) interaction scores across samples. Rows represent LR pairs and columns represent samples. Optionally, sample metadata can be used to annotate the columns.

Usage

heatmap_sample(
  lr_scores,
  metadata,
  score = c("normalized", "raw"),
  selected_sender = NULL,
  selected_receiver = NULL,
  selected_metadata = NULL,
  treeheight_row = 50,
  treeheight_col = 50,
  show_LR = FALSE,
  show_sample = FALSE,
  basic_title = NULL
)

Value

A pheatmap object.

Arguments

lr_scores

Data frame containing LR interaction scores per sample (data frame).

metadata

Data frame containing sample metadata (data frame).

score

Character string indicating which score to use: "normalized" (default) or "raw" .

selected_sender

Specific sender cell type to filter, default is None (use all) (character).

selected_receiver

Specific receiver cell type to filter, default is None (use all) (character).

selected_metadata

List of column names in metadata to annotate samples (default: None, use all)(character vector).

treeheight_row

The height of a tree for rows (numeric, default: 50).

treeheight_col

The height of a tree for columns (numeric, default: 50).

show_LR

Whether to display ligand-receptor names on rows (logical, default: FALSE).

show_sample

Whether to display sample names on columns (logical, default: FALSE).

basic_title

Custom heatmap title (optional).

Examples

Run this code
# Heatmap of LR Interaction Scores
data(lr_scores_eg)
data(metadata_eg)

p <- heatmap_sample(
  lr_scores = lr_scores_eg,
  metadata = metadata_eg,
  score = "normalized",
  selected_sender = "Endothelial",
  selected_receiver = "Perivascular",
  selected_metadata = c("Sex", "Age_group", "IFN_type")
  )

print(p)

Run the code above in your browser using DataLab