Skip to contents

Batch-wise gene statistics checking, average expression, and common-gene subsetting

Usage

check_gene_stats_in_multi_batch(srt, batch_col = "Batch", layer = "counts")

check_gene_avg_in_multi_batch(
  srt,
  genes,
  batch_col = "Batch",
  layer = "counts"
)

subset_common_gene_in_multi_batch(srt, common_genes, assay = "RNA")

Arguments

srt

A Seurat object.

batch_col

Metadata column indicating batch/sample. Default "Batch".

layer

Expression layer to inspect: "counts" for presence; "data" for averaged expression.

genes

Character vector of genes (only for check_gene_avg_in_multi_batch).

common_genes

Character vector of shared genes (only for subset_common_gene_in_multi_batch).

assay

Assay to subset. Default "RNA".

Value

  • check_gene_stats_in_multi_batch: list with a tibble stats and two character vectors common, drop.

  • check_gene_avg_in_multi_batch: tibble of mean expression (rows = genes, cols = batches).

  • subset_common_gene_in_multi_batch: a Seurat object containing only the genes shared by all batches.

Examples

if (FALSE) { # \dontrun{
## --------------------------------------------------------------------
## Tutorial: reconcile gene sets across multiple batches
## --------------------------------------------------------------------

# Assume `cd4` is a Seurat object with metadata column "Batch"

# Step 1 - inspect gene overlap/uniqueness across batches
res <- check_gene_stats_in_multi_batch(cd4)  # returns stats, common, drop
res$stats                                    # view the tibble summary

# Step 2 - examine average expression of genes missing from >=1 batch
avg <- check_gene_avg_in_multi_batch(cd4, res$drop); head(avg); colSums(avg[-1])

# Step 3 - subset the Seurat object to the intersection gene set
cd4 <- subset_common_gene_in_multi_batch(cd4, res$common)
} # }