Description Usage Arguments Value Examples
Use this function to compute LISI scores of one or more labels.
1 | compute_lisi(X, meta_data, label_colnames, perplexity = 30, nn_eps = 0)
|
X |
A matrix with cells (rows) and features (columns). |
meta_data |
A data frame with one row per cell. |
label_colnames |
Which variables to compute LISI for. |
perplexity |
The effective number of each cell's neighbors. |
nn_eps |
Error bound for nearest neighbor search with |
A data frame of LISI values. Each row is a cell and each column is a different label variable.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ## Example with 400 cells.
library(lisi)
library(dplyr)
library(tidyr)
library(ggplot2)
library(magrittr)
head(lisi::meta_data)
## Let's color cells by labels. For label 1, there are mixed and non-mixed
## groups. For label 2, all cells are well mixed.
lisi::X %>%
cbind(lisi::meta_data) %>%
sample_frac(1L, FALSE) %>%
gather(key, val, label1, label2) %>%
ggplot(aes(X1, X2, color = val)) +
geom_point(shape = 21) +
facet_wrap(~key)
## Now to compute and plot the LISI values for each label.
lisi_res <- compute_lisi(lisi::X, lisi::meta_data, c('label1', 'label2'))
head(lisi_res)
lisi::X %>%
cbind(lisi_res) %>%
sample_frac(1L, FALSE) %>%
gather(key, lisi_value, label1, label2) %>%
ggplot(aes(X1, X2, color = lisi_value)) +
geom_point(shape = 21) +
facet_wrap(~key)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.