View source: R/correlationStatistics.R
interCellTypeSpatialCrossCor | R Documentation |
Tests for inter-cell-type spatial cross-correlation between gene A in group A and gene B in group B
interCellTypeSpatialCrossCor(gexpA, gexpB, groupA, groupB, weight)
gexpA |
Expression for gene A |
gexpB |
Expression for gene B |
groupA |
Cells in group A |
groupB |
Cells in group B |
weight |
Adjacency weight matrix |
statistic of how well gene expression A in cells of group A are correlated in space with gene expression B in cells of group B
# Simulate data set.seed(0) N <- 100 pos <- cbind(rnorm(N), rnorm(N)) rownames(pos) <- paste0('cell', 1:N) colnames(pos) <- c('x', 'y') weight <- getSpatialNeighbors(pos) ctA <- sample(rownames(pos), N/2) ctB <- setdiff(rownames(pos), ctA) gexpA <- pos[,2] gexpA[ctB] <- 0 gexpB <- pos[,2] gexpB[ctA] <- 0 #plotEmbedding(pos, col=gexpA) #plotEmbedding(pos, col=gexpB) interCellTypeSpatialCrossCor(gexpA, gexpB, ctA, ctB, weight) cor(gexpA, gexpB) # compare
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.