Computes summary "count within" statistics
for each Slide ID in csd and each pair of phenotypes in phenotypes.
See phenoptr::count_within() for details of the counts and the
summary calculation.
count_within_summary(
csd,
radii,
phenotypes = NULL,
categories = NA,
details_path = NULL,
.by = "Slide ID",
extra_cols = NULL
)Cell seg data with Cell X Position,
Cell Y Position, field name and Phenotype columns.
Vector of radii to search within.
Optional list of phenotypes to include. If omitted,
will use unique_phenotypes(csd). Counts are computed for all
pairs of phenotypes.
Optional list of tissue categories to compute within. If
omitted or NA, all cells will be included.
If present, path to save tab-separated tables with count within data for each cell.
Column to aggregate by
The names of extra columns to include in the detailed results.
A data frame with summary statistics for each phenotype pair in each Slide ID.
If details_path is provided, this will save a table with one
row per cell and columns for each phenotype and radius giving
the count of cells of that type within that distance.
Note: If categories is NA or includes NA, the "All" tissue category in
the results will include all cells in csd. If categories does not include
NA, the "All" tissue category will include only cells in the provided
categories.