chmCovariateBar: Get a covariate bar attached to an NG-CHM.

View source: R/functions.R

chmCovariateBarR Documentation

Get a covariate bar attached to an NG-CHM.

Description

Get a covariate bar attached to an NG-CHM.

Usage

chmCovariateBar(hm, fullname, where)

Arguments

hm

The NG-CHM to get the covariate bar from.

fullname

The full name of the covariate bar to get. If no covariate bar with that name exists, return NULL.

where

The axis or axes on which to look for the covariate bar Can be "row", "column", or "both" (default).

Value

An ngchmBar or NULL.

See Also

ngchmBar

chmNewCovariateBar

chmCovariate

Examples

# Examples using `chmNew()` require git to be installed and available.
## Not run: 
  # If the NGCHMDemoData package is installed, use it to demo usage
  if (requireNamespace("NGCHMDemoData", quietly = TRUE)) {
    # Create example NGCHM with covariate bar
    data(TCGA.GBM.Demo, package = "NGCHMDemoData")
    hm <- chmNew("gbmexpr", TCGA.GBM.ExpressionData[1:50, 1:50])
    hm <- chmAddCovariateBar(
      hm, "column",
      chmNewCovariate("TP53 Mutation", TCGA.GBM.TP53MutationData[1:50])
    )
    # Get covariate bar by name
    tp53_covariate_bar <- chmCovariateBar(hm, "TP53 Mutation")
  }
  # Small example not requiring NGCHMDemoData
  matrix <- matrix(rnorm(100),
    nrow = 10, ncol = 10,
    dimnames = list(paste0("r", 1:10), paste0("c", 1:10))
  )
  hm <- chmNew("Demo", matrix)
  covariate <- setNames(rnorm(10), colnames(matrix))
  hm <- chmAddCovariateBar(hm, "column", chmNewCovariate("my covariate", covariate))
  my_covariate_bar <- chmCovariateBar(hm, "my covariate")

## End(Not run)

MD-Anderson-Bioinformatics/NGCHM-R documentation built on April 1, 2024, 12:34 p.m.