# R code
library(Seurat)
mat_5 <- read.table("GSM4037992_peripheral_donor_5_enriched_expression.tsv.gz")
row.names(mat_5) <- mat_5[,1]
#保存原始cluster labels
orig_cluster_labels5 <- mat_5$final_cluster_labels
mat_5 <- mat_5[,-c(1:3)]
#需要转置一下,行是细胞barcode
peripheral_donor_5 <- CreateSeuratObject(counts=t(mat_5),project="peripheral_donor_5")
peripheral_donor_5 <- AddMetaData(object = peripheral_donor_5, metadata = orig_cluster_labels5, col.name = "orig_cluster_labels")
mat_7 <- read.table("GSM4037994_peripheral_donor_7_enriched_expression.tsv.gz")
row.names(mat_7) <- mat_7[,1]
orig_cluster_labels7 <- mat_7$final_cluster_labels
mat_7 <- mat_7[,-c(1:3)]
peripheral_donor_7 <- CreateSeuratObject(counts=t(mat_7),project="peripheral_donor_7")
peripheral_donor_7 <- AddMetaData(object = peripheral_donor_7, metadata = orig_cluster_labels7, col.name = "orig_cluster_labels")
peripheral <- merge(peripheral_donor_5,
y = peripheral_donor_7)
peripheral[["percent.mt"]] <- PercentageFeatureSet(peripheral, pattern = "^MT")
VlnPlot(peripheral, features = c("nFeature_RNA", "nCount_RNA", "percent.mt"), ncol = 3)
peripheral <- FindVariableFeatures(peripheral, selection.method = "vst", nfeatures = 2000)
all.genes <- rownames(peripheral)
#不是原始count 计数矩阵,直接Scale下面流程
peripheral <- ScaleData(peripheral, features = all.genes)
peripheral <- RunPCA(peripheral, features = VariableFeatures(object = peripheral))
ElbowPlot(peripheral)
peripheral <- RunUMAP(peripheral, dims = 1:20)
DimPlot(peripheral, reduction = "umap", label = TRUE, pt.size = 0.5) + NoLegend()
FeaturePlot(peripheral, features = c("ARHGEF3"))
# GSE124395
#GSE124395_Normalhumanliverdata.RData
#An Rdata file containing the expression matrix of cells and genes from the normal human liver cell atlas. Please assign a variable and use the readRDS() function in R to load this data in R.
#这个作者有给RData文件,但是直接load发现打不开,作者让我们用readRDS读
library(Seurat)
count <- readRDS("GSE124395_Normalhumanliverdata.RData")
#dim(count)
#33941 12622
GSE124395 <- CreateSeuratObject(counts=count,project="GSE124395")
cluster <- read.table("GSE124395_clusterpartition.txt.gz")
#GSE124395部分细胞不在cluster中,应该是作者进行了过滤
#AddMetaData是可以匹配行名添加值的
GSE124395 <- AddMetaData(object = GSE124395 , metadata = cluster , col.name = "orig_cluster_labels")
#转成anndata格式
SaveH5Seurat(GSE124395, filename = "GSE124395.h5Seurat")
Convert("GSE124395.h5Seurat", dest = "h5ad")