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
)

Arguments

csd

Cell seg data with Cell X Position, Cell Y Position, field name and Phenotype columns.

radii

Vector of radii to search within.

phenotypes

Optional list of phenotypes to include. If omitted, will use unique_phenotypes(csd). Counts are computed for all pairs of phenotypes.

categories

Optional list of tissue categories to compute within. If omitted or NA, all cells will be included.

details_path

If present, path to save tab-separated tables with count within data for each cell.

.by

Column to aggregate by

extra_cols

The names of extra columns to include in the detailed results.

Value

A data frame with summary statistics for each phenotype pair in each Slide ID.

Details

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.