#' Create the drug set enrichment object that is used in the visualization
#'
#' @param mDrugEnrich a large matrix represents the gene expression fold change in the presence of different perturbations, either various drugs concentrations or other genetic engineering
#' @param DrugsAnnot is matrix represents the drugs annotation that contains the targets, mechanism of action , clinical phase, disease area, and indication
#' @param mFC A matrix of differential gene expression fold-change of own experiment, the rows name of the matrix must be the genes names
#' @param contr is a character string represent the two compared conditions(contrast) as it is provided from the fold-change matrix
#' @return drug set enrichment object
#' @export
#'
#' @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])
#'
getActiveDSEA <- function(mDrugEnrich, DrugsAnnot, mFC, contr = NULL) {
rownames(DrugsAnnot) <- DrugsAnnot$pert_iname
if (is.null(contr)) {
contr <- colnames(mFC)[1]
}
dr <- computePeturbEnrichment(
mFC = mFC, mDrugEnrich = mDrugEnrich, DrugsAnnot = DrugsAnnot,
methods = "GSEA", nprune = 250, contrast = contr
)
drs <- dr[["GSEA"]]
nes <- round(drs$X[, contr], 4)
pv <- round(drs$P[, contr], 4)
qv <- round(drs$Q[, contr], 4)
drug <- rownames(drs$X)
stats <- dr$stats
annot <- dr$annot
nes[is.na(nes)] <- 0
qv[is.na(qv)] <- 1
pv[is.na(pv)] <- 1
## compile results matrix
jj <- match(toupper(drug), toupper(rownames(DrugsAnnot)))
annot <- DrugsAnnot[jj, c("moa", "target")]
dt <- data.frame(drug = drug, NES = nes, pval = pv, padj = qv, annot)
sel <- which(dt$moa != "" | dt$target != "")
dts <- dt[sel, , drop = FALSE]
dsea <- list(table = dts, clust = dr$clust, stats = stats)
return(dsea)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.