#' Retrieve the Color Coded Pathway Map based on Patient Metabolomic Profile
#'
#' @param enriched.pathwayID - The pathwayID of the pathway you want the image of.
#' @param met.profile - A character vector of a patient's metabolomic profile, including KEGG IDs
#' and the associated z-score or p-value describing the level of the metabolite compared to controls.
#' @param type - Either "p-value" or "z-score".
#' @param gene.profile - Default set to NULL, meaning the default enrichment analysis only considers metabolites.
#' However, if you have gene sets of interest, too, set this parameter to a character vector of the gene names.
#' Gene IDs must be converted to Entrez Identifiers.
#' @export plot.getPathviewImage
#' @examples
#' pathway.data = plot.getPathviewImage(met.profile)
plot.getPathviewImage = function(enriched.pathwayID, met.profile, type, gene.profile=NULL) {
xml.file = system.file("extdata", sprintf("%s.xml", enriched.pathwayID), package="pathview")
#node.data=node.info(xml.file)
#plot.data.cpd=node.map(mol.data=met.profile, node.data, node.types="compound")
#cols.ts.cpd=node.color(plot.data.cpd, limit=1, bins=10)
#if (!is.null(gene.profile)) {
# path.map = node.map(mol.data=met.profile, node.data, node.types=c("gene", "compound"))
#} else {
# path.map = node.map(mol.data=met.profile, node.data, node.types="compound")
#}
nms.perturbed.mets = names(met.profile[which(met.profile>2.5)])
pathway.compounds = node.data$type[which(node.data$type=="compound")]
pathCompIDs = node.data$labels[names(pathway.compounds)]
z = met.profile[nms.perturbed.mets[which(nms.perturbed.mets %in% pathCompIDs)]]
pathview(gene.data=NULL, cpd.data=met.profile, pathway.id=enriched.pathwayID,
limit=list(cpd=median(z), gene=1), species="hsa", cpd.idtype="kegg")
filename = paste(getwd(), sprintf("%s.pathview.png", enriched.pathwayID), sep="/")
return(filename)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.