library(Seurat)
library(readr)
download.file(
"https://s3-us-west-2.amazonaws.com/10x.files/samples/cell/pbmc3k/pbmc3k_filtered_gene_bc_matrices.tar.gz",
destfile = "data/seuratPBMC.tar.gz"
)
untar("data/seuratPBMC.tar.gz", exdir = "data/")
pbmc.data <- Read10X("data/filtered_gene_bc_matrices/hg19/")
pbmc.data <- CleanMatrixMCA(pbmc.data)
pbmc <-
CreateSeuratObject(
counts = pbmc.data,
project = "pbmc3k",
min.cells = 3,
min.features = 200
)
pbmc[["percent.mt"]] <-
PercentageFeatureSet(object = pbmc, pattern = "^MT-")
pbmc <-
subset(x = pbmc,
subset = nFeature_RNA > 200 & nFeature_RNA < 2500 & percent.mt < 5)
pbmc <-
NormalizeData(
object = pbmc,
normalization.method = "LogNormalize",
scale.factor = 10000
)
pbmc <-
FindVariableFeatures(object = pbmc,
selection.method = "vst",
nfeatures = 2000)
all.genes <- rownames(x = pbmc)
pbmc <- ScaleData(object = pbmc, features = all.genes)
pbmc <-
RunPCA(object = pbmc, features = VariableFeatures(object = pbmc))
pbmc <- FindNeighbors(object = pbmc, dims = 1:10)
pbmc <- FindClusters(object = pbmc, resolution = 0.5)
new.cluster.ids <-
c("Memory CD4 T",
"Naive CD4 T",
"CD14+ Mono",
"B",
"CD8 T",
"FCGR3A+ Mono",
"NK",
"DC",
"Mk")
names(x = new.cluster.ids) <- levels(x = pbmc)
pbmc <- RenameIdents(object = pbmc, new.cluster.ids)
Seurat2700PBMCs <- pbmc
set.seed(100)
samp <- sample(colnames(pbmc), 50)
seuratPbmc <- subset(pbmc, cells = samp)
seuratPbmc2 <-
CreateSeuratObject(counts = GetAssayData(seuratPbmc, slot = "counts"))
seuratPbmc2 <- NormalizeData(seuratPbmc2)
VariableFeatures(seuratPbmc2) <- VariableFeatures(seuratPbmc)
Idents(seuratPbmc2) <- seuratPbmc@active.ident
seuratPbmc <- seuratPbmc2
seuratPbmc <-
AddMetaData(seuratPbmc, seuratPbmc@active.ident, col.name = "seurat_clusters")
unlink("data/seuratPBMC.tar.gz", recursive = TRUE)
unlink("data/filtered_gene_bc_matrices/", recursive = TRUE)
devtools::use_data(seuratPbmc, overwrite = TRUE)
write_rds(Seurat2700PBMCs,"../Seurat2700PBMCs.rds")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.