Builds a hierarchical signature model from single-cell RNA-seq data using DESeq2-based marker gene selection and optional hierarchical clustering. The resulting model can be passed to deconvolute() to avoid rebuilding the signature for every bulk dataset.

build_model_rectanglepy(
  single_cell_object,
  cell_type_annotations,
  bulk_gene_expression = NULL,
  model_path = NULL,
  optimize_cutoffs = TRUE,
  p = 0.015,
  lfc = 1.5,
  n_cpus = NULL,
  gene_expression_threshold = 0.5,
  verbose = FALSE,
  ...
)

Arguments

single_cell_object

A matrix with the single-cell data. Rows are genes, columns are cells. Row and column names must be set. Raw counts expected.

cell_type_annotations

A vector of cell type labels, one per column of single_cell_object.

bulk_gene_expression

Optional. A matrix of bulk data (rows = genes, columns = samples). When provided, the signature is restricted to genes present in the bulk data.

model_path

Optional path where the signature pickle file should be saved. If NULL (default), a temporary file is used. Providing a permanent path allows the signature to be reused across R sessions by passing the same path to deconvolute() or extract_signature_rectanglepy().

optimize_cutoffs

Whether to optimize p-value and log-fold-change cutoffs via grid search. Recommended but slow. Default: TRUE.

p

P-value cutoff for DE analysis. Only used if optimize_cutoffs = FALSE.

lfc

Log fold-change cutoff for DE analysis. Only used if optimize_cutoffs = FALSE.

n_cpus

Number of CPUs for DE analysis. NULL uses all available.

gene_expression_threshold

Minimum fraction of cells that must express a gene for it to be included in DE analysis. Default: 0.5.

verbose

Whether to print progress to the console. Default: FALSE.

...

Additional arguments, silently ignored. Allows extra parameters to pass through the deconvolute() dispatcher without error.

Value

Path to a pickle file containing the RectangleSignatureResult. Pass this path as the signature argument to deconvolute() or extract_signature_rectanglepy().