Description Usage Arguments Details Value Author(s) Examples
View source: R/plot_all_NG_biomarkers.R
Save a forestplot of all Nightingale biomarker associations in a 2-page,
predefined layout (utilizes forestplot
).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | plot_all_NG_biomarkers(
df,
machine_readable_name = machine_readable_name,
name = NULL,
estimate = estimate,
se = se,
pvalue = NULL,
colour = NULL,
shape = NULL,
logodds = FALSE,
psignif = 0.05,
ci = 0.95,
filename = NULL,
paperwidth = 15,
paperheight = sqrt(2) * paperwidth,
xlims = NULL,
layout = "2020",
...
)
|
df |
A data frame with the data to plot. It must contain at least three
variables, a character column with the names to be displayed on the y-axis
(see parameter |
machine_readable_name |
the variable in df containing the machine
readable names of Nightingale blood biomarkers. I.e. the names in this
variable must be the same as in the |
name |
the variable in |
estimate |
the variable in |
se |
the variable in the |
pvalue |
the variable in |
colour |
the variable in |
shape |
the variable in |
logodds |
logical (defaults to FALSE) specifying whether the |
psignif |
numeric, defaults to 0.05. The p-value threshold
for statistical significance. Entries with larger than |
ci |
A number between 0 and 1 (defaults to 0.95) indicating the type of confidence interval to be drawn. |
filename |
a character string giving the name of the file. |
paperwidth |
page width in inches |
paperheight |
page height in inches |
xlims |
NULL or a numeric vector of length 2 specifying the common x limits across all biomarker subgroups. |
layout |
one of the predefined layouts in |
... |
|
The function uses a custom grouping specified by
df_grouping_all_NG_biomarkers
. The input df
and
df_grouping_all_NG_biomarkers
are joined by machine_readable_name
,
while another df
variable may be used for y-axis labels, defined in
name
input parameter.
If filename is NULL, a list of plot objects (one for each page in layout) is returned.
Maria Kalimeri, Ilari Scheinin, Vilma Jagerroos
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | ## Not run:
# Join the built-in association demo dataset with a variable that contains
# the machine readable names of Nightingale biomarkers. (Note: if you
# have built your association data frame using the Nightingale CSV result file,
# then your data frame should already contain machine readable names.)
df <-
df_linear_associations %>%
left_join(
select(
df_NG_biomarker_metadata,
name,
machine_readable_name
),
by = "name"
)
# Print effect sizes for Nightingale biomarkers in a 2-page pdf
plot_all_NG_biomarkers(
df = df,
machine_readable_name = machine_readable_name,
# Notice that when name is not defined explicitly, names from
# df_NG_biomarker_metadata are used
estimate = beta,
se = se,
pvalue = pvalue,
colour = trait,
filename = "biomarker_linear_associations.pdf",
xlab = "1-SD increment in BMI
per 1-SD increment in biomarker concentration",
layout = "2016"
)
# Custom layout can also be provided
layout <- df_NG_biomarker_metadata %>%
dplyr::filter(
.data$group == "Fatty acids",
.data$machine_readable_name %in% df$machine_readable_name
) %>%
dplyr::mutate(
group_custom = .data$subgroup,
column = dplyr::case_when(
.data$group_custom == "Fatty acids" ~ 1,
.data$group_custom == "Fatty acid ratios" ~ 2
),
page = 1
) %>%
dplyr::select(
.data$machine_readable_name,
.data$group_custom,
.data$column,
.data$page
)
plot_all_NG_biomarkers(
df = df,
machine_readable_name = machine_readable_name,
# Notice that when name is not defined explicitly, names from
# df_NG_biomarker_metadata are used
estimate = beta,
se = se,
pvalue = pvalue,
colour = trait,
xlab = "1-SD increment in BMI
per 1-SD increment in biomarker concentration",
layout = layout
)
# log odds for type 2 diabetes
df <-
df_logodds_associations %>%
left_join(
select(
df_NG_biomarker_metadata,
name,
machine_readable_name
),
by = "name"
) %>%
# Set the study variable to a factor to preserve order of appearance
# Set class to factor to set order of display.
dplyr::mutate(
study = factor(
study,
levels = c("Meta-analysis", "NFBC-1997", "DILGOM", "FINRISK-1997", "YFS")
)
)
# Print effect sizes for Nightingale biomarkers in a 2-page pdf
plot_all_NG_biomarkers(
df = df,
machine_readable_name = machine_readable_name,
# Notice that when name is not defined explicitly, names from
# df_NG_biomarker_metadata are used
estimate = beta,
se = se,
pvalue = pvalue,
colour = study,
logodds = TRUE,
filename = "biomarker_t2d_associations.pdf",
xlab = "Odds ratio for incident type 2 diabetes (95% CI)
per 1−SD increment in metabolite concentration",
layout = "2016",
# Restrict limits as some studies are very weak and they take over the
# overall range.
xlims = c(0.5, 3.2)
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.