Repository navigation
Expand file tree
/
Copy path11-scCUTseq_brca-phylo.Rmd
More file actions
85 lines (60 loc) · 2.29 KB
/
Copy path11-scCUTseq_brca-phylo.Rmd
File metadata and controls
85 lines (60 loc) · 2.29 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
# Phylogenetic analysis of breast cancer
This sections produces all the figures used in Supplementary Figure 10.
```{r}
# Source setup file
source("./functions/setup.R")
# Load functions
source("./functions/plotHeatmap.R")
```
## Performing phylogenetic analysis
We performed phylogenetic analysis of the single-cells of two breast cancer samples using MEDICC2. The input for this the total copy number profiles and the following command was used to run this.
```{bash performing phylo analysis, eval = FALSE}
medicc2 --plot none -j {nthreads} --total-copy-numbers -a 'total_cn' {input_tsv} {output_dir}
```
## Plotting phylogenetic tree and heatmap
We then plot the tree generated by MEDICC2 alongside the single-cell genomewide heatmap. First we plot sample 1.
```{r plot trees and heatmap brca1, fig.width=22, fig.height=14}
# Load in brca1 data
tree = read.tree("./data/phylotrees/brca1_500kb.new")
input = fread("./data/phylotrees/brca1_input.tsv")
# Reorder
dt = dcast(input, chrom + start + end ~ sample_id)
dt = dt[gtools::mixedorder(chrom),]
# Rename column and set chr23 back to chrX
setnames(dt, "chrom", "chr")
dt[chr == "chr23", chr := "chrX"]
# include diploid
dt[, diploid := 2L]
dt[chr == "chrX", diploid := 1L]
# Plot tree
tree_plot = ggtree(tree)
# Get sample order from tree
col_order = rev(get_taxa_name(tree_plot))
# Plot heatmap
heatmap = plotHeatmap(dt[, 4:ncol(dt)], dt[, 1:3], dendrogram = F, order = col_order, linesize = .75)
# Combine plots
tree_plot + heatmap + plot_layout(widths = c(1, 3))
```
Next, we do the same but for sample 2.
```{r plot trees and heatmap brca2, fig.width=22, fig.height=8}
# Load in brca1 data
tree = read.tree("./data/phylotrees/brca2_500kb.new")
input = fread("./data/phylotrees/brca2_input.tsv")
# Reorder
dt = dcast(input, chrom + start + end ~ sample_id)
dt = dt[gtools::mixedorder(chrom),]
# Rename column and set chr23 back to chrX
setnames(dt, "chrom", "chr")
dt[chr == "chr23", chr := "chrX"]
# include diploid
dt[, diploid := 2L]
dt[chr == "chrX", diploid := 1L]
# Plot tree
tree_plot = ggtree(tree)
# Get sample order from tree
col_order = rev(get_taxa_name(tree_plot))
# Plot heatmap
heatmap = plotHeatmap(dt[, 4:ncol(dt)], dt[, 1:3], dendrogram = F, order = col_order, linesize = .75)
# Combine plots
tree_plot + heatmap + plot_layout(widths = c(1, 3))
```