R/calculateAveragePairwiseCorrelation.R
, R/plot.calculateAveragePairwiseCorrelationObject.R
calculateAveragePairwiseCorrelation.Rd
Computes the average pairwise correlations between specified cell types in single-cell gene expression data.
The S3 plot method takes the output of the `calculateAveragePairwiseCorrelation` function, which should be a matrix of pairwise correlations, and plots it as a heatmap.
A SingleCellExperiment
object containing numeric expression matrix for the query cells.
A SingleCellExperiment
object containing numeric expression matrix for the reference cells.
The column name in the colData
of query_data
that identifies the cell types.
The column name in the colData
of reference_data
that identifies the cell types.
A character vector specifying the cell types to include in the plot. If NULL, all cell types are included.
A numeric vector specifying which principal components to use in the analysis. Default is 1:10.
If set to NULL
then no dimensionality reduction is performed and the assay data is used directly for computations.
The correlation method to use for calculating pairwise correlations.
Name of the assay on which to perform computations. Default is "logcounts".
Output matrix from `calculateAveragePairwiseCorrelation` function.
Additional arguments to be passed to the plotting function.
A matrix containing the average pairwise correlation values. Rows and columns are labeled with the cell types. Each element in the matrix represents the average correlation between a pair of cell types.
The S3 plot method returns a ggplot
object representing the heatmap plot.
This function operates on SingleCellExperiment
objects,
ideal for single-cell analysis workflows. It calculates pairwise correlations between query and
reference cells using a specified correlation method, then averages these correlations for each
cell type pair. This function aids in assessing the similarity between cells in reference and query datasets,
providing insights into the reliability of cell type annotations in single-cell gene expression data.
The S3 plot method converts the correlation matrix into a dataframe, creates a heatmap using ggplot2, and customizes the appearance of the heatmap with updated colors and improved aesthetics.
plot.calculateAveragePairwiseCorrelationObject
calculateAveragePairwiseCorrelation
# Load data
data("reference_data")
data("query_data")
# Compute pairwise correlations
cor_matrix_avg <- calculateAveragePairwiseCorrelation(query_data = query_data,
reference_data = reference_data,
query_cell_type_col = "SingleR_annotation",
ref_cell_type_col = "expert_annotation",
cell_types = c("CD4", "CD8", "B_and_plasma"),
pc_subset = 1:10,
correlation_method = "spearman")
# Visualize correlation output
plot(cor_matrix_avg)