This function calculates the nearest neighbour correlation for each feature (eg, proteins) in each sample. This is calculated by taking the correlation between each cell and its nearest neighbours cell for a particular feature. This function supports spatial proteomics, and spatial transcriptomics.
Arguments
- data
A list object containing
data
matrix andcelltype
andsample
vector.- type
The type of dataset, either "scrna", "spatial_t", or "spatial_p".
- num_top_gene
Number of top variable genes to use when genes is not provided. Defaults to 1500.
- ncores
Number of cores for parallel processing.
Value
a dataframe of samples x features The features are in the form of protein 1, protein 2 ... etc, with the numbers representing Pearson's correlation.
Examples
utils::data("example_scrnaseq" , package = "scFeatures")
data <- example_scrnaseq[1:50, 1:20]
celltype <- data$celltype
data <- data@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_nn_correlation <- run_nn_correlation(
alldata, type = "spatial_p", ncores = 1
)
#> Warning: the standard deviation is zero
#> Warning: the standard deviation is zero
#> Warning: the standard deviation is zero
#> Warning: the standard deviation is zero
#> Warning: the standard deviation is zero
#> Warning: the standard deviation is zero
#> Warning: the standard deviation is zero
#> Warning: the standard deviation is zero
#> Warning: the standard deviation is zero
#> Warning: the standard deviation is zero
#> Warning: the standard deviation is zero
#> Warning: the standard deviation is zero
#> Warning: the standard deviation is zero
#> Warning: the standard deviation is zero
#> Warning: the standard deviation is zero
#> Warning: the standard deviation is zero
#> Warning: the standard deviation is zero
#> Warning: the standard deviation is zero
#> Warning: the standard deviation is zero