knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This vignette demonstrates how to specify the color maps and use data layers by creating a NG-CHM from 2 data layers: a layer from the unadjusted data, and another from row-centering that data. Each layer will have its own custom color map.
Color maps are created with chmNewColorMap()
. The first argument to this function
is a list of breakpoints. For the TCGA.BRCA.ExpressionData demo data, reasonable breakpoints are
6.4, 10, and 14. The second argument is a corresponding list of
colors for those breakpoints. The colors can be specified by name for standard colors, or by hexadecimal code.
For the unadjusted data color map:
library(NGCHM) unadjustedColorMap <- chmNewColorMap(c(6.4,10,14), c('mediumblue','snow','firebrick'))
For the second color map to be used with row-centered data, breakpoints are set at -2, 0, and 2. For the purpose of illustration, the hexidecimal code is used for specifying the color.
rowCenteredColorMap <- chmNewColorMap(c(-2,0,2), c('#9933ff','#f0f0f0','#228B22'))
Data layers can be created with the chmNewDataLayer()
function. The first argument is the desired name
of the data layer. The second argument is the matrix of data, and the third argument is the color map.
library(NGCHMDemoData) unadjustedLayer <- chmNewDataLayer('Unadjusted', TCGA.BRCA.ExpressionData, unadjustedColorMap) rowCenteredData <- t(scale(t(TCGA.BRCA.ExpressionData))) rowCenteredLayer <- chmNewDataLayer('Row-Centered', rowCenteredData, rowCenteredColorMap)
We explicitly provide the two data layers created above to the chmNew()
function:
hm <- chmNew('TCGA BRCA Expression', unadjustedLayer, rowCenteredLayer)
and export to a .ngchm or .html file:
library(NGCHMSupportFiles) chmExportToFile(hm,'tcga-brca-two-layers.ngchm') chmExportToHTML(hm,'tcga-brca-two-layers.html')
The resulting NG-CHM has the two data layers available. Click on the icon to toggle between them.
library('htmltools') filePath = paste(getwd(),'/tcga-brca-two-layers.html',sep='') htmltools::includeHTML(filePath)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.