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 object

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

Improved argument names and documentaion, but same functionalty from get_mean_ratio2().

Value

A 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 cols spcified by the user to add gene infomation

Examples

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

#   gene            cellType.target mean.target cellType.2nd mean.2nd MeanRatio MeanRatio.rank MeanRatio.anno        
#  <chr>           <fct>                 <dbl> <fct>           <dbl>     <dbl>          <int> <chr>                 
# 1 ENSG00000230615 Inhib.2               1.00  Excit.2         0.239      4.20              1 Inhib.2/Excit.2: 4.197
# 2 ENSG00000162512 Inhib.2               1.71  Astro           0.512      3.35              2 Inhib.2/Astro: 3.346  
# 3 ENSG00000137965 Inhib.2               0.950 Astro           0.413      2.30              3 Inhib.2/Astro: 2.301  
# 4 ENSG00000060718 Inhib.2               3.32  Astro           1.47       2.26              4 Inhib.2/Astro: 2.264  
# 5 ENSG00000162631 Inhib.2               3.55  Astro           1.62       2.19              5 Inhib.2/Astro: 2.19  

# Option to specify gene_name as the "Symbol" column from rowData
# this will be added to the marker stats output
SummarizedExperiment::rowData(sce_ab)
get_mean_ratio(sce_ab, cellType_col = "cellType", gene_name = "Symbol", gene_ensembl = "gene_id")
# A tibble: 1,778 × 10
# gene            cellType.target mean.target cellType.2nd mean.2nd MeanRatio MeanRatio.rank MeanRatio.anno   gene_ensembl gene_name
# <chr>           <fct>                 <dbl> <fct>           <dbl>     <dbl>          <int> <chr>            <chr>        <chr>    
# 1 ENSG00000230615 Inhib.2               1.00  Excit.2         0.239      4.20              1 Inhib.2/Excit.2… ENSG0000023… AL139220…
# 2 ENSG00000162512 Inhib.2               1.71  Astro           0.512      3.35              2 Inhib.2/Astro: … ENSG0000016… SDC3     
# 3 ENSG00000137965 Inhib.2               0.950 Astro           0.413      2.30              3 Inhib.2/Astro: … ENSG0000013… IFI44    


lahuuki/DeconvoBuddies documentation built on May 5, 2024, 9:35 a.m.