-
Notifications
You must be signed in to change notification settings - Fork 0
/
Prepare_RDS.r
167 lines (92 loc) · 5.85 KB
/
Prepare_RDS.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# code record
# this code in 2021-12-30
#==========================================================================================================================================
# 1. run cellranger
# cell ranger was run by hg38,use cellranger v3.0.2
# cell ranger was run by xiapeng and lly
# xiapeng run all LCBM samples and lly run paired Lung sample
#==========================================================================================================================================
# 2. sample filter
# Lung cancer data [Sangsung] were filter by MT<20%.
# sample for Sangsung was prepare in Prepare_GSE131907.R file
# so maybe LCBM also use MT <20%
############################################################################################################################################
############################################################################################################################################
#===========================================================================================================================================
# @ this sample do not need to normalized
# LCBM cell ranger result in xiapeng's file /public/workspace/xiapeng/Brain_Tumor_sc/0data/LCBM/inhouse/
sample <- grep("\\.|E20927",dir("/public/workspace/xiapeng/Brain_Tumor_sc/0data/LCBM/inhouse/"),invert=T,value=T)
for(i in 1:length(sample)){
name <- sample[i]
datafile = paste0("/public/workspace/xiapeng/Brain_Tumor_sc/0data/LCBM/inhouse/",name,"/3cellranger/outs/filtered_feature_bc_matrix")
outpath = "/public/workspace/lily/Lung2Brain/HG38_Data/Prepare/"
rdspath = '/public/workspace/lily/Lung2Brain/HG38_Data/RDS/'
tmp <- Read10X(data.dir = datafile)
if(name=="WSY"){
name <- "Pair_BM"
}
dat<- CreateSeuratObject(counts = tmp, project = name,min.cells = 3, min.features = 200)
dat[["percent.mt"]] <- PercentageFeatureSet(object = dat, pattern = "^MT-")
pdf(paste0(outpath,name, "_vlnPlot_prepare.pdf"))
p<-VlnPlot(object = dat, features = c("nFeature_RNA", "nCount_RNA", "percent.mt"), ncol = 3)
print(p)
dev.off()
if(ncol(dat)>10000){
dat = subset(x=dat,subset=nFeature_RNA > 200 & nFeature_RNA < 7500 & percent.mt < 10)
}else{
dat = subset(x=dat,subset=nFeature_RNA > 200 & nFeature_RNA < 7500 & percent.mt < 20)
}
dat = NormalizeData(object = dat)
dat <- FindVariableFeatures(object = dat)
saveRDS(dat,file=paste0(rdspath,name,'.RDS'))
}
#===========================================================================================================================================
# and for paired Lung samples
# ~/R21136163_hg38 ,will mv into /public/workspace/lily/LCBM_pair/
library(Seurat)
name <- "Pair_Lung"
datafile = paste0("/public/workspace/lily/","R21136163_hg38","/outs/filtered_feature_bc_matrix")
outpath = "/public/workspace/lily/Lung2Brain/HG38_Data/Prepare/"
rdspath = '/public/workspace/lily/Lung2Brain/HG38_Data/RDS/'
tmp <- Read10X(data.dir = datafile)
dat<- CreateSeuratObject(counts = tmp, project = name,min.cells = 3, min.features = 200)
dat[["percent.mt"]] <- PercentageFeatureSet(object = dat, pattern = "^MT-")
pdf(paste0(outpath,name, "_vlnPlot_prepare.pdf"))
p<-VlnPlot(object = dat, features = c("nFeature_RNA", "nCount_RNA", "percent.mt"), ncol = 3)
print(p)
dev.off()
dat = subset(x=dat,subset=nFeature_RNA > 200 & nFeature_RNA < 7500 & percent.mt < 10)
dat = NormalizeData(object = dat)
dat <- FindVariableFeatures(object = dat)
saveRDS(dat,file=paste0(rdspath,name,'.RDS'))
############################################################################################################################################
############################################################################################################################################
############################################################################################################################################
############################################################################################################################################
############################################################################################################################################
############################################################################################################################################
# change some name
# mv
# and this data will trans to .5
# scp [email protected]:/public/workspace/lily/Lung2Brain/HG38_Data/RDS/\{A20190305.RDS,A20190312.RDS,D0927.RDS,E0927.RDS,Pair_BM.RDS,Pair_LUNG.RDS,T_Bsc1.RDS\} ./
# 2022-2-14
# prepare RDS for
#================================================================================================================================
library(Seurat)
name <- "PLCBM2"
datafile = paste0("/public/workspace/lily/LCBM_pair/","R22009109_hg38","/outs/filtered_feature_bc_matrix")
outpath = "/public/workspace/lily/Lung2Brain/HG38_Data/Prepare/"
rdspath = '/public/workspace/lily/Lung2Brain/HG38_Data/RDS/'
tmp <- Read10X(data.dir = datafile)
dat<- CreateSeuratObject(counts = tmp, project = name,min.cells = 3, min.features = 200)
dat[["percent.mt"]] <- PercentageFeatureSet(object = dat, pattern = "^MT-")
pdf(paste0(outpath,name, "_vlnPlot_prepare.pdf"))
p<-VlnPlot(object = dat, features = c("nFeature_RNA", "nCount_RNA", "percent.mt"), ncol = 3)
print(p)
dev.off()
dat = subset(x=dat,subset=nFeature_RNA > 200 & nFeature_RNA < 7500 & percent.mt < 10)
dat = NormalizeData(object = dat)
dat <- FindVariableFeatures(object = dat)
saveRDS(dat,file=paste0(rdspath,name,'.RDS'))
# and this data will trans to .5
# scp [email protected]:/public/workspace/lily/Lung2Brain/HG38_Data/RDS/PLCBM2.RDS ./