matrix<-Read10X("filtered_feature_bc_matrix")
obj<-CreateSeuratObject(counts=matrix,project = "ffpedemo1")
id_map <- read_delim('filtered_feature_bc_matrix/features.tsv.gz', delim="\t", na="",
col_names = c('Ensembl', 'Symbol')) %>% dplyr::select(1, 2) %>%
mutate(Symbol_uniq=make.unique(Symbol))
rownames(id_map) <- id_map$Symbol_uniq
obj@tools$id_map <- id_map
obj[['percent.mito']] <- PercentageFeatureSet(object = obj, pattern = '^(MT|mt|Mt)-')
obj <- subset(obj, subset = nCount_RNA >= 300)
mt.p <- pnorm(obj$percent.mito, mean = median(obj$percent.mito), sd = mad(obj$percent.mito), lower.tail = FALSE)
mt.lim <- min(obj$percent.mito[which(p.adjust(mt.p, method = "fdr") < 0.05)])
if(mt.lim < 10){mt.lim = 10}
mito_threshold <- mt.lim
if(is.infinite(mito_threshold)){
mito_threshold <- 100
}
obj <- subset(obj, subset = `percent.mito` <= mito_threshold)
obj <- NormalizeData(obj, verbose = FALSE)
obj <- FindVariableFeatures(obj, selection.method = "vst", nfeatures = 2000, verbose = FALSE)
obj <- ScaleData(obj, verbose = FALSE)
obj <- RunPCA(obj, npcs = 15, verbose = FALSE)
obj <- FindNeighbors(obj, dims = 1:15)
resolution <- seq(0.2, 1.4, 0.3)
obj <- FindClusters(obj, resolution = resolution)
resolution_idents <- 'RNA_snn_res.0.8'
Idents(obj) <- resolution_idents
obj[['seurat_clusters']] <- obj[[resolution_idents]]
obj <- RunUMAP(obj, reduction = "pca", dims = 1:15)
obj <- RunTSNE(obj, reduction = "pca", dims = 1:15, check_duplicates = FALSE)
saveRDS(obj, file="ffpedemo1.rds")