-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDomain_architecture.R
237 lines (162 loc) · 8.79 KB
/
Domain_architecture.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
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
G122 <- read.table("/Users/rhianah/Documents/Dissertation/domain_mapping/combined_122.tsv", header = TRUE, sep = "\t")
frequency_table <- table(G122$Domain, G122$Lineage)
print(frequency_table)
df_frequency <- as.data.frame(as.table(frequency_table))
df_formatted <- df_frequency %>%
pivot_wider(names_from = Var2, values_from = Freq, values_fill = 0) %>%
arrange(Var1)
df_formatted
library(reshape2)
df_melted <- melt(df_formatted, id.vars = "Var1")
archi122 <- ggplot(df_melted, aes(x = value, y = Var1, fill = variable)) +
geom_bar(stat = "identity", position = "dodge") +
labs(title = "Orthogroup 122",
x = "Counts",
y = "Protein Domain (PFAM)",
fill = "Group") +
scale_fill_manual(values = c("orange", "blue")) +
theme(axis.text.y = element_text(hjust = 1, size = 11), # Set the y-axis label size to 12
axis.text.x = element_text(size = 12), # Set the x-axis label size to 12
plot.title = element_text(hjust = 0.5, size = 20), # Center the title and set the title size to 16
axis.title = element_text(size = 15)) # Adjust y-axis labels alignment
ggsave(filename = "/Users/rhianah/Documents/Dissertation/domain_mapping/122_archi.png", plot = archi122, width = 10, height = 8, dpi = 300)
G58 <- read.table("/Users/rhianah/Documents/Dissertation/domain_mapping/combined_58.tsv", header = TRUE, sep = "\t")
frequency_table <- table(G58$Domain, G58$Lineage)
print(frequency_table)
df_frequency <- as.data.frame(as.table(frequency_table))
df_formatted <- df_frequency %>%
pivot_wider(names_from = Var2, values_from = Freq, values_fill = 0) %>%
arrange(Var1)
df_formatted
library(reshape2)
df_melted <- melt(df_formatted, id.vars = "Var1")
arhi58 <- ggplot(df_melted, aes(x = value, y = Var1, fill = variable)) +
geom_bar(stat = "identity", position = "dodge") +
labs(title = "Orthogroup 58",
x = "Counts",
y = "Protein Domain (PFAM)",
fill = "Group") +
scale_fill_manual(values = c("orange", "blue")) +
theme(axis.text.y = element_text(hjust = 1, size = 11), # Set the y-axis label size to 12
axis.text.x = element_text(size = 12), # Set the x-axis label size to 12
plot.title = element_text(hjust = 0.5, size = 20), # Center the title and set the title size to 16
axis.title = element_text(size = 15)) # Adjust y-axis labels alignment
ggsave(filename = "/Users/rhianah/Documents/Dissertation/domain_mapping/58_archi.png", plot = arhi58, width = 10, height = 8, dpi = 300)
##73
#make into frequency table
G73 <- read.table("/Users/rhianah/Documents/Dissertation/domain_mapping/combined_73.tsv", header = TRUE, sep = "\t")
frequency_table <- table(G73$Domain, G73$Lineage)
print(frequency_table)
df_frequency <- as.data.frame(as.table(frequency_table))
df_formatted <- df_frequency %>%
pivot_wider(names_from = Var2, values_from = Freq, values_fill = 0) %>%
arrange(Var1)
df_formatted
library(reshape2)
df_melted <- melt(df_formatted, id.vars = "Var1")
archi73 <- ggplot(df_melted, aes(x = value, y = Var1, fill = variable)) +
geom_bar(stat = "identity", position = "dodge") +
labs(title = "Orthogroup 73",
x = "Counts",
y = "Protein Domain (PFAM)",
fill = "Group") +
scale_fill_manual(values = c("orange", "blue")) +
theme(axis.text.y = element_text(hjust = 1, size = 11), # Set the y-axis label size to 12
axis.text.x = element_text(size = 12), # Set the x-axis label size to 12
plot.title = element_text(hjust = 0.5, size = 20), # Center the title and set the title size to 16
axis.title = element_text(size = 15)) # Adjust y-axis labels alignment
ggsave(filename = "/Users/rhianah/Documents/Dissertation/domain_mapping/73_archi.png", plot = archi73, width = 10, height = 8, dpi = 300)
#######68
G68 <- read.table("/Users/rhianah/Documents/Dissertation/domain_mapping/combined_68.tsv", header = TRUE, sep = "\t")
frequency_table <- table(G68$Domain, G68$Lineage)
print(frequency_table)
df_frequency <- as.data.frame(as.table(frequency_table))
df_formatted <- df_frequency %>%
pivot_wider(names_from = Var2, values_from = Freq, values_fill = 0) %>%
arrange(Var1)
df_formatted
library(reshape2)
df_melted <- melt(df_formatted, id.vars = "Var1")
archi68 <- ggplot(df_melted, aes(x = value, y = Var1, fill = variable)) +
geom_bar(stat = "identity", position = "dodge") +
labs(title = "Orthogroup 68",
x = "Counts",
y = "Protein Domain (PFAM)",
fill = "Group") +
scale_fill_manual(values = c("orange", "blue")) +
theme(axis.text.y = element_text(hjust = 1, size = 11), # Set the y-axis label size to 12
axis.text.x = element_text(size = 12), # Set the x-axis label size to 12
plot.title = element_text(hjust = 0.5, size = 20), # Center the title and set the title size to 16
axis.title = element_text(size = 15)) # Adjust y-axis labels alignment
ggsave(filename = "/Users/rhianah/Documents/Dissertation/domain_mapping/68_archi.png", plot = archi68, width = 10, height = 8, dpi = 300)
#######17
G17 <- read.table("/Users/rhianah/Documents/Dissertation/domain_mapping/combined_17.tsv", header = TRUE, sep = "\t")
frequency_table <- table(G17$Domain, G17$Lineage)
print(frequency_table)
df_frequency <- as.data.frame(as.table(frequency_table))
df_formatted <- df_frequency %>%
pivot_wider(names_from = Var2, values_from = Freq, values_fill = 0) %>%
arrange(Var1)
df_formatted
library(reshape2)
df_melted <- melt(df_formatted, id.vars = "Var1")
archi17 <- ggplot(df_melted, aes(x = value, y = Var1, fill = variable)) +
geom_bar(stat = "identity", position = "dodge") +
labs(title = "Orthogroup 17",
x = "Counts",
y = "Protein Domain (PFAM)",
fill = "Group") +
scale_fill_manual(values = c("orange", "blue")) +
theme(axis.text.y = element_text(hjust = 1, size = 11), # Set the y-axis label size to 12
axis.text.x = element_text(size = 12), # Set the x-axis label size to 12
plot.title = element_text(hjust = 0.5, size = 20), # Center the title and set the title size to 16
axis.title = element_text(size = 15)) # Adjust y-axis labels alignment
ggsave(filename = "/Users/rhianah/Documents/Dissertation/domain_mapping/17_archi.png", plot = archi17, width = 10, height = 8, dpi = 300)
####orthogroup 7 and 54
G7 <- read.table("/Users/rhianah/Documents/Dissertation/domain_mapping/combined_07.tsv", header = TRUE, sep = "\t")
frequency_table <- table(G7$Domain, G7$Lineage)
print(frequency_table)
df_frequency <- as.data.frame(as.table(frequency_table))
df_formatted <- df_frequency %>%
pivot_wider(names_from = Var2, values_from = Freq, values_fill = 0) %>%
arrange(Var1)
df_formatted
library(reshape2)
df_melted <- melt(df_formatted, id.vars = "Var1")
ggplot(df_melted, aes(x = value, y = Var1, fill = variable)) +
geom_bar(stat = "identity", position = "dodge") +
labs(title = "Orthogroup 7",
x = "Counts",
y = "Protein Domain (PFAM)",
fill = "Group") +
scale_fill_manual(values = c("orange", "blue")) +
theme(axis.text.y = element_text(hjust = 1, size = 11), # Set the y-axis label size to 12
axis.text.x = element_text(size = 12), # Set the x-axis label size to 12
plot.title = element_text(hjust = 0.5, size = 20), # Center the title and set the title size to 16
axis.title = element_text(size = 15)) # Adjust y-axis labels alignment
ggsave(filename = "/Users/rhianah/Documents/Dissertation/domain_mapping/7_archi.png", plot = G73plot, width = 10, height = 8, dpi = 300)
####orthogroup 1225
G1255 <- read.table("/Users/rhianah/Documents/Dissertation/domain_mapping/combined_1255.tsv", header = TRUE, sep = "\t")
frequency_table <- table(G1255$Domain, G1255$Lineage)
print(frequency_table)
df_frequency <- as.data.frame(as.table(frequency_table))
df_formatted <- df_frequency %>%
pivot_wider(names_from = Var2, values_from = Freq, values_fill = 0) %>%
arrange(Var1)
df_formatted
library(reshape2)
df_melted <- melt(df_formatted, id.vars = "Var1")
# Create the horizontal bar chart
g1255 <- ggplot(df_melted, aes(x = value, y = Var1, fill = variable)) +
geom_bar(stat = "identity", position = "dodge") +
labs(title = "Orthogroup 1255",
x = "Counts",
y = "Protein Domain (PFAM)",
fill = "Group") +
scale_fill_manual(values = c("orange", "blue")) +
theme(axis.text.y = element_text(hjust = 1, size = 11), # Set the y-axis label size to 12
axis.text.x = element_text(size = 12), # Set the x-axis label size to 12
plot.title = element_text(hjust = 0.5, size = 20), # Center the title and set the title size to 16
axis.title = element_text(size = 15)) # Adjust y-axis labels alignment
g1255
ggsave(filename = "/Users/rhianah/Documents/Dissertation/domain_mapping/1255_archi.png", plot = g1255, width = 10, height = 8, dpi = 300)