R/layer_stat_cor_plot.R
layer_stat_cor_plot.Rd
This function makes a ComplexHeatmap from the correlation matrix
between a reference and query modeling statistics from layer_stat_cor()
.
For example, between the query statistics from a set of cell cluster/types
derived from scRNA-seq or snRNA-seq data (among other types) and the
reference layer statistics from the Human DLPFC Visium data (when using the
default arguments).
The output of layer_stat_cor()
.
A numeric(1)
specifying the highest correlation value for
the color scale (should be between 0 and 1).
A numeric(1)
specifying the lowest correlation value for
the color scale (should be between 0 and -1).
A character(3)
vector specifying the color scale for the
fill of the heatmap. The first value is used for color_min
, the second one
for zero, and the third for color_max
.
named character
vector of colors, Adds colors to query
row annotations.
named character
vector of colors, Adds colors to
reference column annotations.
annotation data.frame output of
annotate_registered_clusters()
, adds 'X' for good confidence annotations,
'*' for poor confidence.
Additional parameters passed to
ComplexHeatmap::Heatmap()
such as cluster_rows
and cluster_columns
.
(Heatmap-class) plot of t-stat correlations
Includes functionality to add color annotations,
(helpful to match to colors in Visium spot plots), and annotations from
annotate_registered_clusters()
.
Other Layer correlation functions:
annotate_registered_clusters()
,
layer_stat_cor()
## Obtain the necessary data
## reference human pilot modeling results
if (!exists("modeling_results")) {
modeling_results <- fetch_data(type = "modeling_results")
}
#> 2024-12-13 19:41:45.772414 loading file /github/home/.cache/R/BiocFileCache/5c656d46b9_Human_DLPFC_Visium_modeling_results.Rdata%3Fdl%3D1
## query spatialDLPFC modeling results
query_modeling_results <- fetch_data(
type = "spatialDLPFC_Visium_modeling_results"
)
#> 2024-12-13 19:41:46.922689 loading file /github/home/.cache/R/BiocFileCache/103d15db52ad_modeling_results_BayesSpace_k09.Rdata%3Fdl%3D1
## Compute the correlations
cor_stats_layer <- layer_stat_cor(
stats = query_modeling_results$enrichment,
modeling_results,
model_type = "enrichment"
)
## Visualize the correlation matrix
## Default plot with no annotations and defaults for ComplexHeatmap()
layer_stat_cor_plot(cor_stats_layer)
## add colors
## add libd_layer_colors to reference Human Pilot layers
layer_stat_cor_plot(cor_stats_layer, reference_colors = libd_layer_colors)
## obtain colors for the query clusters
cluster_colors <- get_colors(clusters = rownames(cor_stats_layer))
layer_stat_cor_plot(cor_stats_layer,
query_colors = cluster_colors,
reference_colors = libd_layer_colors
)
## Apply additional ComplexHeatmap param
layer_stat_cor_plot(cor_stats_layer,
cluster_rows = FALSE,
cluster_columns = FALSE
)
## Add annotation
annotation_df <- annotate_registered_clusters(
cor_stats_layer,
confidence_threshold = .55
)
layer_stat_cor_plot(cor_stats_layer, annotation = annotation_df)
## All together
layer_stat_cor_plot(
cor_stats_layer,
query_colors = cluster_colors,
reference_colors = libd_layer_colors,
annotation = annotation_df,
cluster_rows = FALSE,
cluster_columns = FALSE
)