-
Notifications
You must be signed in to change notification settings - Fork 1
/
mammal_orders_graph.R
40 lines (37 loc) · 1.09 KB
/
mammal_orders_graph.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
#load matchup of disease to bacterial species and GMPD traits
# load("df_parasite.Rdata")
load("df_all.Rdata")
df = df_all
unique(df$Label)#check that all are 1
dim(df)[1]
inds_human = which(df$Spp == "Homo sapiens")
df$Order = as.character(df$Order)
df$Order[inds_human]="Human"
df = df[,c("Spp",
"disease",
"pathogen",
"Order",
"Label")]
df = unique(df)
dim(df)[1]
size = 14
df$Label = factor(df$Label)
plot <- ggplot(df, alpha = 0.2,
aes(x = Order, group = Label, fill = Label))+
geom_bar(stat="count", position='dodge')+
theme(axis.text.x = element_text(angle = 90, hjust = 1,
vjust = 0.5, size =size))+
guides(fill=guide_legend(title="Pathogen host"))
# plot <- ggplot(df,
# aes(x = Order, fill=Label))+
# geom_bar(stat="identity", color = "black", size = 0.2,
# position=position_dodge()) +
# #
# #
# # geom_histogram(stat = "count")+
# ylab("count of host-pathogen pairs")+
# xlab("host order")+
#
plot
ggsave(filename = "host_order.jpg",
plot = plot)