Description Usage Arguments Examples
View source: R/03-venn-diagram-function.r
This function produces a Venn diagram showing the treatment effect size of subgroups defined by sets from the categories of covariates. Also, it prints out the minimum and maximum of the treatment effect size on the console so as to set an approapriate range for effect size on the colour strip . Note that there are two options of graphical display; whether show the subgroup effect size of the complement of the union of all the considered subgroups or not. In addition, this function only works up to 5 sets and does not run an area-proportional algorithms for displaying two or three set. In addition, the function uses log odd ratio and log hazard ratio for displaying subgroup effect sizes in binary and survival data, respectively.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | plot_venn(
dat,
covari.sel,
cat.sel,
trt.sel,
resp.sel,
outcome.type,
fill = TRUE,
range.strip = c(-6, 6),
n.brk = 13,
n.brk.axis = 7,
effect = "HR",
show.overall = TRUE,
palette = "divergent",
col.power = 0.5,
font.size = c(1, 1.5, 1, 0.9, 1, 1),
title = NULL,
strip = NULL,
prop_area = FALSE,
cat.dist = "default",
grid.newpage = TRUE
)
|
dat |
a data set |
covari.sel |
a vector of indices of covariates |
cat.sel |
a vector of indices of the categories for each covariate |
trt.sel |
a covariate index specifying the treatment code |
resp.sel |
a covariate index specifying the response variable |
outcome.type |
a string specifying the type of the response variable, it can be "continuous", or "binary" or "survival". |
fill |
A logical indicating whether to use color for treatment effects |
range.strip |
a vector with two elements specifying the range of treatment effect size for display |
n.brk |
a number specifying the number of the points dividing the range of the argument "range.strip". |
n.brk.axis |
a number specifying the number of breakpoints dividing the axis of the argument "range.strip". |
effect |
either "HR" or "RMST". only when outcome.type = "survival" |
show.overall |
logical. whether to show or not the overall treatment effect in the strip |
palette |
either "divergent" or "hcl" |
col.power |
to be used when palette = "hcl". see colorspace package for reference |
font.size |
a vector specifying the size of labels and text; the first element is for the main title; the second is for the category labels; the third is for the sample size labels; the fourth is for the legend text; the fifth is for the y-axis label of the colour strip; the sixth is for the unit label on the y axis. |
title |
a string specifying the main title. |
strip |
a string specifying the title of the colour strip. |
prop_area |
A logical indicating whether to make the areas approximately proportional to the set size |
cat.dist |
A vector (length same as covari.sel) giving the distances (in npc units) of the category names from the edges of the circles (can be negative) |
grid.newpage |
logical. If TRUE (default), the function calls grid::grid.newpage() to start from an empty page. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | library(dplyr)
# Load the data to be used
data(prca)
## 3.a Venn Diagram -----------------------------------------------------------
dat <- prca
dat %>%
rename(Performance = pf,
`Bone\nmetastasis` = bm,
`History of\ncardiovascular\nevents` = hx) -> dat
plot_venn(dat,
covari.sel = c(5, 7, 4),
cat.sel = c(2,2,2),
trt.sel = 3,
resp.sel = c(1,2),
outcome.type = "survival",
fill = FALSE,
cat.dist = c(0.04,0.04,0.07),
font.size = c(0.5, 0.5, 0.7, 0.5, 0.6, 0.6))
## 3.b Filled Venn Diagram -----------------------------------------------------------
dat <- prca
dat$age1 = factor(dat$age1)
dat %>%
rename(Stage = stage,
Performance = pf,
`Bone\nmetastasis` = bm,
`History of\ncardiovascular\nevents` = hx) -> dat
plot_venn(dat,
covari.sel = c(4,6,7,5),#vars,
cat.sel = c(2,2,2,2),
trt.sel = 3,
resp.sel = c(1,2),
outcome.type = "survival",
fill = TRUE,
range.strip = c(-3, 3),
n.brk = 31, n.brk.axis = 7,
font.size = c(0.5, 0.5, 0.7, 0.5, 0.6, 0.6),
strip = paste("Treatment effect size (log hazard ratio)"),
palette = "hcl")
## 3.c Area-proportional Venn Diagram -------------------------------------------------------------
dat <- prca
plot_venn(dat,
covari.sel = c(5,7,4),
cat.sel = c(2,2,2),
trt.sel = 3,
resp.sel = c(1,2),
outcome.type = "survival",
fill = TRUE,
range.strip = c(-3, 3),
n.brk = 31, n.brk.axis = 7,
font.size = c(0.5, 0.5, 0.7, 0.5, 0.6, 0.6),
strip = paste("Treatment effect size (log hazard ratio)"),
palette = "hcl", prop_area = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.