-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03-bm1.Rmd
More file actions
213 lines (172 loc) · 6.36 KB
/
03-bm1.Rmd
File metadata and controls
213 lines (172 loc) · 6.36 KB
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
---
title: "BM1"
output: html_document
editor_options:
chunk_output_type: console
---
The following code analysis the breast metastatic sample with metastasis to the liver and to the pleural effusion.
This works as an example on how to employ CopyKit for the analysis of multiple datasets.
# BM1
## Reading datasets
``` {r bm1_data, class.source="bg-success"}
# Running data with CopyKit for the primary breast sample
bm1_breast <-
runVarbin(
"/mnt/lab/users/dminussi/projects/CopyKit_Manuscript_Code/datasets/BM1/breast/marked_bams/",
remove_Y = TRUE
)
# Finding diploid and low-quality cells and excluding it from the copykit object
bm1_breast <- findOutliers(bm1_breast, resolution = 0.8)
bm1_breast <- findAneuploidCells(bm1_breast)
bm1_breast <- bm1_breast[, colData(bm1_breast)$outlier == FALSE]
bm1_breast <- bm1_breast[, colData(bm1_breast)$is_aneuploid == TRUE]
# Adding the tissue information to colData
colData(bm1_breast)$timepoint <- 'breast'
# ~~~~~~~~~~~~~~~~~~~~~~~
# Running data with CopyKit for the liver metastasis sample
bm1_liver <-
runVarbin(
"/mnt/lab/users/dminussi/projects/CopyKit_Manuscript_Code/datasets/BM1/liver/marked_bams/",
remove_Y = TRUE
)
# Finding diploid and low-quality cells and excluding it from the copykit object
bm1_liver <- findOutliers(bm1_liver)
bm1_liver <- findAneuploidCells(bm1_liver)
bm1_liver <- bm1_liver[, colData(bm1_liver)$outlier == FALSE]
bm1_liver <- bm1_liver[, colData(bm1_liver)$is_aneuploid == TRUE]
# Adding the tissue information to colData
colData(bm1_liver)$timepoint <- 'liver'
# Running data with CopyKit for the pleural effusion metastasis sample
bm1_pleural <-
runVarbin(
"/mnt/lab/users/dminussi/projects/CopyKit_Manuscript_Code/datasets/BM1/pleural/marked_bams/",
remove_Y = TRUE
)
# Finding diploid and low-quality cells and excluding it from the copykit object
bm1_pleural <- findOutliers(bm1_pleural)
bm1_pleural <- findAneuploidCells(bm1_pleural)
bm1_pleural <- bm1_pleural[, colData(bm1_pleural)$outlier == FALSE]
bm1_pleural <-
bm1_pleural[, colData(bm1_pleural)$is_aneuploid == TRUE]
# Adding the tissue information to colData
colData(bm1_pleural)$timepoint <- 'pleural'
```
Merging the three datasets
``` {r bm1_merging, class.source="bg-success"}
# Merging the three copykit objects
bm1_merged <- cbind(bm1_breast,
bm1_liver,
bm1_pleural)
```
From here on the analysis follow the same steps as a standard CopyKit workflow analysis.
## Running UMAP and Clustering
``` {r bm1_umap_cl, class.source="bg-success"}
bm1_merged <- runUmap(bm1_merged)
bm1_merged <- findSuggestedK(bm1_merged)
bm1_merged_suggestedk <- plotSuggestedK(bm1_merged)
bm1_merged_suggestedk
bm1_merged <- findClusters(bm1_merged)
bm1_merged <- calcConsensus(bm1_merged)
bm1_merged <- runConsensusPhylo(bm1_merged)
plotHeatmap(bm1_merged, label = c('subclones', 'timepoint'))
bm1_merged_umap_p <- plotUmap(bm1_merged, label = 'subclones')
bm1_merged_umap_p
# Cluster c3 from the pleural sample is a cluster of tumor-normal doublets
# We can subset out of the CopyKit object in a similar way to the filtering
# functions with the information from colData
bm1_merged <- bm1_merged[, colData(bm1_merged)$subclones != 'c3']
# Re-clustering the sample after doublet removal
# This sample has a smaller sample size, therefore we are reducing the
# n_neighbors parameter from the UMAP and increasing min_dist
bm1_merged <- runUmap(bm1_merged, n_neighbors = 10, min_dist = 0.1)
# Grid Search of Jaccard Similarity (cluster stability)
bm1_merged <- findSuggestedK(bm1_merged)
bm1_merged <- findClusters(bm1_merged)
# Plotting the UMAP colored by the tissue of origin from the colData information
bm1_merged_tp_umap_p <- plotUmap(bm1_merged, label = 'timepoint')
bm1_merged_tp_umap_p
# Plotting the UMAP colored by the subclones from the colData information
bm1_merged_umap_p <- plotUmap(bm1_merged, label = 'subclones')
bm1_merged_umap_p
```
## Consensus tree
To root the tree, we will use an inferred Most Recent Common Ancestral from the primary tumor and provide that as an argument to the runConsensusPhylo function.
This consensus tree will be used by plotHeatmap to order the subclones on the plot
``` {r bm1_tree, class.source="bg-success"}
# The primary sample per se has very few cells so we will add a subclone
# information to the colData to use the later inferMrca function in CopyKit
colData(bm1_breast)$subclones <- 'c1'
bm1_breast <- calcConsensus(bm1_breast)
# Inferring the MRCA on the primary breast sample
bm1_breast <- inferMrca(bm1_breast)
# calculating the consensus of the Merged dataset and using the inferred
# primary MRCA as the root of the tree
bm1_merged <- calcConsensus(bm1_merged)
bm1_merged <- runConsensusPhylo(bm1_merged,
root = 'user',
root_user = metadata(bm1_breast)$inferred_mrca)
# Rotating branches
consensusPhylo(bm1_merged) <-
ape::rotate(consensusPhylo(bm1_merged), 6)
bm1_merged_consensus_phylo <-
plotPhylo(bm1_merged, label = 'subclones', consensus = TRUE)
bm1_merged_consensus_phylo
# Calculating cophenetic distances between subclones
ape::cophenetic.phylo(consensusPhylo(bm1_merged))
```
``` {r bm1_heatmap, fig.width = 8, fig.height = 9, class.source="bg-success"}
# Plotting the copy number heatmap with annotation data from the subclones and
# the tissue of origin
plotHeatmap(bm1_merged, label = c('subclones', 'timepoint'))
```
``` {r bm1_consensus_heatmap_genes, fig.width = 9, class.source="bg-success"}
# Plotting a consensus heatmap with the plotHeatmap function.
# The annotation represents the subclones and relevant cancer genes are marked.
plotHeatmap(
bm1_merged,
label = 'subclones',
consensus = TRUE,
genes = c(
"MYC",
"MYB",
"BRCA1",
"ERBB2",
"CDH1",
"FGFR1",
"AKT2",
"CDK4",
"CCNE1",
"CCND1",
"MTOR",
"FGF10",
"BRAF",
"AURKA"
)
)
# Using the plotGeneCopy function to plot the segment ratios mean values for
# the selected genes and coloring it by the tissue of origin from the metadata
bm1_merged_gc <-
plotGeneCopy(
bm1_merged,
genes = c(
"MYC",
"MYB",
"BRCA1",
"ERBB2",
"CDH1",
"FGFR1",
"AKT2",
"CDK4",
"CCNE1",
"CCND1",
"MTOR",
"FGF10",
"BRAF",
"AURKA"
),
label = 'timepoint',
dodge.width = .8
) +
scale_fill_hue()
bm1_merged_gc
```