Commit 22f99fae authored by Pradat Yoann's avatar Pradat Yoann
Browse files

v0.99.4 add legend 1 and legend 2 aside

parent b0d78adc
Pipeline #10621 failed with stages
in 1 minute
test_that("legend circle grob", {
scale_breaks <- seq(from=0, to=1, by=0.1)
theme <- ttheme_awesome(base_size=12,
rep_mode="col",
core_size=unit(5, "mm"),
scale_breaks=scale_breaks,
color_palette=NULL,
color_breaks=NULL)
g <- gtable_legend(d=t(scale_breaks[2:length(scale_breaks)]),
labels=scale_breaks,
widths=rep(theme$core$size, length(scale_breaks)-1),
heights=theme$core$size,
fg_fun=theme$core$fg_fun,
bg_fun=theme$core$bg_fun,
fg_params=theme$core$fg_params,
bg_params=theme$core$bg_params,
title_label="Prop of tumors with the signature",
title_gp=gpar(fontsize=8),
title_x=0.5*(length(scale_breaks)-1)*theme$core$size,
title_y=1.5*theme$core$size,
labels_gp=gpar(fontsize=6),
labels_pad=unit(-1, "mm"),
padding=theme$core$padding,
scale_breaks=theme$core$scale_breaks,
rep_mode=theme$core$rep_mode,
r_min=theme$core$scale_ratio*0.5*theme$core$size,
r_max=0.5*theme$core$size)
## add the background
expect_true(is(g, "grob"))
out <- plot_grob(g, name="legend_circle_grob.pdf", width=5, height=1)
expect_true(out$plot_success)
})
test_that("legend rect grob", {
color_palette <- c("#ffc651", "#ffa759", "#ff8962", "#ff6b6b", "#cc6999", "#9968c8", "#6767f8", "#4459ce", "#224ba5",
"#013d7c")
color_breaks <- c(0, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 25, 1e6)
theme <- ttheme_awesome(base_size=12,
rep_mode="col",
core_size=unit(5, "mm"),
color_palette=color_palette,
color_breaks=color_breaks)
fg_fun <- theme$core$bg_fun
fg_params <- theme$core$bg_params
fg_params$fill <- NULL
g <- gtable_legend(d=t(color_breaks[1:length(color_breaks)-1]),
labels=color_breaks,
widths=rep(theme$core$size, length(color_breaks)-1),
heights=theme$core$size,
fg_fun=fg_fun,
fg_params=fg_params,
bg_fun=NULL,
bg_params=NULL,
title_label="Median mut/Mb due to signature",
title_gp=gpar(fontsize=8),
title_x=0.5*(length(color_breaks)-1)*theme$core$size,
title_y=1.5*theme$core$size,
orientation="horizontal",
labels_gp=gpar(fontsize=6),
labels_pad=unit(-1, "mm"),
padding=theme$core$padding,
color_breaks=color_breaks,
color_palette=color_palette)
## add the background
expect_true(is(g, "grob"))
out <- plot_grob(g, name="legend_rect_grob.pdf", width=5, height=1)
expect_true(out$plot_success)
})
test_that("legend rect grob vertical", {
color_palette <- c("#ffc651", "#ffa759", "#ff8962", "#ff6b6b", "#cc6999", "#9968c8", "#6767f8", "#4459ce", "#224ba5",
"#013d7c")
color_breaks <- c(0, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 25, 1e6)
theme <- ttheme_awesome(base_size=12,
rep_mode="col",
core_size=unit(5, "mm"),
color_palette=color_palette,
color_breaks=color_breaks)
fg_fun <- theme$core$bg_fun
fg_params <- theme$core$bg_params
fg_params$fill <- NULL
g <- gtable_legend(d=color_breaks[1:length(color_breaks)-1],
labels=color_breaks,
widths=theme$core$size,
heights=rep(theme$core$size, length(color_breaks)-1),
fg_fun=fg_fun,
fg_params=fg_params,
bg_fun=NULL,
bg_params=NULL,
title_label="Title",
title_gp=gpar(fontsize=8),
title_y=-0.5*(length(color_breaks)-3)*(theme$core$size+theme$core$padding[1]),
title_x=2*theme$core$size,
orientation="vertical",
labels_gp=gpar(fontsize=6),
labels_pad=unit(-3, "mm"),
padding=theme$core$padding,
color_breaks=color_breaks,
color_palette=color_palette)
## add the background
expect_true(is(g, "grob"))
out <- plot_grob(g, name="legend_rect_grob_vertical.pdf", width=1, height=3)
expect_true(out$plot_success)
})
......@@ -132,9 +132,9 @@ test_that("extra table grob on pcawg works", {
dscale$n <- NULL
dscale <- column_to_rownames(.data=dscale, var="Cancer.Types")
dscale <- t(as.matrix(dscale))
rows_more <- list("name"=rownames(dscale))
rows_more <- list("Aetiology"=SBS_aetiology[SBS_aetiology$Signature %in% rownames(dscale), "Aetiology"])
scale_breaks <- seq(from=0, to=10, by=0.1)
scale_breaks <- seq(from=0, to=1, by=0.1)
dcolor <- pcawg_counts %>%
group_by(Cancer.Types) %>%
......@@ -149,6 +149,7 @@ test_that("extra table grob on pcawg works", {
color_breaks <- c(0, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 25, 1e6)
theme <- ttheme_awesome(base_size=12,
rep_mode="col",
core_size=unit(5, "mm"),
scale_breaks=scale_breaks,
color_palette=color_palette,
......@@ -159,6 +160,59 @@ test_that("extra table grob on pcawg works", {
cols_more=cols_more, rows_more=rows_more,
theme=theme)
out <- plot_grob(g, name="table_extra_grob_pcawg.pdf", width=12, height=16)
out <- plot_grob(g, name="table_extra_grob_pcawg.pdf", width=15, height=16)
expect_true(out$plot_success)
g1 <- gtable_legend(d=t(scale_breaks[2:length(scale_breaks)]),
labels=scale_breaks,
widths=rep(theme$core$size, length(scale_breaks)-1),
heights=theme$core$size,
fg_fun=theme$core$fg_fun,
bg_fun=theme$core$bg_fun,
fg_params=theme$core$fg_params,
bg_params=theme$core$bg_params,
title_label="Prop of tumors with the signature",
title_gp=gpar(fontsize=8),
title_x=0.5*(length(scale_breaks)-1)*theme$core$size,
title_y=1.5*theme$core$size,
labels_gp=gpar(fontsize=6),
labels_pad=unit(-1, "mm"),
padding=theme$core$padding,
scale_breaks=theme$core$scale_breaks,
rep_mode=theme$core$rep_mode,
r_min=theme$core$scale_ratio*0.5*theme$core$size,
r_max=0.5*theme$core$size)
out <- plot_grob(g1, name="table_extra_grob_pcawg_legend_1.pdf", width=3, height=1)
expect_true(out$plot_success)
fg_fun <- theme$core$bg_fun
fg_params <- theme$core$bg_params
fg_params$fill <- NULL
g2 <- gtable_legend(d=t(color_breaks[1:length(color_breaks)-1]),
labels=color_breaks,
widths=rep(theme$core$size, length(color_breaks)-1),
heights=theme$core$size,
fg_fun=fg_fun,
fg_params=fg_params,
bg_fun=NULL,
bg_params=NULL,
title_label="Median mut/Mb due to signature",
title_gp=gpar(fontsize=8),
title_x=0.5*(length(color_breaks)-1)*theme$core$size,
title_y=1.5*theme$core$size,
orientation="horizontal",
labels_gp=gpar(fontsize=6),
labels_pad=unit(-1, "mm"),
padding=theme$core$padding,
color_breaks=color_breaks,
color_palette=color_palette)
## add the background
expect_true(is(g2, "grob"))
out <- plot_grob(g2, name="table_extra_grob_pcawg_legend_2.pdf", width=5, height=1)
expect_true(out$plot_success)
})
test_that("text grob", {
g <- text_grob(label="test",
col="black")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment