Description Usage Arguments Value Examples
Creates customized boxplot of network measure changes across 3 network types for all ranks from Phylum to Genus for a given environment. Single or combinations of measures and ranks may also be selected. The statistical significance can be shown using stars (p.signif) or actual p-value scores (p.format).
1 | vis_comp_net_meas_boxplots2(df, met_name, meas_name_options = NULL, rank_level_options = NULL, p_label = c("p.signif", "p.format"), p_size = 2)
|
df |
Dataframe of all scores per measure, per network type, and per rank for all nodes, created from comp_by_deleting_random_knowns_t_v3 function |
met_name |
Name of environment |
meas_name_options |
Network measures to compare. If left blank, will compare all network measures (degree, betweenness, and closeness). Otherwise, can select a single measure or combination of measures. |
rank_level_options |
Classification ranks to compare. If left blank, will compare network measure changes for all ranks from Phylum to Genus. Otherwise, can select a single rank or combination of ranks |
p_label |
Label of statistical significance. Can choose between 2 options - p.signif (using stars to denote significance) or p.format (using numerical p-value to denote significance) |
p_size |
Size of statistical significance indicators. Default is 2. |
Returns boxplot ggplot object comparing network measure changes across network types for the indicated rank levels.
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 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (df, met_name, meas_name_options = NULL, rank_level_options = NULL,
p_label = c("p.signif", "p.format"), p_size = 2)
{
df = df[df$rank_level != "Kingdom" & df$rank_level != "Species",
]
if (is.null(meas_name_options) && is.null(rank_level_options)) {
g1 <- ggplot(df, aes(type, data, color = type)) + facet_grid(measure ~
rank_level, scales = "free") + geom_boxplot(outlier.shape = NA) +
ylab("Centrality score") + ggpubr::stat_compare_means(label = p_label,
size = p_size, comparisons = list(c("Original", "Without_unknown"),
c("Without_unknown", "Bootstrap"), c("Bootstrap",
"Original"))) + theme(axis.title.x = element_blank(),
axis.text.x = element_blank())
}
else if (is.null(meas_name_options) && !(is.null(rank_level_options))) {
spec_df = df[df$rank_level %in% rank_level_options, ]
g1 <- ggplot(spec_df, aes(type, data, color = type)) +
facet_grid(measure ~ rank_level, scales = "free") +
geom_boxplot(outlier.shape = NA) + theme(axis.title.x = element_blank(),
axis.text.x = element_blank()) + ggpubr::stat_compare_means(label = p_label,
size = p_size, comparisons = list(c("Original", "Without_unknown"),
c("Without_unknown", "Bootstrap"), c("Bootstrap",
"Original")))
}
else if (!(is.null(meas_name_options)) && is.null(rank_level_options)) {
spec_df = df[df$measure %in% meas_name_options, ]
g1 <- ggplot(spec_df, aes(type, data, color = type)) +
facet_grid(measure ~ rank_level, scales = "free") +
geom_boxplot(outlier.shape = NA) + theme(axis.title.x = element_blank(),
axis.text.x = element_blank()) + ggpubr::stat_compare_means(label = p_label,
size = p_size, comparisons = list(c("Original", "Without_unknown"),
c("Without_unknown", "Bootstrap"), c("Bootstrap",
"Original")))
}
else {
spec_df = df[df$measure %in% meas_name_options & df$rank_level %in%
rank_level_options, ]
g1 <- ggplot(spec_df, aes(type, data, color = type)) +
geom_boxplot(outlier.shape = NA)
if (length(meas_name_options) > 1 && length(rank_level_options) >
1) {
g1 <- g1 + facet_grid(measure ~ rank_level, scales = "free") +
ggpubr::stat_compare_means(label = p_label, size = p_size,
comparisons = list(c("Original", "Without_unknown"),
c("Without_unknown", "Bootstrap"), c("Bootstrap",
"Original"))) + theme(axis.title.x = element_blank(),
axis.text.x = element_blank())
}
else if (length(meas_name_options) > 1 && length(rank_level_options) ==
1) {
g1 <- g1 + facet_wrap(~measure, scales = "free") +
ggpubr::stat_compare_means(label = p_label, size = p_size,
comparisons = list(c("Original", "Without_unknown"),
c("Without_unknown", "Bootstrap"), c("Bootstrap",
"Original"))) + theme(axis.title.x = element_blank(),
axis.text.x = element_blank())
}
else if (length(meas_name_options) == 1 && length(rank_level_options) >
1) {
g1 <- g1 + facet_wrap(~rank_level, scales = "free") +
ggpubr::stat_compare_means(label = p_label, size = p_size,
comparisons = list(c("Original", "Without_unknown"),
c("Without_unknown", "Bootstrap"), c("Bootstrap",
"Original"))) + theme(axis.title.x = element_blank(),
axis.text.x = element_blank())
}
else if (length(meas_name_options) == 1 && length(rank_level_options) ==
1) {
g1 <- g1 + ylab(meas_name_options) + ggtitle(rank_level_options) +
ggpubr::stat_compare_means(label = p_label, comparisons = list(c("Original",
"Without_unknown"), c("Without_unknown", "Bootstrap"),
c("Bootstrap", "Original"))) + theme(axis.title.x = element_blank(),
axis.text.x = element_blank())
}
}
g1 <- g1 + ggtitle(paste(met_name, "Centrality Score Comparison",
sep = " ")) + ylab("Centrality score") + theme(plot.title = element_text(hjust = 0.5))
return(g1)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.