R/annotate_registered_clusters.R
annotate_registered_clusters.Rd
Once you have computed the enrichment t-statistics for your sc/snRNA-seq data
using registration_wrapper()
and related functions, you can then use
layer_stat_cor()
and layer_stat_cor_plot()
to perform the spatial
registartion of your sc/snRNA-seq data. This function helps interpret that
matrix and assign layer labels to your clusters.
annotate_registered_clusters(
cor_stats_layer,
confidence_threshold = 0.25,
cutoff_merge_ratio = 0.25
)
The output of layer_stat_cor()
.
A numeric(1)
specifying the minimum correlation
that a given cluster must have against any of the layers (by default) to
be considered as having a 'good' assignment. Otherwise, the confidence will
be 'poor' and the final label will have an asterisk.
A numeric(1)
specifying the threshold for merging
or not layer assignments (by default). This is a proportion of the difference
between the current correlation and the next highest given the units of the
next highest correlation. Defaults to a difference of 25% of the next highest
correlation: if the observed difference is lower than this threshold, then we
keep merging. Higher values will lead to more layers (by default) being
merged.
A data.frame
with 3 columns. Your cluster
s, the layer_confidence
which depends on confidence_threshold
, and the layer_label
.
If you change the input modeling_results
to layer_stat_cor()
then the
interpretation of this function could change. For example, maybe you have
your own spatially-resolved transcriptomics data that doesn't have to be
about DLPFC layers.
Other Layer correlation functions:
layer_stat_cor()
,
layer_stat_cor_plot()
## Obtain the necessary data
if (!exists("modeling_results")) {
modeling_results <- fetch_data(type = "modeling_results")
}
#> 2024-12-13 19:39:58.500782 loading file /github/home/.cache/R/BiocFileCache/5c656d46b9_Human_DLPFC_Visium_modeling_results.Rdata%3Fdl%3D1
## Compute the correlations
cor_stats_layer <- layer_stat_cor(
tstats_Human_DLPFC_snRNAseq_Nguyen_topLayer,
modeling_results,
model_type = "enrichment"
)
## Obtain labels
annotate_registered_clusters(cor_stats_layer)
#> cluster layer_confidence layer_label layer_label_simple
#> 1 22 (3) good WM WM
#> 2 3 (3) good WM WM
#> 3 23 (3) good WM WM
#> 4 17 (3) good WM WM
#> 5 21 (3) good WM WM
#> 6 7 (4) good Layer1 L1
#> 7 5 (4) good Layer1 L1
#> 8 9 (5) poor Layer1/WM* L1/WM*
#> 9 26 (5) poor Layer1* L1*
#> 10 1 (4) poor Layer1/WM* L1/WM*
#> 11 24 (6) poor Layer6* L6*
#> 12 13 (1) good Layer6 L6
#> 13 10 (1) good Layer6 L6
#> 14 27 (1) good Layer6 L6
#> 15 29 (2) poor Layer4* L4*
#> 16 14 (2) good Layer4 L4
#> 17 15 (2) poor Layer5/Layer4* L5/4*
#> 18 18 (2) poor Layer4* L4*
#> 19 2 (1) poor Layer5* L5*
#> 20 31 (1) good Layer5 L5
#> 21 8 (1) poor Layer2* L2*
#> 22 16 (2) poor Layer2* L2*
#> 23 28 (2) poor Layer2* L2*
#> 24 30 (2) poor Layer2* L2*
#> 25 20 (2) poor Layer3/Layer5/Layer4* L3/5/4*
#> 26 11 (2) poor Layer4/Layer3* L4/3*
#> 27 25 (2) poor Layer2/Layer4/Layer3* L2/4/3*
#> 28 4 (1) good Layer3/Layer4 L3/4
#> 29 12 (1) good Layer4 L4
#> 30 6 (1) good Layer2 L2
#> 31 19 (1) good Layer3 L3
## More relaxed merging threshold
annotate_registered_clusters(cor_stats_layer, cutoff_merge_ratio = 1)
#> cluster layer_confidence layer_label
#> 1 22 (3) good WM
#> 2 3 (3) good WM
#> 3 23 (3) good WM
#> 4 17 (3) good WM
#> 5 21 (3) good WM
#> 6 7 (4) good Layer1
#> 7 5 (4) good Layer1
#> 8 9 (5) poor Layer1/WM*
#> 9 26 (5) poor Layer1/WM*
#> 10 1 (4) poor Layer1/WM*
#> 11 24 (6) poor Layer6/WM/Layer1*
#> 12 13 (1) good Layer6
#> 13 10 (1) good Layer6
#> 14 27 (1) good Layer6
#> 15 29 (2) poor Layer4/Layer3*
#> 16 14 (2) good Layer4/Layer5/Layer3
#> 17 15 (2) poor Layer5/Layer4*
#> 18 18 (2) poor Layer4/Layer5/Layer3*
#> 19 2 (1) poor Layer5*
#> 20 31 (1) good Layer5
#> 21 8 (1) poor Layer2/Layer3*
#> 22 16 (2) poor Layer2/Layer3*
#> 23 28 (2) poor Layer2/Layer3*
#> 24 30 (2) poor Layer2/Layer3/Layer4/Layer5/Layer1*
#> 25 20 (2) poor Layer3/Layer5/Layer4*
#> 26 11 (2) poor Layer4/Layer3/Layer2/Layer5*
#> 27 25 (2) poor Layer2/Layer4/Layer3/Layer5*
#> 28 4 (1) good Layer3/Layer4
#> 29 12 (1) good Layer4/Layer5/Layer3
#> 30 6 (1) good Layer2/Layer3
#> 31 19 (1) good Layer3/Layer2/Layer4
#> layer_label_simple
#> 1 WM
#> 2 WM
#> 3 WM
#> 4 WM
#> 5 WM
#> 6 L1
#> 7 L1
#> 8 L1/WM*
#> 9 L1/WM*
#> 10 L1/WM*
#> 11 L6/WM/1*
#> 12 L6
#> 13 L6
#> 14 L6
#> 15 L4/3*
#> 16 L4/5/3
#> 17 L5/4*
#> 18 L4/5/3*
#> 19 L5*
#> 20 L5
#> 21 L2/3*
#> 22 L2/3*
#> 23 L2/3*
#> 24 L2/3/4/5/1*
#> 25 L3/5/4*
#> 26 L4/3/2/5*
#> 27 L2/4/3/5*
#> 28 L3/4
#> 29 L4/5/3
#> 30 L2/3
#> 31 L3/2/4