diff --git a/R/firstlib.R b/R/firstlib.R index 89ae2e2..e0b3685 100644 --- a/R/firstlib.R +++ b/R/firstlib.R @@ -1,17 +1,17 @@ .onAttach <- function (lib, pkg) { ver <- read.dcf(file.path(lib,pkg,"DESCRIPTION"),"Version") ver <- as.character(ver) packageStartupMessage("\nchallengeR ", ver, - " loaded. \n\n", + " loaded. \n", # "Note: Layouting in case of many algorithms or tasks is not yet optimized. Please be patient, we are steadily working on improving the package", - "\n\nPlease cite as:\n Wiesenfarth, M., Reinke, A., Landman, B.A., Cardoso, M.J., Maier-Hein, L. and Kopp-Schneider, A. (2019). Methods and open-source toolkit for analyzing and visualizing challenge results. arXiv preprint arXiv:1910.05121\n\n", + "\nPlease cite as:\n Wiesenfarth, M., Reinke, A., Landman, B.A., Cardoso, M.J., Maier-Hein, L. and Kopp-Schneider, A. (2019). Methods and open-source toolkit for analyzing and visualizing challenge results. arXiv preprint arXiv:1910.05121\n", domain = NULL, appendLF = TRUE) } .onLoad <- function(...) { } .onUnload <- function (libpath) { } diff --git a/R/violin.R b/R/violin.R index 72e91cf..d66feda 100644 --- a/R/violin.R +++ b/R/violin.R @@ -1,91 +1,91 @@ violin <- function(x,...) UseMethod("violin") violin.default <- function(x, ...) stop("not implemented for this class") violin.bootstrap.list=function(x,...){ ken=melt(kendall.bootstrap.list(x)) colnames(ken)[2]="Task" - cat("\n\nSummary Kendall's tau\n") + cat("\n\nSummary Kendall's tau:\n") ss=ken%>%group_by(Task)%>% summarise(mean=mean(value,na.rm=T), median=median(value,na.rm=T), q25=quantile(value,probs = .25,na.rm=T), q75=quantile(value,probs = .75,na.rm=T))%>% arrange(desc(median)) - print(as.data.frame(ss)) + print(knitr::kable(as.data.frame(ss))) # drop task if no kendall could be computed noResults <- sapply(split(ss,ss$Task), function(x) all(is.na(x[,-1]))) if (any(noResults)) { - message("No Kendall's tau could be calculated for any bootstrap sample in task ", + cat("\nNo Kendall's tau could be calculated for any bootstrap sample in task ", names(noResults)[noResults], - " because of missing variability. Task dropped from figure.") + " because of missing variability. Task dropped from figure.",fill=F) ken <- ken %>% filter(Task %in% names(noResults)[!noResults]) } xAxisText <- element_blank() # Show task names as tick mark labels only for multi-task data set if (length(x$data) > 1) { xAxisText <- element_text(angle = 90, vjust = 0.5, hjust = 1) } ken%>%mutate(Task=factor(.data$Task, levels=ss$Task))%>% ggplot(aes(Task,value))+ geom_violin(alpha=.3, color=NA, na.rm=TRUE, fill="blue")+ geom_boxplot(width=0.1, na.rm=TRUE, fill="white")+ theme(axis.text.x = xAxisText, legend.position = "none")+ ylab("Kendall's tau")+ scale_y_continuous(limits=c(min(min(ken$value),0), max(max(ken$value),1))) } kendall.bootstrap.list=function(x){ ken=lapply(1:length(x$bootsrappedRanks),function(Task){ id=match(rownames( x$bootsrappedRanks[[Task]]), rownames(x$matlist[[Task]]) ) sapply(x$bootsrappedRanks[[Task]], function(bootSample) suppressWarnings(kendall(bootSample, x$matlist[[Task]]$rank[id]))) } ) names(ken)=names((x$bootsrappedRanks)) if (sum(is.na(x))>0){ cat("Bootstrap samples without variability in rankings (all algorithms ranked 1) excluded.\n Frequency of such samples by task:\n",fill = T) sapply(ken,function(x) sum(is.na(x))) } return(ken) } density.bootstrap.list=function(x,...){ ken=melt(kendall.bootstrap.list(x)) colnames(ken)[2]="Task" cat("\n\nSummary Kendall's tau\n") ss=ken%>%group_by(Task)%>% summarise(mean=mean(value,na.rm=T), median=median(value,na.rm=T), q25=quantile(value,probs = .25,na.rm=T), q75=quantile(value,probs = .75,na.rm=T))%>% arrange(desc(median)) print(as.data.frame(ss)) ggplot(ken)+ geom_density(aes(value,fill=Task),alpha=.3,color=NA) } diff --git a/inst/appdir/visualizationViolinPlots.Rmd b/inst/appdir/visualizationViolinPlots.Rmd index 36e8ba3..88e075e 100644 --- a/inst/appdir/visualizationViolinPlots.Rmd +++ b/inst/appdir/visualizationViolinPlots.Rmd @@ -1,9 +1,9 @@ ## *Violin plot* for visualizing ranking stability based on bootstrapping \label{violin} The ranking list based on the full assessment data is pairwisely compared with the ranking lists based on the individual bootstrap samples (here $b=$ `r ncol(boot_object$bootsrappedRanks[[1]])` samples). For each pair of rankings, Kendall's $\tau$ correlation is computed. Kendall’s $\tau$ is a scaled index determining the correlation between the lists. It is computed by evaluating the number of pairwise concordances and discordances between ranking lists and produces values between $-1$ (for inverted order) and $1$ (for identical order). A violin plot, which simultaneously depicts a boxplot and a density plot, is generated from the results. \bigskip -```{r violin} +```{r violin, results='asis'} violin(boot_object) ```