R/plotMOA.R

Defines functions plotMOA

Documented in plotMOA

#' Plot mechanism of action
#'
#' @param dsea is dsea object which is the output of the function getActiveDSEA()
#' @param ntop the number of the top enteries (genes or drug), ntop = 16 as a default value
#'
#' @return plot of mechanism of action
#' @export
#' @import utils
#' @import graphics
#'
#' @examples # from the data-sets provided as examples within the package load the .rda files
#' # DrugsAnnot, mDrugEnrich, mFC
#' dsea <- getActiveDSEA(mDrugEnrich, DrugsAnnot, mFC, contr = colnames(mFC)[1])
#' plotMOA(dsea)


plotMOA <- function(dsea, ntop = 16) {
  moa <- getMOA(dsea)
  res <- moa$drugClass

  jj <- unique(c(utils::head(order(-res$NES), ntop), utils::tail(order(-res$NES), ntop)))
  moa.top <- res$NES[jj]
  names(moa.top) <- res$pathway[jj]
  par(mfrow = c(2, 1), mar = c(3.5, 4, 3.5, 3.5), mgp = c(2.5, 1, 0.5), cex=1)
  graphics::barplot(moa.top,
    horiz = FALSE, las = 3,
    ylab = "Enrichment score  (NES)",
    main = "Mechanism of action",
    cex.names = 1.1
  )
}
bigomics/SPACEconnect documentation built on March 19, 2022, 3:39 a.m.