Skip to contents

Compute triangle features from kernel matrices

Usage

computeTriangles(
  kernel,
  cell_names,
  patient_names,
  Dcell = NULL,
  unifKernel = NULL,
  norm = FALSE,
  bundle = TRUE,
  zero_threshold = 1
)

Arguments

kernel

Kernel array from compute_kernel().

cell_names

Character vector of cell-type names.

patient_names

Character vector of patient names.

Dcell

Patient-by-cell-type abundance matrix, used to weight raw (unnormalized) scores. Ignored when unifKernel/norm is used.

unifKernel

Optional normalized baseline kernel.

norm

Logical; if TRUE, divide by the baseline triangle scores.

bundle

Logical; if TRUE, aggregate all directions into a single "Tr" triangle score per triple. If FALSE, two scores are returned per triple: "TT" (trust/transitive triangle, i->j->k and i->k) and, for i<=j<=k only, "CT" (cycle triangle, i->j->k->i).

zero_threshold

Drop a triangle once its fraction of zero-valued patients reaches this threshold. Default 1 only drops triangles that are zero for every patient (the original behavior); lower it (e.g. 0.9) to also drop merely zero-inflated triangles.

Value

A patient-by-feature data frame of triangle scores. Triples with no possible ligand-receptor pathway in any patient (zero for every patient) are dropped rather than returned as all-zero columns.