run_L_function: Generate L stats

View source: R/run_scfeatures.R

run_L_functionR Documentation

Generate L stats

Description

This function calculates L-statistics to measure spatial autocorrelation. L value greater than zero indicates spatial attraction of the pair of proteins whereas L value less than zero indicates spatial repulsion. The function supports spatial proteomics and spatial transcriptomics.

Usage

run_L_function(data, type = "spatial_p", ncores = 1)

Arguments

data

A list object containing data matrix and celltype and sample vector.

type

The type of dataset, either "scrna", "spatial_t", or "spatial_p".

ncores

Number of cores for parallel processing.

Value

a dataframe of samples x features The features are in the form of protein 1 vs protein 2, protein 1 vs protein 3 ... etc, with the numbers representing the L values.

Examples


utils::data("example_scrnaseq" , package = "scFeatures")
celltype <- example_scrnaseq$celltype 
data <- example_scrnaseq@assays$RNA@data
sample <- sample( c("patient1", "patient2", "patient3"), ncol(data) , replace= TRUE )
x <- sample(1:100, ncol(data) , replace = TRUE)
y <- sample(1:100, ncol(data) , replace = TRUE)
spatialCoords <- list( x , y)
alldata <- scFeatures:::formatData(data = data, sample = sample, celltype = celltype, 
spatialCoords  = spatialCoords )

feature_L_function <- run_L_function(alldata, type = "spatial_p", ncores = 1)


SydneyBioX/scFeatures documentation built on Aug. 29, 2024, 10:37 a.m.