calculate_proportions_of_cells_in_structure
Source:R/calculate_proportions_of_cells_in_structure.R
calculate_proportions_of_cells_in_structure.Rd
Calculate the proportion of cells of interest in each defined tumour structure relative to all cells in each structure and relative to the same cell type in the whole image.
Usage
calculate_proportions_of_cells_in_structure(
sce_object,
cell_types_of_interest,
feature_colname
)
Arguments
- sce_object
SingleCellExperiment object in the form of the output of
format_image_to_sce
.- cell_types_of_interest
String Vector of immune cells to consider.
- feature_colname
String. The name of the column where the immune cell types are under.
Examples
sce_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"
sce_dist <- calculate_distance_to_tumour_margin(sce_border)
#> [1] "Markers had been selected in pair-wise distance calculation: "
#> [1] "Non-border" "Border"
sce_structure <- define_structure(sce_dist,
names_of_immune_cells = c("Immune1","Immune2","Immune3"),
feature_colname = "Cell.Type", n_margin_layers = 5)
calculate_proportions_of_cells_in_structure(sce_structure,
cell_types_of_interest = c("Immune1","Immune3"),feature_colname = "Cell.Type")
#> Cell.Type Relative_to
#> 1 Immune1 All_cells_in_the_structure
#> 2 Immune3 All_cells_in_the_structure
#> 3 Immune1 All_cells_of_interest_in_the_structure
#> 4 Immune3 All_cells_of_interest_in_the_structure
#> 5 Immune1 The_same_cell_type_in_the_whole_image
#> 6 Immune3 The_same_cell_type_in_the_whole_image
#> 7 All_cells_of_interest All_cells_in_the_structure
#> P.Infiltrated.Immune P.Internal.Margin.Immune P.External.Margin.Immune
#> 1 0.00000000 0.00000000 0.005494505
#> 2 0.14385965 0.08780488 2.159340659
#> 3 0.00000000 0.00000000 0.002538071
#> 4 1.00000000 1.00000000 0.997461929
#> 5 0.00000000 0.00000000 0.002958580
#> 6 0.06507937 0.05714286 0.623809524
#> 7 0.14385965 0.08780488 2.170329670
#> P.Stromal.Immune
#> 1 0.11971581
#> 2 0.05683837
#> 3 0.67806841
#> 4 0.32193159
#> 5 0.99704142
#> 6 0.25396825
#> 7 0.23943162