plotExpression {chromstaR} | R Documentation

## Overlap with expression data

### Description

Get the expression values that overlap with each combinatorial state.

### Usage

    plotExpression(hmm, expression, combinations = NULL, return.marks = FALSE)

### Arguments

`hmm` | A `multiHMM` or `combinedMultiHMM` object or file that contains such an object.
`expression` | A `GRanges-class` object with metadata column 'expression', containing the expression value for each range.
`combinations` | A vector with combinations for which the expression overlap will be calculated. If `NULL` all combinations will be considered.
`return.marks` | Set to `TRUE` if expression values for marks instead of combinations should be returned.

### Value

A `ggplot2` object if a `multiHMM` was given or a named list with `ggplot2` objects if a `combinedMultiHMM` was given.

### Author(s)

Aaron Taudt

### See Also

`plotting`

### Examples

    ## Load an example multiHMM
    file <- system.file("data","multivariate_mode-combinatorial_condition-SHR.RData",
                        package="chromstaR")
    model <- get(load(file))

    ## Obtain expression data
    data(expression_lv)
    head(expression_lv)

    ## We need to get coordinates for each of the genes
    library(biomaRt)
    ensembl <- useMart('ENSEMBL_MART_ENSEMBL', host='may2012.archive.ensembl.org',
                      dataset='rnorvegicus_gene_ensembl')
    genes <- getBM(attributes=c('ensembl_gene_id', 'chromosome_name', 'start_position',
                               'end_position', 'strand', 'external_gene_id',
                               'gene_biotype'),
                  mart=ensembl)
    expr <- merge(genes, expression_lv, by='ensembl_gene_id')
    # Transform to GRanges
    expression.SHR <- GRanges(seqnames=paste0('chr',expr$chromosome_name),
                             ranges=IRanges(start=expr$start, end=expr$end),
                             strand=expr$strand, name=expr$external_gene_id,
                             biotype=expr$gene_biotype,
                             expression=expr$expression_SHR)
    # We apply an asinh transformation to reduce the effect of outliers
    expression.SHR$expression <- asinh(expression.SHR$expression)

    ## Plot
    plotExpression(model, expression.SHR) +
     theme(axis.text.x=element_text(angle=0, hjust=0.5)) +
     ggtitle('Expression of genes overlapping combinatorial states')
    plotExpression(model, expression.SHR, return.marks=TRUE) +
     ggtitle('Expression of marks overlapping combinatorial states')

[Package chromstaR version 1.10.0 Index]