-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathboxp_root.R
More file actions
34 lines (24 loc) · 1.15 KB
/
boxp_root.R
File metadata and controls
34 lines (24 loc) · 1.15 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
boxp_root<-function(results){
res_df<-data.frame(type = character(),
Prob_Y = numeric(),
Prob_N = numeric(),
stringsAsFactors = FALSE)
row.length <- as.numeric(nrow(results[[1]]$Root_dist))
t_names <- names(results)
for(i in 1:length(results)){
df_add<-data.frame(type = t_names[i],
Prob_Y = results[[i]]$Root_dist[[1]],
Prob_N = results[[i]]$Root_dist[[2]])
res_df<-rbind(res_df, df_add, stringsAsFactors=FALSE)
}
df_melt <- melt(res_df, id.vars = "type")
df_melt <- subset(df_melt, !is.na(value))
vis <- ggplot(df_melt, aes(x=type, y=value, fill = variable)) +
geom_boxplot()+
labs(x=NULL, y = "Probability at the root")+
scale_fill_manual(name = NULL, values=c("blue", "red", "darkgrey"),
labels = c("present (Y)", "absent (N)"))+
theme(axis.text=element_text(size=10),
axis.title=element_text(size=14),
legend.text = element_text(size = 10))
return(vis)}