cluster_correlation: Find groups (clusters) of cells (single cell transcriptomes)...

View source: R/cluster_correlation.R

cluster_correlationR Documentation

Find groups (clusters) of cells (single cell transcriptomes) with highest gene expression correlation in two Seurat objects

Description

Sometimes one wants to avoid combining data sets into a single seurat object as this often requires to employ an integration procedure or a batch correction and respective uncertainties. At some point then one may be interested in which clusters correspond to each other in separate seurat object. This function quickly returns a graphic and data frames to judge best matching clusters. Seurat::AverageExpression is used to derive average gene expressions per cluster. Selected gene (features) are then used for correlation calculation.

Usage

cluster_correlation(
  SO,
  meta.cols,
  features = c("all", "pca"),
  assay = c("RNA", "SCT"),
  levels = NULL,
  complement.levels = F,
  split.by = NULL,
  avg.expr,
  method = c("pearson", "kendall", "spearman"),
  corr.in.percent = FALSE,
  min.cells = 20,
  round.corr = 2,
  lower.triangle.only = T,
  aspect.ratio = 1
)

Arguments

SO

named list of exactly 2 Seurat objects; you may also pass the same object twice to have an intra-comparison

meta.cols

character vector of length 2, indicating the column names of meta.data in SO[1] and SO[2] to use for comparison, e.g. the clustering columns in both SOs

features

features to use for correlation calculation; will always be reduced to intersecting features between SOs; if all, all intersecting features in assay are considered; if pca, intersecting rownames of feature.loadings in pca-reduction; or a vector of features

assay

which assay to obtain expression values from

levels

list of length 2 indicating the factor levels in meta.cols to include; this also defines axis orders; can be incomplete e.g. if order matters only for some levels, if complement.levels = T the missing levels are added randomly

complement.levels

add all missing levels in random order

split.by

split correlation calculation by a common column with common levels in SOs; individual correlation coefficients are averaged after fishers z-transformation (atanh) and then transformed back (tanh)

avg.expr

avg.expr from a previous return list of cluster_correlation_matrix; e.g. provide that to only change axis orders or similar but avoid repeated calculation

method

which correlation metric to calculate, passed to stats::cor

corr.in.percent

display correlation in percent (TRUE, T) or as a fraction (FALSE, F)

min.cells

minimum number of cells per group in meta.cols (and if provided split.by) to calculate and return a correlation coefficient

round.corr

decimal places to round correlation values to

lower.triangle.only

return the lower triangle of correlation matrix which will contain unique values only

aspect.ratio

aspect ratio of matrix plot

Value

list with (i) ggplot object of correlation matrix plot, (ii) the data frame to that plot and (iii) calculated average expressions from Seurat::AverageExpression


Close-your-eyes/scexpr documentation built on April 21, 2023, 10:27 a.m.