Skip to content

Instantly share code, notes, and snippets.

@DarwinAwardWinner
Last active May 29, 2020 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DarwinAwardWinner/21652acf017880c271e95cc2e35574f4 to your computer and use it in GitHub Desktop.
Save DarwinAwardWinner/21652acf017880c271e95cc2e35574f4 to your computer and use it in GitHub Desktop.
library(ggplot2)
library(ggrepel)
library(dplyr)
library(stringr)
library(scales)
## https://github.com/tidyverse/ggplot2/issues/980
mysqrt_trans <- function() {
trans_new("mysqrt",
transform = base::sqrt,
inverse = function(x) ifelse(x<0, 0, x^2),
domain = c(0, Inf))
}
pd <- read.table(textConnection("
MAST Wilcoxon mtd
alra 0.8 0.5 ALRA
autoimpute 0.0 0.0 AutoImpute
baynorm 0.4 0.0 bayNorm
dca 0.0 0.0 DCA
deepimpute 7.4 0.0 DeepImpute
drimpute 0.2 0.0 DrImpute
knnsmooth 0.0 0.0 kNN-smoothing
magic 0.0 0.0 MAGIC
mcimpute 0.1 0.0 mcImpute
pblr 1.4 0.0 PBLR
raw 0.0 0.5 no_imp
saver 0.0 0.0 SAVER
saverx 0.0 0.0 SAVERX
scimpute 0.6 0.0 scImpute
screcover 0.0 0.1 scRecover
scscope 0.1 1.1 scScope
scVI 0.0 0.0 scVI
viper 0.3 0.0 VIPER"))
## Initial attempt
ggplot(pd) +
aes(x = MAST, y = Wilcoxon, label = mtd, color = mtd) +
geom_point() +
geom_text_repel() +
theme_bw() +
theme(legend.position = 'none')
mult <- 0.1
pd_grouped <- pd %>%
group_by(point=paste0(MAST, ",", Wilcoxon)) %>%
summarise(MAST = MAST[1], Wilcoxon = Wilcoxon[1],
mtd = paste(mtd, collapse="\n")) %>%
mutate(xnudge = (max(MAST) - MAST) * mult,
ynudge = (max(Wilcoxon) - Wilcoxon) * mult)
ggplot(pd_grouped) +
aes(x = MAST, y = Wilcoxon, label = mtd, color = mtd) +
geom_point() +
geom_text_repel(nudge_x = pd_grouped$xnudge,
nudge_y = pd_grouped$ynudge) +
theme_bw() +
theme(legend.position = 'none') +
scale_x_continuous(trans="mysqrt") +
scale_y_continuous(trans="mysqrt")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment