diff --git a/msd-rank-boxplots.R b/msd-rank-boxplots.R index cfd8487..09d16b0 100644 --- a/msd-rank-boxplots.R +++ b/msd-rank-boxplots.R @@ -1,101 +1,103 @@ library(rstudioapi) current_path = rstudioapi::getActiveDocumentContext()$path setwd(dirname(current_path)) library(ggplot2) +library(RColorBrewer) ########################### # Define functions ########################### mergeRanks <- function(ranking_dsc, ranking_nsd) { # Collect all ranks for both metrics allRanks <- ranking_dsc numberRanks <- length(allRanks) colnames(allRanks)[2:numberRanks] <- paste(colnames(allRanks)[2:numberRanks],"dsc",sep='_') allRanks_NSD <- ranking_nsd colnames(allRanks_NSD)[2:numberRanks] <- paste(colnames(allRanks_NSD)[2:numberRanks],"nsd",sep='_') allRanks_NSD <- allRanks_NSD[match(allRanks$Algorithm, allRanks_NSD$Algorithm),] allRanks_DSC_NSD <- cbind(allRanks, allRanks_NSD[2:numberRanks]) ### Prepare data for plotting # We need two columns, one for the algorithms, one for all ranks rankCol <- as.vector(as.matrix(allRanks_DSC_NSD[2:(numberRanks-1)])) algCol <- rep(allRanks$Algorithm,length(rankCol)/19) allRanks_plt <- data.frame(Algorithm = algCol, rank = rankCol) return(allRanks_plt) } boxplot_rank_phases <- function(allRanksPh1, allRanksPh2) { meanRanksPh1 <- data.frame(Algorithm = allRanksPh1$Algorithm, rank = seq(1:19)) meanRanksPh2 <- data.frame(Algorithm = allRanksPh2$Algorithm, rank = seq(1:19)) # Add phase column allRanksPh1 <- cbind(allRanksPh1, rep("Development phase", 19)) colnames(allRanksPh1) <- c("Algorithm", "Rank", "Phase") allRanksPh2 <- cbind(allRanksPh2, rep("Mystery phase", 19)) colnames(allRanksPh2) <- c("Algorithm", "Rank", "Phase") # Merge phase 1 and 2 allRanks_phases <- rbind(allRanksPh1, allRanksPh2) meanRanks <- rbind(meanRanksPh1, meanRanksPh2) # Make sure ordering of algorithms is correct for plotting allRanks_phases$Algorithm <- factor(allRanks_phases$Algorithm, - levels = c("EdwardMa12593", "BCVuniandes", "RegionTec", "Lesswire1", - "AI-MED", "BUT","VST", "LfB", "A-REUMI01", "jiafucang", - "lupin", "UBIlearn", "whale", "CerebriuDIKU", "MIMI", + levels = c("EdwardMa12593", "BCVuniandes", "RegionTec", "BUT", + "Lesswire1", "AI-MED", "VST", "A-REUMI01", "LfB", "lupin", + "jiafucang", "UBIlearn", "whale", "CerebriuDIKU", "MIMI", "LS Wang's Group","K.A.V.athlon", "NVDLMED","nnU-Net")) + ggplot(allRanks_phases, aes(x=Algorithm, y=Rank, fill=Phase)) + geom_boxplot(outlier.shape=NA) + geom_point(position=position_jitterdodge(), alpha = 0.4, size=2, color = "#5e5858") + coord_flip() + theme_light() + labs(fill = "") + scale_y_discrete(limits=seq(1:19)) + xlab("Algorithm") + ylab("Ranks") + theme(axis.text.x = element_text(size = 14), axis.text.y = element_text(size = 14), axis.title = element_text(size= 16), legend.text = element_text(size = 16), legend.title = element_text(size= 14), legend.position="bottom") } ########################### # Prepare data ########################### rankingsPh1_dsc <- read.csv("rankings-per-subtask/subtask-rankings-ph1-dsc.csv") rankingsPh1_nsd <- read.csv("rankings-per-subtask/subtask-rankings-ph1-nsd.csv") rankingsPh2_dsc <- read.csv("rankings-per-subtask/subtask-rankings-ph2-dsc.csv") rankingsPh2_nsd <- read.csv("rankings-per-subtask/subtask-rankings-ph2-nsd.csv") rankingsPh1_dsc[,1] <- NULL rankingsPh1_nsd[,1] <- NULL rankingsPh2_dsc[,1] <- NULL rankingsPh2_nsd[,1] <- NULL ########################### # Both Phase Boxplots ########################### all_Ranks_ph1 <- mergeRanks(rankingsPh1_dsc, rankingsPh1_nsd) all_Ranks_ph2 <- mergeRanks(rankingsPh2_dsc, rankingsPh2_nsd) p <- boxplot_rank_phases(all_Ranks_ph1, all_Ranks_ph2) ggsave(file="rank-boxplots/RankBoxplots.png", plot=p, width=10, height=8) diff --git a/rank-boxplots/RankBoxplots.png b/rank-boxplots/RankBoxplots.png index 4aed356..8162589 100644 Binary files a/rank-boxplots/RankBoxplots.png and b/rank-boxplots/RankBoxplots.png differ