pca_sample {PopComm}R Documentation

Generate PCA of Ligand-Receptor Interaction Scores

Description

This function performs principal component analysis (PCA) on ligand-receptor (LR) interaction scores across samples, and generates a scatter plot of the first two principal components. Optionally, sample metadata can be used to color the points.

Usage

pca_sample(
  lr_scores,
  metadata,
  selected_sender = NULL,
  selected_receiver = NULL,
  color_by = NULL,
  n_components = 2
)

Arguments

lr_scores

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

metadata

Data frame containing sample metadata (data frame).

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).

color_by

metadata column name to color points in PCA plot (character).

n_components

Number of principal components to extract (numeric, default: 2).

Value

A list with two elements: the first is a ggplot2 PCA scatter plot and the second is the PCA results data frame.

Examples

# PCA of LR Interaction Scores
data(lr_scores_eg)
data(metadata_eg)
res <- pca_sample(lr_scores_eg, metadata_eg, selected_sender = "Cardiac",
  selected_receiver = "Perivascular", color_by = "IFN_type")

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

[Package PopComm version 0.1.0.1 Index]