-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3_DApeaksInNonTBC.Rmd
239 lines (207 loc) · 12.2 KB
/
3_DApeaksInNonTBC.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
---
title: "scATAC-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 scATAC-seq data, generated from rat metrial gland tissues on gestational day (GD) 15.5 and 19.5. <br>
## GD 15.5:
```{r}
library(Signac)
library(Seurat)
library(ggplot2)
library(GenomicRanges)
library(patchwork)
set.seed(1234)
load("/work/LAS/geetu-lab/hhvu/project3_scATAC/rnor6.rda")
load("/work/LAS/geetu-lab/hhvu/project3_scATAC/rnor6.ranges.rda")
load("/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd15.5-ATACwithRNAlables.rda")
Idents(rats) <- [email protected]$predicted.id # change from old identities to those predicted by scRNA-seq
DefaultAssay(rats) <- 'MACSpeaks'
Annotation(rats) <- rnor6.ranges
rats1.markers <- read.table("/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd15.5-unfilteredMarkers.txt", header = T, sep = "\t")
```
Natural killer cells:
```{r}
nk15.5 <- rats1.markers[rats1.markers$cluster == "Natural killer cells" & rats1.markers$avg_log2FC >= log2(1.5) & rats1.markers$p_val_adj <= 0.05,]
#write.table(nk15.5, "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd15.5-nk.txt", quote = F, sep = '\t')
dim(nk15.5)
closest_genes <- ClosestFeature(rats, regions = rownames(nk15.5))
length(unique(closest_genes$gene_name))
#write.table(closest_genes, "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd15.5-nk-toGenes.txt", quote = F, sep = '\t')
```
Smooth muscle cells:
```{r}
sm15.5 <- rats1.markers[rats1.markers$cluster == "Smooth muscle cells" & rats1.markers$avg_log2FC >= log2(1.5) & rats1.markers$p_val_adj <= 0.05,]
#write.table(sm15.5, "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd15.5-sm.txt", quote = F, sep = '\t')
dim(sm15.5)
closest_genes <- ClosestFeature(rats, regions = rownames(sm15.5))
length(unique(closest_genes$gene_name))
#write.table(closest_genes, "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd15.5-sm-toGenes.txt", quote = F, sep = '\t')
```
Endothelial cells:
```{r}
endo15.5 <- rats1.markers[rats1.markers$cluster == "Endothelial cells" & rats1.markers$avg_log2FC >= log2(1.5) & rats1.markers$p_val_adj <= 0.05,]
#write.table(endo15.5, "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd15.5-endo.txt", quote = F, sep = '\t')
dim(endo15.5)
closest_genes <- ClosestFeature(rats, regions = rownames(endo15.5))
length(unique(closest_genes$gene_name))
#write.table(closest_genes, "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd15.5-endo-toGenes.txt", quote = F, sep = '\t')
```
Macrophage cells:
```{r}
macro15.5 <- rats1.markers[rats1.markers$cluster == "Macrophage cells" & rats1.markers$avg_log2FC >= log2(1.5) & rats1.markers$p_val_adj <= 0.05,]
#write.table(macro15.5, "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd15.5-macro.txt", quote = F, sep = '\t')
dim(macro15.5)
closest_genes <- ClosestFeature(rats, regions = rownames(macro15.5))
length(unique(closest_genes$gene_name))
#write.table(closest_genes, "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd15.5-macro-toGenes.txt", quote = F, sep = '\t')
```
In BASH, run the following command to obtain a bed file of the peaks:
```{BASH, eval = F}
cd /work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/
for i in gd15.5-endo.txt gd15.5-macro.txt gd15.5-nk.txt gd15.5-sm.txt; do e=`echo $i | sed 's/txt/bed/g'`; cut -f 6 $i | tail -n +2 | sed 's/-/\t/g' | awk '{print $1"\t"$2"\t"$3"\t"$1"-"$2"-"$3}' > $e; done
```
We can look at the distribution of the cell type-enriched peaks. For natural killer cells (NKs):
```{r}
library(ChIPseeker)
library(GenomicFeatures)
library(RMariaDB)
txdb <- makeTxDbFromEnsembl(organism= "Rattus norvegicus", release = 98)
file <- "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd15.5-nk.bed"
peakAnno <- annotatePeak(file, tssRegion=c(-3000, 3000), TxDb=txdb)
#pdf("/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/FIGURES/20220829_draftV3/figureS3-15.5-NKs.#pdf", height = 5, width = 6)
plotDistToTSS(peakAnno,
title="Distribution of transcription factor-binding loci relative to TSS - natural killer cells GD15.5")
#dev.off()
```
Smooth muscle cells:
```{r}
file <- "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd15.5-sm.bed"
peakAnno <- annotatePeak(file, tssRegion=c(-3000, 3000), TxDb=txdb)
#pdf("/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/FIGURES/20220829_draftV3/figureS3-15.5-sm.#pdf", height = 5, width = 6)
plotDistToTSS(peakAnno,
title="Distribution of transcription factor-binding loci relative to TSS - smooth muscle cells GD15.5")
#dev.off()
```
Endothelial cells:
```{r}
file <- "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd15.5-endo.bed"
peakAnno <- annotatePeak(file, tssRegion=c(-3000, 3000), TxDb=txdb)
#pdf("/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/FIGURES/20220829_draftV3/figureS3-15.5-endo.#pdf", height = 5, width = 6)
plotDistToTSS(peakAnno,
title="Distribution of transcription factor-binding loci relative to TSS - Endothelial cells GD15.5")
#dev.off()
```
Macrophage cells:
```{r}
file <- "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd15.5-macro.bed"
peakAnno <- annotatePeak(file, tssRegion=c(-3000, 3000), TxDb=txdb)
#pdf("/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/FIGURES/20220829_draftV3/figureS3-15.5-macro.#pdf", height = 5, width = 6)
plotDistToTSS(peakAnno,
title="Distribution of transcription factor-binding loci relative to TSS - Macrophage cells GD15.5")
#dev.off()
```
## GD 19.5:
```{r}
set.seed(1234)
load("/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd19.5-ATACwithRNAlables.rda")
Idents(rats) <- [email protected]$predicted.id # change from old identities to those predicted by scRNA-seq
DefaultAssay(rats) <- 'MACSpeaks'
Annotation(rats) <- rnor6.ranges
rats1.markers <- read.table("/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd19.5-unfilteredMarkers.txt", header = T, sep = "\t")
```
Natural killer cells:
```{r}
nk19.5 <- rats1.markers[rats1.markers$cluster == "Natural killer cells" & rats1.markers$avg_log2FC >= log2(1.5) & rats1.markers$p_val_adj <= 0.05,]
#write.table(nk19.5, "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd19.5-nk.txt", quote = F, sep = '\t')
dim(nk19.5)
closest_genes <- ClosestFeature(rats, regions = rownames(nk19.5))
length(unique(closest_genes$gene_name))
#write.table(closest_genes, "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd19.5-nk-toGenes.txt", quote = F, sep = '\t')
```
Smooth muscle cells:
```{r}
sm19.5 <- rats1.markers[rats1.markers$cluster == "Smooth muscle cells" & rats1.markers$avg_log2FC >= log2(1.5) & rats1.markers$p_val_adj <= 0.05,]
#write.table(sm19.5, "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd19.5-sm.txt", quote = F, sep = '\t')
dim(sm19.5)
closest_genes <- ClosestFeature(rats, regions = rownames(sm19.5))
length(unique(closest_genes$gene_name))
#write.table(closest_genes, "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd19.5-sm-toGenes.txt", quote = F, sep = '\t')
```
Endothelial cells:
```{r}
endo19.5 <- rats1.markers[rats1.markers$cluster == "Endothelial cells" & rats1.markers$avg_log2FC >= log2(1.5) & rats1.markers$p_val_adj <= 0.05,]
#write.table(endo19.5, "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd19.5-endo.txt", quote = F, sep = '\t')
dim(endo19.5)
closest_genes <- ClosestFeature(rats, regions = rownames(endo19.5))
length(unique(closest_genes$gene_name))
#write.table(closest_genes, "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd19.5-endo-toGenes.txt", quote = F, sep = '\t')
```
Macrophage cells:
```{r}
macro19.5 <- rats1.markers[rats1.markers$cluster == "Macrophage cells" & rats1.markers$avg_log2FC >= log2(1.5) & rats1.markers$p_val_adj <= 0.05,]
#write.table(macro19.5, "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd19.5-macro.txt", quote = F, sep = '\t')
dim(macro19.5)
closest_genes <- ClosestFeature(rats, regions = rownames(macro19.5))
length(unique(closest_genes$gene_name))
#write.table(closest_genes, "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd19.5-macro-toGenes.txt", quote = F, sep = '\t')
```
In BASH, run the following command to obtain a bed file of the TBC peaks:
```{BASH, eval = F}
cd /work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/
for i in gd19.5-endo.txt gd19.5-macro.txt gd19.5-nk.txt gd19.5-sm.txt; do e=`echo $i | sed 's/txt/bed/g'`; cut -f 8 $i | tail -n +2 | sed 's/-/\t/g' | awk '{print $1"\t"$2"\t"$3"\t"$1"-"$2"-"$3}' > $e; done
```
We can look at the distribution of the cell type-enriched peaks. For natural killer cells (NKs):
```{r}
file <- "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd19.5-nk.bed"
peakAnno <- annotatePeak(file, tssRegion=c(-3000, 3000), TxDb=txdb)
#pdf("/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/FIGURES/20220829_draftV3/figureS3-19.5-NKs.#pdf", height = 5, width = 6)
plotDistToTSS(peakAnno,
title="Distribution of transcription factor-binding loci relative to TSS - natural killer cells GD19.5")
#dev.off()
```
Smooth muscle cells:
```{r}
file <- "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd19.5-sm.bed"
peakAnno <- annotatePeak(file, tssRegion=c(-3000, 3000), TxDb=txdb)
#pdf("/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/FIGURES/20220829_draftV3/figureS3-19.5-sm.#pdf", height = 5, width = 6)
plotDistToTSS(peakAnno,
title="Distribution of transcription factor-binding loci relative to TSS - smooth muscle cells GD19.5")
#dev.off()
```
Endothelial cells:
```{r}
file <- "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd19.5-endo.bed"
peakAnno <- annotatePeak(file, tssRegion=c(-3000, 3000), TxDb=txdb)
#pdf("/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/FIGURES/20220829_draftV3/figureS3-19.5-endo.#pdf", height = 5, width = 6)
plotDistToTSS(peakAnno,
title="Distribution of transcription factor-binding loci relative to TSS - Endothelial cells GD19.5")
#dev.off()
```
Macrophage cells:
```{r}
file <- "/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/4_RNAintegration/2_MACS2Peaks/annotation_scRNAseq/gd19.5-macro.bed"
peakAnno <- annotatePeak(file, tssRegion=c(-3000, 3000), TxDb=txdb)
#pdf("/work/LAS/geetu-lab/hhvu/project3_scATAC/scATAC-seq-analysis/FIGURES/20220829_draftV3/figureS3-19.5-macro.#pdf", height = 5, width = 6)
plotDistToTSS(peakAnno,
title="Distribution of transcription factor-binding loci relative to TSS - Macrophage cells GD19.5")
#dev.off()
```
```{r}
sessionInfo()
```