shinycell

Author

Almut Lütge

Interactively explore single cell data

Preamble

library(dplyr)
library(tidyr)
library(ggplot2)
library(zellkonverter)
library(SingleCellExperiment)
library(ShinyCell)
library(Seurat)

Load data objects

sce <- readH5AD(file.path("..", "data", "1.1-sce-after-contamination-removal-integration-clustering.h5ad"), reader ="R")

sce_pre <- readRDS(file.path("..", "data", "0.2-sce-after-contamination-removal.rds"))

#saveRDS(sce, file.path("..", "data", "1.1-sce-after-contamination-removal-integration-clustering.rds"))

#Annotate object
sce$cell_types <- sce$logcounts.scaled.pca.harmony.neighbors_connectivities.leiden_05res

sce <- sce[, !sce$cell_types %in% c("6", "8", "9", "10")]

sce$cell_type_name <- as.factor(sce$cell_types) |> droplevels()
levels(sce$cell_type_name) <- c("4 precollector2", "1 capillary1", "3 precollector1", "6 valve", "2 capillary2", "5 collector", "7 proliferative")

sce$cell_type_name <- factor(sce$cell_type_name, levels = c("1 capillary1", "2 capillary2", "3 precollector1", "4 precollector2", "5 collector", "6 valve", "7 proliferative"))

reducedDims(sce)["umap"] <- reducedDims(sce)["logcounts.scaled.pca.harmony.neighbors.umap"]

# Add relevant metadata to unfiltered sce
sce_pre <- sce_pre[, colnames(sce)]
colData(sce_pre) <- colData(sce)
reducedDims(sce_pre) <- reducedDims(sce)

saveRDS(sce_pre, file.path("..", "data", "sce_all_metadata_genes.rds"))

# Convert to seurat
seurat <- as.Seurat(sce_pre, counts = "counts", data = "logcounts")
seurat$ident <- seurat$cell_type_name

saveRDS(seurat, file.path("..", "data", "seurat_all_metadata_genes.rds"))

Load ShinyCell

scConf = createConfig(sce_pre)
makeShinyApp(sce_pre, scConf, gene.mapping = TRUE,
             shiny.title = "LECs different tissues")