Last data update: 2014.03.03

R: A function to plot a graph colored by expression data
plotExpressionGraphR Documentation

A function to plot a graph colored by expression data

Description

Given a graph and expression data for one entity, will plot the graph with the nodes colored according to the expression levels provided.

Usage

plotExpressionGraph(graph, nodeEGmap, exprs, ENTREZIDenvir, mapFun, log = FALSE, nodeAttrs = list(), ...)

Arguments

graph

The graph to plot

nodeEGmap

A list with element names being node names and the elements being EntrezLink IDs corresponding to those node names.

exprs

A vector of expression data, with names being Affymetrix IDs and values being the expression level.

ENTREZIDenvir

An environment mapping Affymetrix IDs to EntrezLink IDs, such as the ones provided in the xxx2ENTREZID environments from the Bioconductor data packages (where xxx) is a data package).

mapFun

A function to map expression levels to colors.

log

Whether or not the expression data.

nodeAttrs

A list of node attributes, as per plot.graph.

...

Any extra arguments to be passed to plot.graph.

Details

This function can be used to plot a graph and have the nodes colored according to expression levels provided by the user. The graph parameter is a graph object from the graph package.

The nodeEGmap parameter is a list that maps the nodes of the graphs to EntrezLink IDs. An example of this is the IMCAEntrezLink object in the integrinMediatedCellAdhesion data set in the graph package.

The exprs argument is a vector mapping expression levels to Affymetrix IDs. One way to generate an appropriate vector is to extract a single column from an ExpressionSet.

The ENTREZIDenvir environment maps Affymetrix IDs to EntrezLink IDs. The simplest way to provide this argument is to load the preferred Bioconductor data package (e.g. hgu95av2.db) and pass in that package's xxx2ENTREZID, where xxx is the name of the package.

The mapFun function defaults to the function defMapFun, which maps nodes to be either blue, green or red depending for expression ranges of 0-100, 101-500, and 501+. In the case where log is TRUE these ranges are modified with log2. Custom versions of this function can be supplied by the user - it must take two parameters, first the expression vector and a boolean value (log) specifying if the data has had a log2 applied to it. The function must return a vector with the same names as the expression vector, but the values of the vector will be color strings.

The nodeAttrs list can be specified if any other node attributes are desired to be set by the user. Please see the plot.graph man page for more information on this. The other attribute list (attrs and edgeAttrs) can be passed in via the ... parameter.

The IMCAEntrezLink data structure was created for the purpose of illustrating this program. On Sept 24 2007, the current version of hgu95av2.db was used to map from the nodes of IMCAGraph (in graph package) to Entrez identifiers.

Author(s)

Jeff Gentry

See Also

plot.graph, integrinMediatedCellAdhesion

Examples

   if (require("Rgraphviz") && require("hgu95av2.db") &&
       require("fibroEset")) {
       data(integrinMediatedCellAdhesion)
	   data(IMCAEntrezLink)
       data(fibroEset)
       attrs <- getDefaultAttrs()
       attrs$graph$rankdir <- "LR"
       plotExpressionGraph(IMCAGraph, IMCAEntrezLink,
                           exprs(fibroEset)[,1],
                           hgu95av2ENTREZID, attrs = attrs)
   }

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(geneplotter)
Loading required package: Biobase
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
    get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
    match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
    rbind, rownames, sapply, setdiff, sort, table, tapply, union,
    unique, unsplit

Welcome to Bioconductor

    Vignettes contain introductory material; view with
    'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.

Loading required package: lattice
Loading required package: annotate
Loading required package: AnnotationDbi
Loading required package: stats4
Loading required package: IRanges
Loading required package: S4Vectors

Attaching package: 'S4Vectors'

The following objects are masked from 'package:base':

    colMeans, colSums, expand.grid, rowMeans, rowSums

Loading required package: XML
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/geneplotter/plotExpressionGraph.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plotExpressionGraph
> ### Title: A function to plot a graph colored by expression data
> ### Aliases: plotExpressionGraph getPlotExpressionColors IMCAEntrezLink
> ###   defMapFun
> ### Keywords: utilities graphs hplot
> 
> ### ** Examples
> 
>    if (require("Rgraphviz") && require("hgu95av2.db") &&
+        require("fibroEset")) {
+        data(integrinMediatedCellAdhesion)
+ 	   data(IMCAEntrezLink)
+        data(fibroEset)
+        attrs <- getDefaultAttrs()
+        attrs$graph$rankdir <- "LR"
+        plotExpressionGraph(IMCAGraph, IMCAEntrezLink,
+                            exprs(fibroEset)[,1],
+                            hgu95av2ENTREZID, attrs = attrs)
+    }
Loading required package: Rgraphviz
Loading required package: graph

Attaching package: 'graph'

The following object is masked from 'package:XML':

    addNode

Loading required package: grid

Attaching package: 'Rgraphviz'

The following object is masked from 'package:annotate':

    toFile

The following objects are masked from 'package:IRanges':

    from, to

The following objects are masked from 'package:S4Vectors':

    from, to

Loading required package: hgu95av2.db
Loading required package: org.Hs.eg.db


Loading required package: fibroEset
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>