-
Notifications
You must be signed in to change notification settings - Fork 0
/
10X_expr_matrix_QC_barcode.R
executable file
·30 lines (28 loc) · 1.34 KB
/
10X_expr_matrix_QC_barcode.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
library(Seurat)
library(dplyr)
library(Matrix)
library(methods)
packageVersion("Seurat")
args=commandArgs(TRUE)
path<-args[1]
name<-args[2]
pbmc.data<-Read10X(data.dir = path)
pbmc <- CreateSeuratObject(raw.data = pbmc.data, min.cells = 0, min.genes = 0,project = name)
mito.genes <- grep(pattern = "^MT-", x = rownames(x = pbmc@data), value = TRUE,ignore.case = T)
percent.mito <- colSums([email protected][mito.genes, ])/colSums([email protected])
pbmc <- AddMetaData(object = pbmc, metadata = percent.mito, col.name = "percent.mito")
pdf("Before_QC.pdf",16,9)
print(VlnPlot(object = pbmc, features.plot = c("nGene", "nUMI", "percent.mito"), nCol = 3))
##par(mfrow = c(1, 2))
print(GenePlot(object = pbmc, gene1 = "nUMI", gene2 = "percent.mito"))
print(GenePlot(object = pbmc, gene1 = "nUMI", gene2 = "nGene"))
dev.off()
pbmc <- FilterCells(object = pbmc, subset.names = c("nGene", "percent.mito"),low.thresholds = c(300, -Inf), high.thresholds = c(Inf, 0.15))
pdf("After_QC.pdf",16,9)
print(VlnPlot(object = pbmc, features.plot = c("nGene", "nUMI", "percent.mito"), nCol = 3))
print(GenePlot(object = pbmc, gene1 = "nUMI", gene2 = "percent.mito"))
print(GenePlot(object = pbmc, gene1 = "nUMI", gene2 = "nGene"))
dev.off()
barcode<-colnames(pbmc@data)
barcode<-data.frame(Barcode=barcode)
write.csv(barcode,paste(name,"barcode_filter.csv",sep="_"),row.names = F,quote = F)