-
Notifications
You must be signed in to change notification settings - Fork 0
/
HGSOC_SE_Peak_Overlap.R
59 lines (43 loc) · 1.87 KB
/
HGSOC_SE_Peak_Overlap.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
########################
# Matt Regner
# Nov 2021
# SE overlap
########################
# Full processed scRNA-seq data was generated in the following directory:
# /datastore/nextgenout5/share/labs/francolab/scENDO_scOVAR_Proj/scRNA-seq_Processing/HGSOC_RNA
# Fully processed scATAc-seq data was generated in the following directory:
# /datastore/nextgenout5/share/labs/francolab/scENDO_scOVAR_Proj/scATAC-seq_Processing/HGSOC_ATAC_March_2021-v3
library(ArchR)
library(GenomicRanges)
set.seed(1234)
addArchRGenome(genome="hg38")
addArchRThreads(threads = 16)
###########################
# Subset archr project and call peaks in the malignant fraction
###########################
proj <- readRDS("./final_archr_proj_archrGS.rds")
levels(factor(proj$predictedGroup_ArchR))
malignant <- c("0-Epithelial cell","2-Epithelial cell","3-Epithelial cell","7-Epithelial cell","11-Epithelial cell","16-Epithelial cell"
)
idxSample <- BiocGenerics::which(proj$predictedGroup_ArchR %in% malignant)
cellsSample <- proj$cellNames[idxSample]
proj <- proj[cellsSample, ]
# Find path to Macs2
pathToMacs2 <- findMacs2()
# Add peakset according to predicted labels
proj <- addGroupCoverages(ArchRProj = proj, groupBy = "predictedGroup_ArchR",force = T)
proj <- addReproduciblePeakSet(
ArchRProj = proj,
groupBy = "predictedGroup_ArchR",
pathToMacs2 = pathToMacs2,
force=T
)
proj <- addPeakMatrix(proj,force=T)
peaks.gr <- getPeakSet(proj)
saveRDS(peaks.gr,"HGSOC_Malignant_Enriched_Peaks_GRanges.rds")
peaks.mat <- getMatrixFromProject(ArchRProj = proj,useMatrix = "PeakMatrix")
saveRDS(peaks.mat,"HGSOC_Malignant_Enriched_Peak_Matrix.rds")
peaks.gr <- data.frame(chrom = peaks.gr@seqnames,
ranges = peaks.gr@ranges)
colnames(peaks.gr) <- c("seq","start","end","width","cluster")
write.table(peaks.gr[,1:3],"PeaksOpenInPrimaryTumors.bed",sep = "\t",col.names =F,row.names = F,quote = T)