bi_NN_G: Bivariate Nearest Neighbor Based Measures of Spatial...

View source: R/nearest_neighbor.R

bi_NN_GR Documentation

Bivariate Nearest Neighbor Based Measures of Spatial Clustering for IF data

Description

This function computes the nearest neighbor distribution for a particular marker relative to another marker for the observed and permuted point processes.

Usage

bi_NN_G(
  mif,
  mnames,
  r_range = seq(0, 100, 50),
  num_permutations = 50,
  edge_correction = "rs",
  keep_perm_dis = FALSE,
  exhaustive = TRUE,
  workers = 1,
  overwrite = FALSE,
  xloc = NULL,
  yloc = NULL
)

Arguments

mif

An MIF object

mnames

Character vector of marker names to estimate degree of nearest neighbor distribution

r_range

Numeric vector of potential r values this range must include 0. Note that the range selected is very different than count based measures. See details.

num_permutations

Numeric value indicating the number of permutations used. Default is 50.

edge_correction

Character value indicating the type of edge correction to use. Options include "rs" or "hans".

keep_perm_dis

Logical value determining whether or not to keep the full distribution of permuted G values

exhaustive

Logical. If TRUE then markers must be a vector and spatial measures will be computed all pairs of unique markers. If FALSE then markers must be a data.frame with the desired combinations.

workers

Integer value for the number of workers to spawn

overwrite

Logical value determining if you want the results to replace the current output (TRUE) or be to be appended (FALSE).

xloc

a string corresponding to the x coordinates. If null the average of XMin and XMax will be used

yloc

a string corresponding to the y coordinates. If null the average of YMin and YMax will be used

Value

Returns a data frame

anchor

Marker for which the distances are measured from

counted

Marker for which the distances are measured to

Theoretical CSR

Expected value assuming complete spatial randomness

Permuted CSR

Average observed G for the permuted point process

Observed

Observed value for the observed point process

Degree of Clustering Permuted

Degree of spatial clustering where the reference is the permuted estimate of CSR

Degree of Clustering Theoretical

Degree of spatial clustering where the reference is the theoretical estimate of CSR

Examples

#' #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")

#Nearest Neighbor distribution for the colocalization of CD3+CD8+ positive 
#cells and CD3+FOXP3+ positive cells where CD3+FOXP3+ is the reference cell 
#type at neighborhood size of 10,20,...,100 (zero must be included in the 
#input).

x <- bi_NN_G(mif = x, mnames = c("CD3..CD8.", "CD3..FOXP3."), 
num_permutations = 1, edge_correction = 'rs', r = seq(0,100,10),
keep_perm_dis = FALSE, workers = 1, exhaustive = TRUE) 


spatialTIME documentation built on April 1, 2023, 12:18 a.m.