generated from PNNL-CompBio/p3
-
Notifications
You must be signed in to change notification settings - Fork 3
/
circos_plot_summary.Rmd
169 lines (120 loc) · 4.74 KB
/
circos_plot_summary.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
---
title: "Data availability summary"
author: "Camilo Posso"
date: "03/09/2022"
output:
html_document:
code_folding: hide
toc: true
editor_options:
chunk_output_type: console
---
Making the table to use for circos plots. Must run inline for circos to work properly
```{r include=FALSE}
source("util/loading_data.R")
source("util/synapseUtil.R")
library(circlize)
library(dplyr)
load("Misc/load.combined.data 3-09-2022.RData")
# load.combined.data()
## drug data here
drug_data_counts <- functional.data %>%
select(Barcode.ID, Inhibitor, AUC) %>%
unique() %>%
group_by(Barcode.ID) %>%
summarise(total = n()) %>%
as.data.frame()
rownames(drug_data_counts) <- drug_data_counts$Barcode.ID
## WES is mutational data
samples_all <- global.data$Barcode.ID %>% unique()
samples.WES <- unique(WES.data$Barcode.ID)
samples.RNA <- unique(RNA.data$Barcode.ID)
samples.common <- intersect(samples.RNA, samples.WES)
samples_RNA_not_WES <- setdiff(samples.RNA, samples.common)
samples_WES_not_RNA <- setdiff(samples.WES, samples.common)
samples_RNA_or_WES <- union(samples.RNA, samples.WES)
samples_rest <- setdiff(samples_all, samples_RNA_or_WES)
n.common <- length(samples.common)
n.WES <- length(samples.WES)
n.RNA <- length(samples.RNA)
n.RNA_WES <- length(samples_RNA_not_WES)
n.WES_RNA <- length(samples_WES_not_RNA)
n.total <- length(samples_all)
n.complement <- n.total - n.common - n.RNA_WES - n.WES_RNA
table(meta$FLT3.ITD)
n.filler <- 0
df = data.frame(sector = c(rep("Common", n.common), rep("WES-RNA", n.WES_RNA),
rep("RNA-WES", n.RNA_WES), rep("Rest", n.complement)),
Dummyx = c(1:n.common, 1:n.WES_RNA, 1:n.RNA_WES, 1:n.complement),
Dummy1 = 1, Dummy2 = 1, Dummy3 = 1, Dummy4 = 1)
rownames(df) <- c(samples.common,
samples_WES_not_RNA,
samples_RNA_not_WES,
samples_rest)
df$sector <- factor(df$sector, levels = c("Common", "WES-RNA", "RNA-WES", "Rest"))
df$number_drugs <- drug_data_counts[rownames(df), "total"]
df <- df %>%
group_by(sector) %>%
arrange(number_drugs) %>%
ungroup(sector) %>%
arrange(sector)
df$x <- c(1:n.common, 1:n.WES_RNA, 1:n.RNA_WES, 1:n.complement)
```
## Circos plot
```{r}
setwd("./cohort_summary/")
png(file = "data_sample_summary_circos.png",
width = 5, height = 5, units = "in", res = 1200)
circos.clear()
circos.par("track.height" = 0.05, gap.degree = 0.02, start.degree = 90)
circos.initialize(df$sector, x = df$x)
circos.track(df$sector, y = df$Dummy2, ylim = c(0.5, 1.5),
panel.fun = function(x, y) {
circos.update(bg.border = "#FFFFFF")
})
chosen.colors = c(data_type_colors[[4]], data_type_colors[[4]], "#FFFFFF", "#FFFFFF")
circos.trackPoints(df$sector, df$x, df$Dummy2, cex = 0.6,
col = chosen.colors, pch = 16)
circos.track(df$sector, y = df$Dummy3, ylim = c(0.5, 1.5),
panel.fun = function(x, y) {
circos.update(bg.border = "#FFFFFF")
})
chosen.colors = c(data_type_colors[[3]], "#FFFFFF", data_type_colors[[3]], "#FFFFFF")
circos.trackPoints(df$sector, df$x, df$Dummy3, cex = 0.6,
col = chosen.colors, pch = 16)
circos.track(df$sector, y = df$Dummy4, ylim = c(0.5, 1.5),
panel.fun = function(x, y) {
circos.update(bg.border = "#FFFFFF")
})
chosen.colors = c(data_type_colors[[2]], data_type_colors[[2]],
data_type_colors[[2]], data_type_colors[[2]])
circos.trackPoints(df$sector, df$x, df$Dummy4, cex = 0.6,
col = chosen.colors, pch = 16)
circos.track(df$sector, y = df$Dummy4, ylim = c(0.5, 1.5),
panel.fun = function(x, y) {
circos.update(bg.border = "#FFFFFF")
})
chosen.colors = c(data_type_colors[[1]], data_type_colors[[1]],
data_type_colors[[1]], data_type_colors[[1]])
circos.trackPoints(df$sector, df$x, df$Dummy4, cex = 0.6,
col = chosen.colors, pch = 16)
circos.par("track.height" = 0.5)
circos.track(df$sector, y = df$number_drugs, x = df$x, ylim = c(130, 2),
panel.fun = function(x, y) {
circos.update(bg.border = "#FFFFFF")
circos.barplot(value = y, pos = x, col = "cadetblue",
border = "#FFFFFF")
})
legend("topleft", inset = c(0,0), pch = c(21, 21, 21, 21),
legend = c("Global", "Phospho", "RNA", "WES"),
col = data_type_colors,
pt.bg = data_type_colors,
bty = "n")
dev.off()
```
## Push to synapse
```{r}
source("../util/make_plots_util.R")
## Uploading to the analysis folder, as this is an introductory summary figure
upload.plot("data_sample_summary_circos.png", parentId = "syn26524060")
```