get_mean_ratio: Get Mean Ratio for Each Gene x Cell Type

View source: R/get_mean_ratio.R

get_mean_ratioR Documentation

Get Mean Ratio for Each Gene x Cell Type

Description

Calculate the Mean Ratio value and rank for each gene for each cell type in the sce object, to identify effective marker genes for deconvolution.

Usage

get_mean_ratio(
  sce,
  cellType_col,
  assay_name = "logcounts",
  gene_ensembl = NULL,
  gene_name = NULL
)

Arguments

sce

SummarizedExperiment-class (or any derivative class) object containing single cell/nucleus gene expression data.

cellType_col

A character(1) name of the column in the colData() of sce that denotes the cell type or group of interest.

assay_name

A character(1) specifying the name of the assay() in the sce object to use to rank expression values. Defaults to logcounts since it typically contains the normalized expression values.

gene_ensembl

A character(1) specifying the rowData(sce_pseudo) column with the ENSEMBL gene IDs. This will be used by layer_stat_cor().

gene_name

A character(1) specifying the rowData(sce_pseudo) column with the gene names (symbols).

Details

Note if a cell type has < 10 cells the MeanRatio results may be unstable. See rational in OSCA: https://bioconductor.org/books/3.19/OSCA.multisample/multi-sample-comparisons.html#performing-the-de-analysis.

Value

A tibble::tibble() with the MeanRatio values for each gene x cell type.

  • gene is the name of the gene (from rownames(sce)).

  • cellType.target is the cell type we're finding marker genes for.

  • mean.target is the mean expression of gene for cellType.target.

  • cellType.2nd is the second highest non-target cell type.

  • mean.2nd is the mean expression of gene for cellType.2nd.

  • MeanRatio is the ratio of mean.target/mean.2nd.

  • MeanRatio.rank is the rank of MeanRatio for the cell type.

  • MeanRatio.anno is an annotation of the MeanRatio calculation helpful for plotting.

  • gene_ensembl & gene_name optional columns from rowData(sce) specified by the user to add gene information.

Examples

## load example SingleCellExperiment
if (!exists("sce_DLPFC_example")) sce_DLPFC_example <- fetch_deconvo_data("sce_DLPFC_example")
## Explore properties of the sce object
sce_DLPFC_example

## this data contains logcounts of gene expression
SummarizedExperiment::assays(sce_DLPFC_example)$logcounts[1:5, 1:5]

## nuclei are classified in to cell types
table(sce_DLPFC_example$cellType_broad_hc)

## Get the mean ratio for each gene for each cell type defined in
## `cellType_broad_hc`
get_mean_ratio(sce_DLPFC_example, cellType_col = "cellType_broad_hc")

# Option to specify gene_name as the "Symbol" column from rowData
# this will be added to the marker stats output
SummarizedExperiment::rowData(sce_DLPFC_example)

## specify rowData col names for gene_name and gene_ensembl
get_mean_ratio(sce_DLPFC_example,
    cellType_col = "cellType_broad_hc",
    gene_name = "gene_name",
    gene_ensembl = "gene_id"
)


LieberInstitute/DeconvoBuddies documentation built on Nov. 1, 2024, 11:58 a.m.