-
Notifications
You must be signed in to change notification settings - Fork 0
/
6_cellphoneDB.Rmd
144 lines (128 loc) · 6.76 KB
/
6_cellphoneDB.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
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
---
title: "scRNA-seq Rat Metrial Glands"
author: "Ha T. H. Vu"
output: html_document
---
```{r setup, include=FALSE}
options(max.print = "75")
knitr::opts_chunk$set(
echo = TRUE,
collapse = TRUE,
comment = "#>",
fig.path = "Files/",
fig.width = 15,
prompt = FALSE,
tidy = FALSE,
message = FALSE,
warning = TRUE
)
knitr::opts_knit$set(width = 75)
```
This is a documentation for analyses of scRNA-seq data, generated from rat metrial gland tissues on gestational day (GD) 15.5 and 19.5. <br>
Preparing the inputs for CellphoneDB, following the instruction here: https://www.cellphonedb.org/ <br>
For gd15.5:
```{r, eval=F}
load("/work/LAS/geetu-lab/hhvu/project3_scATAC/scRNA-seq-analysis/3_cluster_DEG/rmChrMTgenes/GD15.5/gd15.5_res0.8.rda")
gd15.5 <- data
gd15.5$sample <- substr(names(gd15.5$orig.ident), 1, 6)
DefaultAssay(gd15.5) <- "RNA"
gd15.5 <- RenameIdents(gd15.5, `0` = "Other cells", `1` = "Other cells",
`2` = "Other cells", `3` = "Other cells", `4` = "Other cells",
`5` = "Other cells", `6` = "Natural killer cells",
`7` = "Macrophage cells", `8` = "Macrophage cells",
`9` = "Natural killer cells", `10` = "Endothelial cells",
`11` = "Macrophage cells", `12` = "Other cells",
`13` = "Endothelial cells", `14` = "Smooth muscle cells",
`15` = "Endothelial cells", `16` = "Other cells",
`17` = "Smooth muscle cells", `18` = "Other cells",
`19` = "Natural killer cells", `20` = "Other cells",
`21` = "Other cells", `22` = "Other cells",
`23` = "Invasive trophoblast cells", `24` = "Other cells",
`25` = "Other cells", `26` = "Smooth muscle cells",
`27` = "Other cells", `28` = "Other cells")
Idents(gd15.5) <- factor(Idents(gd15.5), levels = c("Other cells", "Macrophage cells", "Smooth muscle cells",
"Endothelial cells", "Natural killer cells", "Invasive trophoblast cells"))
load(file = "/work/LAS/geetu-lab/hhvu/combine-test-expression1.Rdata")
ratHumanOrthologs <- dataset$GRCH38$ratHumanOrthologs
humanGeneMapping <- dataset$GRCH38$humanGeneMapping
genes <- rownames(gd15.5@assays$RNA@data)
genes <- toupper(genes)
ratHumanOrthologs <- ratHumanOrthologs[ratHumanOrthologs$Gene.name %in% genes,]
d <- gd15.5@assays$RNA@data
d <- d[toupper(rownames(d)) %in% ratHumanOrthologs$Gene.name,]
# save gene and cell names
d <- as.data.frame(d)
d$genes <- toupper(rownames(d))
d <- inner_join(d, ratHumanOrthologs[,c("Gene.name", "Human.gene.name")], by = c("genes" = "Gene.name"))
rownames(d) <- d$Human.gene.name
d <- d[,1:(ncol(d)-2)]
write(x = rownames(d), file = "/work/LAS/geetu-lab/hhvu/project3_scATAC/scRNA-seq-analysis/8_cellphonedb/gd15.5features.tsv")
write(x = colnames(d), file = "/work/LAS/geetu-lab/hhvu/project3_scATAC/scRNA-seq-analysis/8_cellphonedb/gd15.5barcodes.tsv")
write.table(d, "/work/LAS/geetu-lab/hhvu/project3_scATAC/scRNA-seq-analysis/8_cellphonedb/gd15.5counts.txt", sep = '\t', quote = F)
[email protected]$idents <- Idents(gd15.5)
table([email protected]$idents)
[email protected]$Cell = rownames([email protected])
df <- [email protected][, c('Cell', 'idents')]
write.table(df, file ='/work/LAS/geetu-lab/hhvu/project3_scATAC/scRNA-seq-analysis/8_cellphonedb/gd15.5_meta.tsv', sep = '\t', quote = F, row.names = F)
```
For gd19.5:
```{r, eval=F}
load("/work/LAS/geetu-lab/hhvu/project3_scATAC/scRNA-seq-analysis/3_cluster_DEG/rmChrMTgenes/GD19.5/gd19.5-4-5-6-7_res0.8.rda")
gd19.5 <- data2
gd19.5 <- RenameIdents(gd19.5, `0` = "Other cells", `1` = "Macrophage cells",
`2` = "Other cells", `3` = "Other cells", `4` = "Other cells",
`5` = "Other cells", `6` = "Invasive trophoblast cells",
`7` = "Macrophage cells", `8` = "Smooth muscle cells",
`9` = "Natural killer cells", `10` = "Endothelial cells",
`11` = "Macrophage cells", `12` = "Other cells",
`13` = "Other cells", `14` = "Macrophage cells",
`15` = "Other cells", `16` = "Other cells",
`17` = "Macrophage cells", `18` = "Macrophage cells",
`19` = "Other cells", `20` = "Endothelial cells",
`21` = "Other cells", `22` = "Other cells",
`23` = "Other cells", `24` = "Other cells",
`25` = "Other cells", `26` = "Smooth muscle cells")
Idents(gd19.5) <- factor(Idents(gd19.5), levels = c("Other cells", "Macrophage cells", "Smooth muscle cells",
"Endothelial cells", "Natural killer cells", "Invasive trophoblast cells"))
DefaultAssay(gd19.5) <- "RNA"
load(file = "/work/LAS/geetu-lab/hhvu/combine-test-expression1.Rdata")
ratHumanOrthologs <- dataset$GRCH38$ratHumanOrthologs
humanGeneMapping <- dataset$GRCH38$humanGeneMapping
genes <- rownames(gd19.5@assays$RNA@data)
genes <- toupper(genes)
ratHumanOrthologs <- ratHumanOrthologs[ratHumanOrthologs$Gene.name %in% genes,]
d <- gd19.5@assays$RNA@data
d <- d[toupper(rownames(d)) %in% ratHumanOrthologs$Gene.name,]
# save gene and cell names
d <- as.data.frame(d)
d$genes <- toupper(rownames(d))
d <- inner_join(d, ratHumanOrthologs[,c("Gene.name", "Human.gene.name")], by = c("genes" = "Gene.name"))
rownames(d) <- d$Human.gene.name
d <- d[,1:(ncol(d)-2)]
write(x = rownames(d), file = "/work/LAS/geetu-lab/hhvu/project3_scATAC/scRNA-seq-analysis/8_cellphonedb/gd19.5features.tsv")
write(x = colnames(d), file = "/work/LAS/geetu-lab/hhvu/project3_scATAC/scRNA-seq-analysis/8_cellphonedb/gd19.5barcodes.tsv")
write.table(d, "/work/LAS/geetu-lab/hhvu/project3_scATAC/scRNA-seq-analysis/8_cellphonedb/gd19.5counts.txt", sep = '\t', quote = F)
[email protected]$idents <- Idents(gd19.5)
table([email protected]$idents)
[email protected]$Cell = rownames([email protected])
df <- [email protected][, c('Cell', 'idents')]
write.table(df, file ='/work/LAS/geetu-lab/hhvu/project3_scATAC/scRNA-seq-analysis/8_cellphonedb/gd19.5_meta.tsv', sep = '\t', quote = F, row.names = F)
```
Installation and loading the environment for CellphoneDB:
```{BASH, eval=F}
module load miniconda3/4.3.30-qdauveb
conda create -n cpdb python=3.7
module load gcc/7.3.0-xegsmw4
module load r/4.0.2-py3-icvulwq
pip install cellphonedb
module load miniconda3/4.3.30-qdauveb
module load gcc/7.3.0-xegsmw4
module load r/4.0.2-py3-icvulwq
source activate cpdb
source deactivate cpdb
```
Example command for running CellphoneDB:
```{BASH, eval=F}
cd /work/LAS/geetu-lab/hhvu/project3_scATAC/scRNA-seq-analysis/8_cellphonedb/
cellphonedb method statistical_analysis gd19.5_meta.tsv gd19.5counts.txt --threads=16
```