Learn R Programming

PopComm (version 1.0.0)

score_lr_all: Analyze Ligand-Receptor Projection Scores (Across All Cell Types)

Description

This function calculates the ligand-receptor (LR) projection scores between all combinations of 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_all(
  rna,
  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.

filtered_lr

A data frame of 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 between all cell types
  result01a <- filter_lr_all(
    rna = matrix_object,
    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 between all cell types
  result02a <- score_lr_all(
    rna = matrix_object,
    filtered_lr = result01a,
    sample_col = 2,
    cell_type_col = 1,
    id_sep = "--",
    num_cores = 1,
    verbose = TRUE
    )

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

Run the code above in your browser using DataLab