Mouse pancreatic endocrinogenesis dataset from Bastidas-Ponce et al. (2019). A total of 1000 cells were downsampled to form the pancreas_sub
dataset.
Source
https://scvelo.readthedocs.io/en/stable/scvelo.datasets.pancreas.html https://github.com/theislab/scvelo_notebooks/raw/master/data/Pancreas/endocrinogenesis_day15.h5ad
Examples
if (FALSE) { # \dontrun{
if (interactive()) {
library(Seurat)
library(reticulate)
library(slingshot)
check_Python("scvelo")
scv <- import("scvelo")
adata <- scv$datasets$pancreas()
pancreas <- adata_to_srt(adata)
set.seed(11)
pancreas_sub <- subset(pancreas, cells = sample(colnames(pancreas), size = 1000))
pancreas_sub <- pancreas_sub[rowSums(pancreas_sub@assays$RNA@counts) > 0, ]
pancreas_sub[["CellType"]] <- pancreas_sub[["clusters_coarse"]]
pancreas_sub[["SubCellType"]] <- pancreas_sub[["clusters"]]
pancreas_sub[["clusters_coarse"]] <- pancreas_sub[["clusters"]] <- NULL
pancreas_sub[["Phase"]] <- ifelse(pancreas_sub$S_score > pancreas_sub$G2M_score, "S", "G2M")
pancreas_sub[["Phase"]][
apply(pancreas_sub[[]][, c("S_score", "G2M_score")], 1, max) < 0, ] <- "G1"
pancreas_sub[["Phase", drop = TRUE]] <- factor(pancreas_sub[["Phase", drop = TRUE]],
levels = c("G1", "S", "G2M"))
pancreas_sub[["PCA"]] <- pancreas_sub[["X_pca"]]
pancreas_sub[["UMAP"]] <- pancreas_sub[["X_umap"]]
pancreas_sub[["X_umap"]] <- pancreas_sub[["X_pca"]] <- NULL
VariableFeatures(pancreas_sub) <- rownames(pancreas_sub[["RNA"]])[
which(pancreas_sub[["RNA"]]@meta.features$highly_variable_genes == "True")]
pancreas_sub <- NormalizeData(pancreas_sub)
pancreas_sub <- FindVariableFeatures(pancreas_sub)
pancreas_sub <- ScaleData(pancreas_sub)
pancreas_sub <- RunPCA(pancreas_sub)
pancreas_sub <- FindNeighbors(pancreas_sub)
pancreas_sub <- FindClusters(pancreas_sub, resolution = 0.5)
pancreas_sub <- RunUMAP(pancreas_sub, dims = 1:30)
# run slingshot
reduction <- DefaultDimReduc(pancreas_sub)
sl <- slingshot(
data = as.data.frame(pancreas_sub[[reduction]]@cell.embeddings[, 1:2]),
clusterLabels = as.character(pancreas_sub$SubCellType)
)
df <- as.data.frame(slingPseudotime(sl))
pancreas_sub <- AddMetaData(pancreas_sub, metadata = df)
pancreas_sub <- AddMetaData(pancreas_sub, metadata = slingBranchID(sl), col.name = "BranchID")
# usethis::use_data(pancreas_sub, compress = "xz")
}
} # }