-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathQDNAseq_paired.R
91 lines (50 loc) · 2.53 KB
/
QDNAseq_paired.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
# file: QDNAseq.R
#library(QDNAseq, lib="/ifs/rcgroups/dxbx-cb/tools/miniconda/envs/ichorCNA/lib/R/library/")
library(QDNAseq, lib="/mnt/centers/bxdx/dxbx-cb/tools/miniconda/envs/ichorCNA/lib/R/library/")
setwd("F:/DFCI/Low_pass/")
#library(QDNAseq)
# 1. Get Bin Annotations
#bins <- readRDS("/ifs/rcgroups/dxbx-cb/shared/panels/QDNAseq/QDNAseq.hg19.100kbp.SR50.rds")
#bins <- readRDS("/mnt/centers/bxdx/dxbx-cb/shared/panels/QDNAseq/QDNAseq.hg19.100kbp.SR50.rds")
bins <- getBinAnnotations(binSize=100, genome="hg19")
#setwd(/directory with bams)
readCounts <- binReadCounts(bins, pairedEnds = T)
# 2. Calculate and plot Raw Counts of all .bam files in working directory. Plot a raw copy number profile (read counts across the genome), and highlight bins that will be removed with default filtering
#readCounts <- binReadCounts(bins,isPaired=TRUE)
exportBins(readCounts, file="raw_readCounts.txt")
pdf("Raw_read_counts.pdf")
plot(readCounts, logTransform=FALSE, ylim=c(-50, 200))
highlightFilters(readCounts, logTransform=FALSE, residual=TRUE, blacklist=TRUE)
dev.off()
# 3. Apply filters to the read counts and plot median read counts as a function of GC content and mappability
readCountsFiltered <- applyFilters(readCounts, residual=TRUE, blacklist=TRUE)
pdf("isobarPlot.pdf")
isobarPlot(readCountsFiltered)
dev.off()
readCountsFiltered <- estimateCorrection(readCountsFiltered)
pdf("noisePlot.pdf")
noisePlot(readCountsFiltered)
dev.off()
# 4. Correct bin counts for GC content and mappability
copyNumbers <- correctBins(readCountsFiltered)
copyNumbersNormalized <- normalizeBins(copyNumbers)
copyNumbersSmooth <- smoothOutlierBins(copyNumbersNormalized)
pdf("Norm_CN_plots.pdf")
plot(copyNumbersSmooth)
dev.off()
exportBins(copyNumbersSmooth, file="copyNumbers.100kb.txt")
exportBins(copyNumbersSmooth, file="copyNumbers.100kb.igv", format="igv")
# 5. Segmentation with the CBS algorithm from DNAcopy, and calling copy number aberrations with CGHcall or cutoffs
copyNumbersSegmented <- segmentBins(copyNumbersSmooth)
copyNumbersSegmented <- normalizeSegmentedBins(copyNumbersSegmented)
pdf("Segment_plots_log2.pdf",width=22*0.8,height=8*0.8)
plot(copyNumbersSegmented)
dev.off()
copyNumbersCalled <- callBins(copyNumbersSegmented)
pdf("Segment_plots_v2.pdf",width=22*0.8,height=8*0.8)
plot(copyNumbersCalled)
dev.off()
save.image(file="QDNASeq_session.RData")
exportBins(copyNumbersCalled, file="segments_called.100kb.txt", format="tsv", type = "segments")
exportBins(copyNumbersCalled, format = "seg")
save.image(file="QDNASeq_session.RData")