Learn R Programming

PopComm (version 1.0.0)

boxplot_lr_group_comparison: Boxplot Comparison of Ligand-Receptor Interaction Scores Across Groups

Description

Generates a boxplot comparing ligand-receptor (LR) interaction scores across sample groups with optional significance testing (t-test or Wilcoxon).

Usage

boxplot_lr_group_comparison(
  lr_scores,
  metadata,
  ligand,
  receptor,
  sender,
  receiver,
  group_by,
  score = c("normalized", "raw"),
  test = TRUE,
  paired = FALSE,
  test_method = c("wilcox.test", "t.test"),
  colors = c("#5fa9d1", "#154778"),
  title = NULL
)

Value

A list containing:

  • plot - ggplot object of the boxplot

  • df - data frame used for plotting

Arguments

lr_scores

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

metadata

Data frame containing sample metadata (data frame).

ligand

Ligand gene name to filter (character).

receptor

Receptor gene name to filter (character).

sender

Sender cell type to filter (character).

receiver

Receiver cell type to filter (character).

group_by

Column name in metadata to group samples (character).

score

Use 'normalized' or 'raw' score (default: "normalized") (character).

test

Whether to add a statistical test annotation (logical, default: TRUE).

paired

Whether to treat the comparison as paired (logical, default: FALSE).

test_method

Statistical test to use: "t.test" or "wilcox.test" (default = "wilcox.test") (character).

colors

Vector of colors for groups (default: c("#5fa9d1", "#154778")).

title

Custom plot title (optional).

Examples

Run this code
# Boxplot of LR Score by group
data(lr_scores_eg)
data(metadata_eg)

res <- boxplot_lr_group_comparison(
  lr_scores = lr_scores_eg,
  metadata = metadata_eg,
  ligand = "PSAP",
  receptor = "LRP1",
  sender = "Perivascular",
  receiver = "Fibroblast",
  group_by = "IFN_type",
  score = "normalized"
  )

print(res$plot)
head(res$df)

Run the code above in your browser using DataLab