calculate_correlations {STDistance}R Documentation

Perform correlation analysis between spatial features and distance metrics with visualization

Description

Perform correlation analysis between spatial features and distance metrics with visualization

Usage

calculate_correlations(
  spatial_data,
  distance_results,
  spatial_feature,
  distance_metric,
  method = "pearson",
  plot = TRUE,
  plot_title = NULL
)

Arguments

spatial_data

Spatial data containing feature columns and Newbarcode identifier

distance_results

Distance results containing distance metrics and Newbarcode identifier

spatial_feature

Column name from spatial_data to use for correlation (e.g., "gen2_SPLIz_numeric")

distance_metric

Column name from distance_results to use for correlation (e.g., "Epithelial_cells_A")

method

Correlation method ("pearson", "spearman", "kendall")

plot

Logical, whether to generate a scatter plot

plot_title

Title for the scatter plot (optional)

Value

A list containing correlation results and ggplot object (if plot=TRUE)

Examples

calculate_correlations(spatial_data = posi,
             distance_results = distance_results,
             spatial_feature = "gen2_SPLIz_numeric",
             distance_metric = "Epithelial_cells_A",
             method = "pearson",
             plot = TRUE,
             plot_title = "Correlation between Gene Expression and Distance")

[Package STDistance version 0.6.6 Index]