Estimates cell-type fractions from bulk RNA-seq data using the Rectangle method. Accepts either a pre-built signature (from build_model_rectanglepy()) or single-cell data for a one-step run.

deconvolute_rectanglepy(
  bulk_gene_expression,
  signature = NULL,
  single_cell_object = NULL,
  cell_type_annotations = NULL,
  correct_mrna_bias = TRUE,
  optimize_cutoffs = TRUE,
  p = 0.015,
  lfc = 1.5,
  n_cpus = NULL,
  gene_expression_threshold = 0.5,
  verbose = FALSE
)

Arguments

bulk_gene_expression

A matrix of bulk data. Rows are genes, columns are samples. Row and column names must be set. TPM normalized.

signature

Path to a .pkl file created by build_model_rectanglepy(). When NULL, single_cell_object and cell_type_annotations are required and the signature is built internally.

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. Only used when signature is NULL.

cell_type_annotations

A vector of cell type labels. Only used when signature is NULL.

correct_mrna_bias

Whether to correct for mRNA content bias. Default: TRUE.

optimize_cutoffs

Whether to optimize DE cutoffs during signature building. Only used when signature is NULL. Default: TRUE.

p

P-value cutoff for DE analysis. Only used when signature is NULL and optimize_cutoffs = FALSE.

lfc

Log fold-change cutoff. Only used when signature is NULL and optimize_cutoffs = FALSE.

n_cpus

Number of CPUs. NULL uses all available.

gene_expression_threshold

Gene expression threshold for DE analysis. Only used when signature is NULL. Default: 0.5.

verbose

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

Value

A matrix with rows = samples and columns = cell types (including an "Unknown" column representing uncharacterized cellular content).