-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathLake_Habib.Rmd
93 lines (63 loc) · 3.48 KB
/
Lake_Habib.Rmd
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
---
title: "R Notebook"
output: html_notebook
---
```{r}
load('/data/proj/GCB_EA/kawai/Lake/Lake_OliOPC_up.Robj')
load('/data/proj/GCB_EA/kawai/Habib/Habib_OliOPC.Robj')
Habib<-FindVariableGenes(object = Habib_OliOPC, mean.function = ExpMean, dispersion.function = LogVMR,
x.low.cutoff = 0.0125, x.high.cutoff = 4, y.cutoff = 0.5)
Lake<-FindVariableGenes(object = Lake_OliOPC, mean.function = ExpMean, dispersion.function = LogVMR,
x.low.cutoff = 0.0125, x.high.cutoff = 4, y.cutoff = 0.5)
Lake_gene<-head(rownames([email protected]),1000)
Habib_gene<-head(rownames([email protected]),1000)
gene.use<-union(Lake_gene,Habib_gene)
gene.use<-unique(gene.use) #1930
gene.use<-c(gene.use)
length(gene.use)
```
```{r}
colnames([email protected])[3:ncol([email protected])]<-paste0('Lake_',colnames([email protected])[3:ncol([email protected])])
colnames([email protected])[3:ncol([email protected])]<-paste0('Habib_',colnames([email protected])[3:ncol([email protected])])
Dataset<-data.frame(row.names=rownames([email protected]),Dataset=c(replicate(nrow([email protected]),'Lake et al. (2018)')))
Lake<-AddMetaData(object = Lake,col.name = Dataset,metadata = Dataset)
Dataset<-data.frame(row.names=rownames([email protected]),Dataset=c(replicate(nrow([email protected]),'Habib et al., (2018)')))
Habib<-AddMetaData(object = Habib,col.name = Dataset,metadata = Dataset)
Habib_Lake<-RunCCA(Habib, Lake, num.cc = 30,genes.use = gene.use)
H_L_CCA_to_beused<-MetageneBicorPlot(Habib_Lake, grouping.var ='Dataset' , dims.eval = 1:30, display.progress = TRUE,smooth = FALSE)
save('H_L_CCA_to_beused',file='H_L_CCA_to_beused.Robj')
save('Habib_Lake',file='Habib_Lake.Robj')
DimHeatmap(object = Habib_Lake, reduction.type = "cca", cells.use = 500,
dim.use = 10:20, do.balanced = TRUE)
```
#choose CC up to 13
```{r}
Habib_Lake<-CalcVarExpRatio(object = Habib_Lake, reduction.type = "pca", grouping.var = "Dataset", dims.use = 1:13)
discarded_Habib_Lake<- SubsetData(Habib_Lake, subset.name = "var.ratio.pca", accept.high = 0.5)
discarded_cells<-c()
discarded_cells_Habib_Lake <- c(discarded_cells, rownames([email protected]))
all_Habib_Lake<-Habib_Lake
Habib_Lake<-SubsetData(object = Habib_Lake, subset.name = "var.ratio.pca", accept.low = 0.5)
dim([email protected]) #33905 5797
dim([email protected]) #34465 6336
Habib_Lake<-AlignSubspace(Habib_Lake, reduction.type = "cca", grouping.var = "Dataset", dims.align = 1:13)
Habib_Lake<-RunTSNE(Habib_Lake, reduction.use = "cca.aligned", dims.use = 1:13,seed.use=1)
Habib_Lake <- FindClusters(Habib_Lake, reduction.type = "cca.aligned", resolution = 0.6, dims.use = 1:13)
save('Habib_Lake',file='Habib_Lake.Robj')
#1,8,10 -> OPC res1
TSNEPlot(Habib_Lake,do.label = TRUE,do.return=TRUE)
TSNEPlot(Habib_Lake,do.label = TRUE,do.return=TRUE,group.by='res.1')
TSNEPlot(Habib_Lake,do.label = TRUE,do.return=TRUE,group.by='Dataset')
FeaturePlot(Habib_Lake,features.plot = 'OPALIN',cols.use = c('grey','red'))
FeatureHeatmap(Habib_Lake,features.plot = 'OPALIN',group.by = 'Dataset')
```
```{r}
L_H_res1<-data.frame(cell =rownames([email protected]),[email protected]$res.1)
#0 OLI1 #1 OLI2 #2 OLI3 #3 OLI4 #4 OLI5 #5 OLI6 #6 OLI7 #7 OPC #8 OLI8 #9 OLI9
res1=c(0,1,2,3,4,5,6,7,8,9,10,11)
assigned=c('OLI1','OLI2','OLI3','OLI4','OLI5','OLI6','OLI7','OPC1','OLI8','OLI9')
H_J_res1$H_J_res1assigned<-plyr::mapvalues(x = H_J_res1$H_J_res1, from = res1, to = assigned)
save('L_H_res1',file='L_H_res1.Robj')
```
```