rectanglepy.rectangle

rectanglepy.rectangle(adata, bulks, cell_type_col='cell_type', *, layer=None, raw=False, correct_mrna_bias=True, optimize_cutoffs=True, p=0.015, lfc=1.5, n_cpus=None, gene_expression_threshold=0.5)

All in one deconvolution method. Creates signatures and deconvolutes the bulk data. Has options for subsampling and consensus runs.

Parameters:
  • adata (AnnData) – The single-cell count data as a DataFrame. DataFrame must have the genes as index and cell identifier as columns. Each entry should be in raw counts.

  • bulks (DataFrame) – The bulk data as a DataFrame. DataFrame must have the bulk identifier as index and the genes as columns. Each entry should be in transcripts per million (TPM).

  • cell_type_col (str (default: 'cell_type')) – The annotations corresponding to the single-cell count data. Series data should have the cell identifier as index and the annotations as values.

  • layer (Optional[str] (default: None)) – The Anndata layer to use for the single-cell data.

  • raw (bool (default: False)) – A flag indicating whether to use the raw Anndata data.

  • optimize_cutoffs (default: True) – Indicates whether to optimize the p-value and log fold change cutoffs using gridsearch.

  • p (default: 0.015) – The p-value threshold for the DE analysis (only used if optimize_cutoffs is False).

  • lfc (default: 1.5) – The log fold change threshold for the DE analysis (only used if optimize_cutoffs is False).

  • n_cpus (Optional[int] (default: None)) – The number of cpus to use for the DE analysis. None value takes all cpus available.

  • correct_mrna_bias (bool) – A flag indicating whether to correct for mRNA bias. Defaults to True.

  • gene_expression_threshold (float) – The threshold for gene expression. Genes with expression below this threshold are removed from the analysis.

Return type:

tuple[DataFrame, RectangleSignatureResult]

Returns:

DataFrame : The estimated cell fractions. RectangleSignatureResult : The result of the rectangle signature analysis.