R/plot_compare_adj_list.R

Defines functions plot_compare_adj_list

#' @title Plot comparison metrics between multiple adjacencies
#' @param df a data frame generated by \code{\link{compare_adj_list}},
#' or multiple ones combined with \code{\link{rbind}}.
#' @return The plot as a ggplot object.
#' @examples
#' adj1 <- adj2 <- adj3 <- edgynode::make_adjacency(edgynode::adjacency_matrix_test_3)
#' adj2[1, 3] <- 5
#' adj3[1, 3] <- 0
#' adj1 <- edgynode::make_standard(adj1)
#' adj2 <- edgynode::make_standard(adj2)
#' adj3 <- edgynode::make_standard(adj3)
#' 
#' euclidean_distance_of_node_degrees <- metric_summary_distance(
#'   summary_fun = summary_node_degree,
#'   distance_fun = philentropy::euclidean,
#'   distance_args = list(testNA = FALSE)
#' )
#' 
#' df <- compare_adj_list(
#'   adj_list = list("adj1" = adj1, "adj2" = adj2, "adj3" = adj3), 
#'   metric = euclidean_distance_of_node_degrees
#' )
#' 
#' plot_compare_adj_list(df)
#' @export 
plot_compare_adj_list <- function(df){
  ggplot2::ggplot(df, ggplot2::aes(x = metric, y = distance, fill = metric)) +
    ggplot2::theme_minimal() +
    ggplot2::geom_violin() +
    ggplot2::geom_point(
      size = 1,
      position = ggplot2::position_jitterdodge(jitter.width = 0.75),
      alpha = 1000 / nrow(df)
    )
}
drostlab/edgynode documentation built on March 29, 2024, 10:36 a.m.