getClusters: Get transcriptional clusters by graph-based clustering

getClustersR Documentation

Get transcriptional clusters by graph-based clustering

Description

Get transcriptional clusters by graph-based clustering

Usage

getClusters(
  pcs,
  k,
  method = igraph::cluster_louvain,
  weight = FALSE,
  verbose = FALSE,
  details = FALSE
)

Arguments

pcs

A matrix of principal components or gene expression to assess transcriptional similarity

k

Number of nearest neighbors for clustering

method

igraph method for graph-based clustering (default: cluster_louvain)

weight

Whether to using weighting by transcriptional distance

verbose

Verbosity

details

Return detailed ouputs

Value

Factor of cluster annotations

Examples

# simulate 3 spatially but 2 transcriptionally distinct groups
N <- 300
M <- 30
# Three spatially distinct groups
pos1 <- cbind(rnorm(N/3), rnorm(N/3))
pos2 <- cbind(rnorm(N/3, 10), rnorm(N/3))
pos3 <- cbind(rnorm(N/3, 10), rnorm(N/3, 10))
pos <- rbind(rbind(pos1, pos2), pos3)
group <- c(rep(1, N/3), rep(2, N/3), rep(3, N/3))
names(group) <- rownames(pos) <- paste0('cell', 1:N)
# But two are transcriptionally identical
pcs12 <- matrix(rnorm(N*2/3*M), N*2/3, M)
pcs3 <- matrix(rnorm(N*1/3*M, 10), N*1/3, M)
pcs <- rbind(pcs12, pcs3)
pcs <- cbind(pcs, abs(10-pcs))
colnames(pcs) <- paste0('PC:', 1:ncol(pcs))
rownames(pcs) <- rownames(pos)
com <- getClusters(pcs, k=50, verbose=TRUE)


JEFworks/MERingue documentation built on June 11, 2022, 4:16 a.m.