R/calculate_summary_distances_of_cells_to_borders.R
calculate_summary_distances_of_cells_to_borders.Rd
Returns the mean, median and standard deviation of the distances between a specified cell type to the border.
calculate_summary_distances_of_cells_to_borders(
spe_object,
cell_types_of_interest,
feature_colname = "Cell.Type"
)
SpatialExperiment object. It should contain information of tissue structure and cell distances to the tissue region border (`colData()` has `Region` and `Distance.To.Border` columns).
String Vector of cell types to consider.
String specifying which column the interested cell types are from.
A data.frame is returned
spe_border <- identify_bordering_cells(SPIAT::defined_image,
reference_cell = "Tumour", feature_colname = "Cell.Type", n_to_exclude = 10)
#> [1] "The alpha of Polygon is: 63.24375"
spe_dist <- calculate_distance_to_margin(spe_border)
#> [1] "Markers had been selected in minimum distance calculation: "
#> [1] "Non-border" "Border"
spe_structure <- define_structure(spe_dist, cell_types_of_interest =
c("Immune1","Immune2","Immune3"), feature_colname = "Cell.Type",
n_margin_layers = 5)
calculate_summary_distances_of_cells_to_borders(spe_structure,
cell_types_of_interest = c("Immune1","Immune3"),feature_colname = "Cell.Type")
#> Cell.Type Area Min_d Max_d Mean_d
#> 1 All_cell_types_of_interest Within_border_area 10.93225 192.4094 86.20042
#> 2 All_cell_types_of_interest Stroma 10.02387 971.5638 195.10637
#> 3 Immune1 Within_border_area NA NA NA
#> 4 Immune1 Stroma 84.20018 970.7749 346.14096
#> 5 Immune3 Within_border_area 10.93225 192.4094 86.20042
#> 6 Immune3 Stroma 10.02387 971.5638 102.79227
#> Median_d St.dev_d
#> 1 88.23299 45.27414
#> 2 101.95113 194.68507
#> 3 NA NA
#> 4 301.01535 187.04247
#> 5 88.23299 45.27414
#> 6 68.19218 131.32714