Learn R Programming

PopComm (version 1.0.0)

score_lr_single: Analyze Ligand-Receptor Projection Scores (Specified Sender and Receiver)

Description

This function calculates the projection scores for ligand-receptor (LR) pairs between specified sender and receiver cell types, and it supports both Seurat objects and average expression matrices (matrix of gene expression data with cell types and samples as column names). The projection score is computed based on linear regression models, measuring the normalized distance of each sample's LR expression from the origin of the regression line.

Usage

score_lr_single(
  rna,
  sender,
  receiver,
  filtered_lr,
  sample_col,
  cell_type_col,
  id_sep,
  min_cells = 50,
  num_cores = 10,
  verbose = TRUE
)

Value

A data frame with projection scores per sample and LR pair. Columns:

All input from filtered_lr

Original columns provided by the user in filtered_lr.

sample

Sample identifier.

score

Projection score (raw co-expression intensity).

normalized_score

Normalized score scaled between 0-1.

Rows are ordered by filtered_lr columns and descending score.

Returns NULL if:

  • No cell types are found in the metadata.

  • One or both of the specified sender and receiver cell types are missing in the data.

  • Fewer than two valid samples remain after filtering based on minimum cell number per sample.

Arguments

rna

A Seurat object or a matrix containing single-cell RNA expression data.

sender

Cell type designated as the ligand sender (character).

receiver

Cell type designated as the receptor receiver (character).

filtered_lr

A data frame of filtered ligand-receptor pairs from prior analysis (e.g., output of filter_lr_single). Must contain an "lr" column with pair identifiers in "Ligand_Receptor" format.

sample_col

Metadata column name (character) for sample identifiers in Seurat mode; Matrix mode uses column index (numeric).

cell_type_col

Metadata column name (character) for cell type in Seurat mode; Matrix mode uses column index (numeric).

id_sep

Separator used in matrix column names to split sample and cell type (e.g., -- for "Cardiac--sample1"). Only used in Matrix mode.

min_cells

Minimum number of cells per sample for both sender and receiver (numeric, default 50). Only used in Seurat mode.

num_cores

Number of CPU cores for parallel processing (numeric, default 10). Automatically capped at (system cores - 1).

verbose

Logical indicating whether to print progress messages (logical, default: TRUE).

Examples

Run this code
# \donttest{
  data(matrix_object)
  data(lr_db)

  # Analyzing ligand-receptor interactions: Perivascular -> Endothelial
  result01s <- filter_lr_single(
    rna = matrix_object,
    sender = "Perivascular",
    receiver = "Endothelial",
    lr_database = lr_db,
    sample_col = 2,
    cell_type_col = 1,
    id_sep = "--",
    min_samples = 10,
    min_sample_ratio = 0.1,
    min_adjust_p = 0.05,
    num_cores = 1,
    verbose = TRUE
    )

  # Analyzing ligand-receptor projection scores: Perivascular -> Endothelial
  result02s <- score_lr_single(
    rna = matrix_object,
    sender = "Perivascular",
    receiver = "Endothelial",
    filtered_lr = result01s,
    sample_col = 2,
    cell_type_col = 1,
    id_sep = "--",
    num_cores = 1,
    verbose = TRUE
    )

  if (!is.null(result02s)) {
  print(head(result02s))
  }
# }

Run the code above in your browser using DataLab