diff --git a/.travis.yml b/.travis.yml index b5f80e3..4e19cc8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ env: - R_BUILD_ARGS="--no-build-vignettes --no-manual" - R_CHECK_ARGS="--no-build-vignettes --no-manual --timings" - _R_CHECK_TIMINGS_="0" + - R_DEFAULT_INTERNET_TIMEOUT="300" r: - release diff --git a/R/ggeplot.R b/R/ggeplot.R index 779a648..c46c484 100644 --- a/R/ggeplot.R +++ b/R/ggeplot.R @@ -10,22 +10,26 @@ #' @importFrom ggplot2 qplot aes geom_rug geom_hline geom_vline annotate theme element_text element_blank element_line element_rect #' #' @export -ggeplot <- function(n, positions, x_axis, y_axis, title="") { - score <- which.max(abs(y_axis)) - qplot(x_axis, - y_axis, - main=title, - ylab="Running Enrichment Score", - xlab="Position in Ranked List of Genes", - geom="line")+ - geom_rug(data=data.frame(positions), aes(x=positions), inherit.aes=FALSE)+ - geom_hline(yintercept=0) + - geom_vline(xintercept=n/2, linetype="dotted") + - annotate("point", x=x_axis[score], y=y_axis[score], color="red") + - annotate("text", x=x_axis[score]+n/20, y=y_axis[score], label=round(y_axis[score],2)) + - annotate("point", x=x_axis[score], y=y_axis[score], color="red") + - theme(plot.title=element_text(hjust=0.5), - panel.background=element_blank(), - axis.line=element_line(color="black"), - panel.border=element_rect(color="black", fill=NA, size=1)) +ggeplot <- function(n, positions, x_axis, y_axis, title = "") { + score <- which.max(abs(y_axis)) + DF <- data.frame(x_axis = x_axis, y_axis = y_axis) + ggplot2::ggplot(DF, aes(x = x_axis, y = y_axis)) + + ggplot2::geom_line() + + ggplot2::labs( + title = title, + y = "Running Enrichment Score", + x = "Position in Ranked List of Genes" + ) + + ggplot2::geom_rug(data = data.frame(positions), aes(x = positions), inherit.aes = FALSE) + + ggplot2::geom_hline(yintercept = 0) + + ggplot2::geom_vline(xintercept = n / 2, linetype = "dotted") + + ggplot2::annotate("point", x = x_axis[score], y = y_axis[score], color = "red") + + ggplot2::annotate("text", x = x_axis[score] + n / 20, y = y_axis[score], label = round(y_axis[score], 2)) + + ggplot2::annotate("point", x = x_axis[score], y = y_axis[score], color = "red") + + ggplot2::theme( + plot.title = ggplot2::element_text(hjust = 0.5), + panel.background = ggplot2::element_blank(), + axis.line = ggplot2::element_line(color = "black"), + panel.border = ggplot2::element_rect(color = "black", fill = NA, linewidth = 1) + ) } diff --git a/R/ggvenn.R b/R/ggvenn.R index 60964eb..3853330 100644 --- a/R/ggvenn.R +++ b/R/ggvenn.R @@ -37,7 +37,7 @@ ggvenn <- function(a, b, ga, gb, title="") { paste(gb, " (", x.b, ")", sep=""))) %>% ggplot(aes(x0=x, y0=y, r=c(r.a, r.b), fill=groups)) + - geom_circle(alpha=0.3, size=0.5) + + geom_circle(alpha=0.3, linewidth=0.5) + coord_fixed() + theme_void() + theme(plot.title=element_text(hjust=0.5), diff --git a/tests/testthat/test-hyp_to_table.R b/tests/testthat/test-hyp_to_table.R index dd8d69e..b34a17b 100644 --- a/tests/testthat/test-hyp_to_table.R +++ b/tests/testthat/test-hyp_to_table.R @@ -1,22 +1,21 @@ test_that("hyp_to_table() is working", { + testdat <- readRDS(file.path(system.file("extdata", package = "hypeR"), "testdat.rds")) + gsets_obj <- testdat$gsets + rgsets_obj <- testdat$rgsets - testdat <- readRDS(file.path(system.file("extdata", package="hypeR"), "testdat.rds")) - gsets_obj <- testdat$gsets - rgsets_obj <- testdat$rgsets - - signature <- testdat$signature - experiment <- testdat$experiment - - hyp_obj <- hypeR(signature, gsets_obj) - multihyp_obj <- hypeR(experiment, rgsets_obj) - - # A single file - hyp_to_table(hyp_obj, file_path="signature.txt", sep="\t") - expect_true(file.exists("signature.txt")) - - # Multiple files within a directory - hyp_to_table(multihyp_obj, file_path="experiment", sep="\t") - expect_true(file.exists("experiment/Signature 1.txt")) - expect_true(file.exists("experiment/Signature 2.txt")) - expect_true(file.exists("experiment/Signature 3.txt")) + signature <- testdat$signature + experiment <- testdat$experiment + + hyp_obj <- hypeR(signature, gsets_obj) + multihyp_obj <- hypeR(experiment, rgsets_obj) + + # A single file + hyp_to_table(hyp_obj, file_path = "signature.txt", sep = "\t") + expect_true(file.exists("signature.txt")) + + # Multiple files within a directory + hyp_to_table(multihyp_obj, file_path = "experiment", sep = "\t") + expect_true(file.exists("experiment/Signature 1.txt")) + expect_true(file.exists("experiment/Signature 2.txt")) + expect_true(file.exists("experiment/Signature 3.txt")) })