R/plot_components.R

Defines functions plot_components

Documented in plot_components

#' @title plot_components
#'
#' @description A function for displaying the component plots: Variables
#  (columns) and observations (rows) both.
#'
#' @param ca_obj The CA object returned by ExPosition.
#'
#' @examples
#' # Using tcga_metadata from package.
#' library(MetaConIdentifier)
#' ca_info <- run_ca(tcga_meta_clean)
#'
#' # Plot the matrix of factor scores as a heatmap to visualize which
#' # groups of observations are contributing the most to each factor.
#'
#' # Get the component plots for the variables and observations both.
#' plot_components(ca_info$ca_obj)
#'
#'
#' @export
#' @importFrom ExPosition epGraphs
#'
plot_components <- function(ca_obj){
  if (!any(class(ca_obj) == "expoOutput")){
    stop("ca_obj is not an ExPosition object. Cannot display plot components.")
  }

  # Display component plots.
  component_plots <- ExPosition::epGraphs(ca_obj, contributionPlots = FALSE)
  print(component_plots)

  return (invisible(NULL))
}

# [END]
ahnjedid/MetaConIdentifier documentation built on Dec. 18, 2021, 11:26 p.m.