-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecCellFie_metrics.Rmd
More file actions
94 lines (77 loc) · 3.47 KB
/
secCellFie_metrics.Rmd
File metadata and controls
94 lines (77 loc) · 3.47 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
---
title: "R Notebook"
output: html_notebook
---
```{r}
library(data.table)
library(dplyr)
library(ggplot2)
library(RColorBrewer)
library(ggraph)
library(igraph)
library(tidyverse)
library(treemapify)
```
Load taskInfo
```{r}
#secCellFie
taskInfo.sec <- openxlsx::read.xlsx("Generate_essentialRxns_manual/essentialRxn_notebook2022.xlsx", sheet="TaskInfo")
count.system.sec <- table(taskInfo.sec$System) %>% data.table() %>% setNames(c("System", "count")) %>%
mutate(System=toupper(System)) %>%
mutate(Pathway="Secretory Pathway")
#metCellFie
# fread("CellFie/genepattern/outtmp/taskInfo.csv")
taskInfo.met <- fread("taskInfo_edit.csv") %>% setNames(colnames(taskInfo.sec))
count.system.met <- table(taskInfo.met$System) %>% data.table() %>% setNames(c("System", "count")) %>%
mutate(Pathway="Metabolic Pathway")
```
Pie chart of secretory tasks by System
```{r}
# Compute the position of labels
#count.system.sec <- count.system.sec %>%
#arrange(desc(System)) %>%
#mutate(prop=count/sum(count.system$count)*100) %>%
#mutate(ypos=cumsum(prop)- 0.5*prop) %>%
#mutate(percent=scales::percent(count/21))
ggplot(count.system.sec, aes(x="", y=count, fill=System)) +
geom_bar(stat="identity", width=1) +
#geom_text(aes(y=ypos, label= percent, size=4)) +
coord_polar("y", start=0) +
theme_void() +
scale_fill_brewer(palette="Set2")
ggsave("Figures/secCellfie_pieChart.svg", pie.system, width = 8, height = 6)
```
Treemap of ALL (met and sec) secretory subsystems
```{r}
count.system <- rbind(count.system.met, count.system.sec)
cellfie.tree <- ggplot(count.system, aes(area=count, subgroup=Pathway, subgroup2= System, fill=Pathway))+
labs(fill = "Cellfie Pathway")+
scale_fill_manual(values=c("plum1", "palegreen"))+
geom_treemap(colour="white")+
geom_treemap_subgroup2_border(colour="gray61", size=1) +
geom_treemap_subgroup_border(colour="gray61", size=4) +
#geom_treemap_subgroup_text(place="centre", grow=F, alpha=0.7, colour="gray99", min.size=0, reflow=T) +
geom_treemap_subgroup2_text(place="centre", grow=F, alpha=0.7, colour="black", min.size=0, reflow=T) +
theme(legend.title=element_text(size=15), legend.text = element_text(size=13))
ggsave("Figures/CellFie_tree.svg", cellfie.tree, width = 9, height = 6)
```
Treemap v2 (include subgroup info)
```{r}
count.system.met2 <- table(taskInfo.met$Subsystem) %>% data.table() %>% setNames(c("Subsystem", "count")) %>%
left_join(select(taskInfo.met, c("System", "Subsystem")) %>% unique()) %>%
mutate(Pathway="Metabolic Pathway")
count.system.sec2 <- table(taskInfo.sec$Subsystem) %>% data.table() %>% setNames(c("Subsystem", "count")) %>%
left_join(select(taskInfo.sec, c("System", "Subsystem")) %>% unique()) %>%
mutate(Pathway="Secretory Pathway")
count.system2 <- rbind(count.system.met2, count.system.sec2)
cellfie.tree2 <- ggplot(count.system2, aes(area=count, subgroup=System, subgroup2= Subsystem, fill=Pathway))+
labs(fill = "Cellfie Pathway")+
scale_fill_manual(values=c("#8B008B", "#008B45"))+
geom_treemap(colour="white")+
geom_treemap_subgroup2_border(colour="gray61", size=1) +
geom_treemap_subgroup_border(colour="gray61", size=4) +
geom_treemap_subgroup_text(place="centre", grow=F, alpha=1, colour="gray99", min.size=0, reflow=T) + #gray99
geom_treemap_subgroup2_text(place="top", grow=F, alpha=0.8, colour="gray27", min.size=0, reflow=T) + #gray27
theme(legend.title=element_text(size=15), legend.text = element_text(size=13))
ggsave("Figures/CellFie_tree_v2.png", cellfie.tree2, width = 9, height = 6)
```