R/compute_metrics.R
compute_metrics.Rd
This function calculates count based Measures (Ripley's K, Besag L, and Marcon's M) of IF data to characterize correlation of spatial point process. For neareast neighbor calculations of a given cell type, this function computes proportion of cells that have nearest neighbor less than r for the observed and permuted point processes.
An MIF object
Character vector of marker names to estimate degree of spatial clustering.
Numeric vector of potential r values this range must include 0.
Numeric value indicating the number of permutations used. Default is 50.
Character vector indicating the type of edge correction to use. Options for count based include "translation" or "isotropic" and for nearest neighboroOptions include "rs" or "hans".
Character vector indicating which count based measure (K, BiK, G, BiG) used to estimate the degree of spatial clustering. Description of the methods can be found in Details section.
Character value of the transformation to apply to count based metrics (none, M, or L)
Logical value determining whether or not to keep the full distribution of permuted K or G values
Integer value for the number of workers to spawn
Logical value determining if you want the results to replace the current output (TRUE) or be to be appended (FALSE).
a string corresponding to the x coordinates. If null the average of XMin and XMax will be used
a string corresponding to the y coordinates. If null the average of YMin and YMax will be used
whether or not to compute all combinations of markers
Returns a data.frame
Expected value assuming complete spatial randomnessn
Average observed K, L, or M for the permuted point process
Observed valuefor the observed point process
Degree of spatial clustering where the reference is the permutated estimate of CSR
Degree of spatial clustering where the reference is the theoretical estimate of CSR
#Create mif object
library(dplyr)
x <- create_mif(clinical_data = example_clinical %>%
mutate(deidentified_id = as.character(deidentified_id)),
sample_data = example_summary %>%
mutate(deidentified_id = as.character(deidentified_id)),
spatial_list = example_spatial,
patient_id = "deidentified_id",
sample_id = "deidentified_sample")
# Define the set of markers to study
mnames <- c("CD3..Opal.570..Positive","CD8..Opal.520..Positive",
"FOXP3..Opal.620..Positive","CD3..CD8.","CD3..FOXP3.")
# Ripley's K and nearest neighbor G for all markers with a neighborhood size
# of 10,20,...,100 (zero must be included in the input).