21  Correlation matrix heatmaps

A common analysis to perform with your single cell data is to assess how much different subsets of your data are correlated between them. For this, correlation matrices are used, typically displayed as heatmaps. This is implemented in SCpubr::do_CorrelationPlot(). Right now, it only works for a single use case: computing the correlation matrix of the highly variable genes between the desired groups. Further use cases will be implemented in the future.

21.1 Using Highly Variable Genes

# Default values.
p <- SCpubr::do_CorrelationPlot(sample = sample, 
                                cell_size = 10)
p

Basic output.

By default, it computes the correlation over the current identities in the object. This can be changed by providing another metadata variable to group.by.

# Custom grouping.
sample$custom_group <- ifelse(sample$seurat_clusters %in% c("1", "3", "5", "7", "9"), "Group A", "Group B")
p <- SCpubr::do_CorrelationPlot(sample = sample, 
                                group.by = "custom_group", 
                                cell_size = 10)
p

Apply a custom grouping.

Axes labels can also be rotated.


# Rotated axis labels.
p <- SCpubr::do_CorrelationPlot(sample = sample,
                                column_names_rot = 90, 
                                cell_size = 10)
p

Rotate axis labels.

21.2 Changing the cell size in the heatmap

Same as with Enrichment Heatmaps, the aspect ratio of the tiles in the heatmap is fixed so that cells are squares, and not rectangles. This can be changed modifying cell_size parameter. This is set to 5 by default.

# Increase cell size.
p <- SCpubr::do_CorrelationPlot(sample = sample,
                                column_names_rot = 0,
                                cell_size = 12)
p

Modify the cell size of the heatmap.