%\VignetteDepends{ToPASeq, graphite, limma, DESeq2, gRbase, graph, Rgraphviz} %\VignetteSuggests{SPIA, DEGraph, clipper, gageData} %\VignetteIndexEntry{An R Package for topology-based pathway analysis of microaray and RNA-Seq data} %\VignettePackage{ToPASeq} \documentclass[letterpaper]{report} \begin{document} \title{ToPASeq: an R package for topology-based pathway analysis of microarray and RNAseq data} \author{Ivana Ihnatova, Eva Budinska \thanks{This work was supported by the project INBIOR (CZ.1.07/2.3.00/20.0042) co-financed by the European Social Fund and the state budget of the Czech Republic.}} \maketitle \tableofcontents \chapter{Introduction} This package de-novo implements or adjusts the existing implementations of several different methods for topology-based pathway analysis of gene expression data from microarray and RNA-Seq technologies. These high-throughput technologies are used for measuring of expression levels of thousands genes in one experiment often with the aim to find pathways and biological processes affected between two conditions. The information which biological processes are affected helps investigators to set-up biologically relevant hypotheses for further research. To this end, a differential gene expression between conditions is assessed - by the means of specific methods, such as limma for instance, which produce lists of differentially expressed genes with specific statistics and p-values for each gene, as well as fold change of mean expression between compared groups. Pathway analysis is the next step, where these differentially expressed genes are mapped to reference pathways derived from databases and relative enrichment is assessed. Methods of topology-based pathway analysis are the last generation of pathway analysis methods that take into account the topological structure of a pathway, which helps to increase specificity and sensitivity of the results. This package implements seven topology-based pathway analysis methods that focus on identification of the pathways that are differentially affected between two conditions (Table~\ref{Tab:01}). Each method is implemented as a single wrapper function which allows the user to call a method in a single command. In addition, this package offers a visualization of the results. The visualization is based on the \texttt{Rgraphviz} package and displays distribution of differential expression and topological significance of the nodes from one pathway. The user can simplify the pathway topology by merging selected sets of nodes into one (individual gene names is the only information that is lost in it). \begin{table} \caption{Methods included in the package. \label{Tab:01}} {\begin{tabular}{lllll}\hline Method & Ref. & Type & Implementation\\\hline TopologyGSA & \cite{Massa} & M & imported\\ DEGraph & \cite{Jacob} & M & imported\\ clipper & \cite{clipper} & M & imported\\ SPIA & \cite{Tarca},& U & imported\\ & \cite{Draghici} &&\\ TBS & \cite{Ibrahim} & U & de novo\\ PWEA & \cite{Hung} & U & de novo\\ TAPPA & \cite{TAPPA} & U & de novo\\\hline \end{tabular}} {M - multivariable, U - univariable} \end{table} \section {Input, output and general functionalities} The input data are either normalized (count) data or gene expression data as well as pathway topological structure. For the sake of simplicity, our package offers in each wrapper function a pre-processing step for RNA-seq normalization - TMM~\cite{TMM} and DESeq~\cite{DESeq}. If necessary, the functions also performs differential gene expression analysis through calling limma and DESeq2 packages. Since some of the methods (SPIA, PRS, PWEA) work with the results of the differentiall expression analysis, the user can prepare the data by his preffered method and skip the built-in normalization and/or differential expression analysis. To summarize, the wrapper functions give options to: 1) normalize the count data (for RNAseq) 2) apply differential expression analysis on gene-level, if applicable, and finally 3) perform topologifal pathway analysis. The functions provides output in a uniform format defined as a new S3 class topResult with basic methods (print, plot, summary) and methods for obtaining the individual parts of the output. \section{Pathway topological structure} Pathways and their topological structures are an important input for the analysis. They are represented as graphs $G=(V,E)$, where $V$ denotes a set of vertices or nodes represented by genes and $E \subseteq V \times V$ is a set of edges between nodes (oriented or not, depending on the method) representing the interaction between genes. These structures can be downloaded from public databases such as KEGG or Biocarta or are available through other packages such as {\tt graphite}. ToPASeq is build upon {\tt graphite} R-package where pathways from seven public databases: KEGG, Biocarta, Reactome, NCI, SPIKE, HumanCyc, Panther were downloaded and parsed into a new S4 class \texttt{pathway} (up to version 1.12.0). The parsing process deals also with a special type of nodes that can be found in biological pathways. Protein complexes are expanded into cliques since it is assumed that all units from one complex interact with each other. A clique, from graph theory, is a subset of vertices such that every two vertices in the subset are connected by an edge. On the other hand, gene families are expanded into separate nodes with same incoming and/or outgoing edges, because they are believed to be interchangable. The most important modification is the propagation of signal through the so called compound-mediated interactions. By compound-mediated interaction we mean an interaction that engages not only genes or their product but also other chemical compounds e.g. calcium ions. \texttt{graphite} is the first package that propagates signal through such interactions. For example, if gene \emph{A} interacts with compound \emph{c} and compound \emph{c} with gene \emph{B} then in a pathway topology gene \emph{A} should interact with gene \emph{B}. Please see~\cite{graphite} for more details. <<>>= library(ToPASeq) pathways<-pathways("hsapiens", "kegg")[1:5] pathways[[1]] str(pathways[[1]]) @ \section{Preparing and manipulating pathways} The easiest way is to use pathway available through \texttt{graphite}. However, you might need to use your own pathway - the easiest way is to download it from some database (do not forget this pathway needs to contain topological information!) and convert it to the correct format using our specific functions for pathway conversion and manipulation. Functions \texttt{AdjacencyMatrix2Pathway} and \texttt{graphNEL2Pathway} coerce either an adjacency matrix (binary matrix, where 1 means an edge between two genes) or \texttt{graphNEL} into \texttt{Pathway}. For a reduction of a specified set of nodes (e.g. genes from the same class with similar function), which helps to simply the graphical graph representation, you can use function \texttt{reduceGraph}. Any other topological manipulations or basic topological analysis can be achieved through \texttt{graphNEL} and conversion from and to \texttt{Pathway}. Or directly with the following functions: \begin{description} \item[intersection] compute the intersection of the two supplied graphs. They must have identical nodes. \item[join] returns the joining of the two graphs. It is similar to \texttt{intersection} but does not require the identical nodes \item[union] compute the union of the two supplied graphs. They must have identical nodes. \item[subGraph] Given a set of nodes and a pathway this function creates and returns subgraph with only the supplied nodes and any edges between them \item[clearNode] Clears all edges incoming and outgoing edges from node(s) \item[removeEdge] removes all edges between two subsets of nodes (starting in one subset and ending in the other) \item[removeNode] removes node(s) from a pathway \item[nodes<-] sets node labels of pathway to a specific value \item[degree] Returns the number of incoming or outgoing edges for specified nodes \item[numNoEdges] Returns the number of nodes without any edge \item[mostEdges] Returns the nodes with most edges \item[acc] Returns the set of nodes accessible from a subset of nodes. The undirected edges are considered as bidirected (directed in both directions) \item[connComp] Returns the connected components present in a pathway. They are returned as list where each slot refers to one component and contains the relevant nodes. The undirected edges are considered as bidirected (directed in both directions) \item[edges] Returns the edges relevant to node or all edges in the pathway \item[isAdjacent] Checks whether two nodes are adjacent (there is an edge starting in first node and ending in the second) \item[isConnected] Checks if a pathway contains only one connected component \item[isDirected] Checks if all edges in a pathway are directed \item[edgemode] Returns the type of edges in a pathway: \texttt{directed}, \texttt{undirected} or both \item[numEdges] Returns the number of edges in a pathway \item[numNodes] Returns the number of nodes in a pathway \item[edgeNames] Returns the names of the edges in a following format: starting node ~ ending node \end{description} We also especially designed function \texttt{prepareData} that converts the idendifiers of pathways, compares them agains the supplied vector of the identifiers from expression data and filters pathways with too many nodes, too few edges, not enought identifiers common with the expression data and transforms the pathways into formats reqiured in individual methods. The normalized gene expression data or count data can be in two formats. One is an simple matrix were rows refer to genes and the other one is an \texttt{ExpressionSet}. There are four acceptable formats for the clincal data: the name or number of \texttt{phenoData} of \texttt{ExpressionSet} or a character or numeric vector that is coerced to factor. We will demonstrate the features of the package on the example of analysis of two datasets. For microarray data we will use the log2-transformed normalized expression data from the \texttt{DEGraph} package and for RNA-Seq data we will use the count data from \texttt{gageData} package. The pathway topologies are available via function \texttt{pathways()} from \texttt{graphite} package. For this demonstrantion we will use human pathways from KEGG or Biocarta. \chapter{Analysis of microarray data} In our example we will use the dataset \texttt{Loi2008\_DEGraphVignette} from \texttt{DEGraph} package. It conatains the expression profiles of 255 patients with hormone-dependent breast cancer stored as a matrix. The aim of the study was to determine which genes are differentially expressed between tamoxifen-resistant and tamoxifen-sensitive samples. Gene expression data matrix and vector of class labels is stored as separate objects \texttt{exprLoi2008} and \texttt{classLoi2008}, respectively. In \texttt{classLoi2008}, \texttt{0} refers to a tamoxifen-resistant sample and \texttt{1} to a tamoxifen-sensitive one. We will not need the annotation data (\texttt{annLoi2008}) or KEGG pathways \texttt{grListKEGG} in our example. On the other hand, we will use a few first pathways from \texttt{KEGG}. The pathways were selected only in order to reduce the computational complexity of the analysis. Also, the outputs from the most computationaly complex methods are displayed as comments. \par <>= options(width=60) @ We will load the package, the data and subset of the pathways with <>= library(ToPASeq) library(DEGraph) data(Loi2008_DEGraphVignette) pathways<-pathways("hsapiens", "kegg")[1:5] ls() @ \section{TopologyGSA} TopologyGSA represents a multivariable method in which the expression of genes is modelled with Gausian Graphical Models with covariance matrix reflecting the pathway topology. It uses the the Iterative Proportional Scaling algorithm to estimate the covariance matrices. The testing procedure is a two-step process. First the equality of covariance matrices is tested via a likelihood ratio test. Then, when the null hypothesis of equality of covariance matrices is not rejected, the differential expression is tested via multivariate analysis of variance. On the other hand, when the convariance matrices are not equal, then Behrens-Fisher method for testing the equality of means in a two sample problem with unequal covariance matrices is employed. This method was first implemented in the \texttt{TopologyGSA} package. In ToPASeq we have optimalized its performance by using different function for obtaining cliques from each pathway. The method can be used with a single command <>= top<-TopologyGSA(exprLoi2008, classLoi2008, pathways, type="MA", perms=200) #99 node labels mapped to the expression data #Average coverage 31.47657 % #0 (out of 5) pathways without a mapped node #Acute myeloid leukemia #Adherens junction #Adipocytokine signaling pathway #Adrenergic signaling in cardiomyocytes #African trypanosomiasis res(top) #$results # t.value df.mean1 df.mean2 p.value #Acute myeloid leukemia 3024.796 30 224 0 #Adherens junction 1102.830 10 244 0 #Adipocytokine signaling pathway 3196.432 25 229 0 #Adrenergic signaling in cardiomyocytes 2178.476 26 228 0 #African trypanosomiasis 1404.259 8 246 0 # lambda.value df.var p.value.var #Acute myeloid leukemia 213.01437 156 1.649509e-03 #Adherens junction 39.92094 10 1.749659e-05 #Adipocytokine signaling pathway 192.81336 121 3.595452e-05 #Adrenergic signaling in cardiomyocytes 169.47418 80 2.211953e-08 #African trypanosomiasis 13.02808 12 3.670031e-01 # qchisq.value var.equal q.value #Acute myeloid leukemia 186.14575 1 0 #Adherens junction 18.30704 1 0 #Adipocytokine signaling pathway 147.67353 1 0 #Adrenergic signaling in cardiomyocytes 101.87947 1 0 #African trypanosomiasis 21.02607 0 0 # #$errors #named list() @ Apart from the expected arguments: a gene expression data matrix, a vector of class labels and a list of pathways, the user needs to specify the \texttt{type} argument which decides on the type of the data (\texttt{"MA"} is used for expression microarray and \texttt{"RNASeq"} for RNA-Seq data). The others arguments are optional. The \texttt{perms} argument sets the number of permutations to be used in the statistical tests. By default both mean and variance tests are run, this can be changed to only variance test by setting \texttt{method="var"}. Arguments \texttt{convertTo} and \texttt{convertBy} control the conversion of the node labels in the pathways. The default setting is \texttt{convertTo="none"} which performs no conversion. Please note, that the node labels should be the same as the rownames of gene expression data matrix. The threshold for variance test is specified with \texttt{alpha} argument. The implementation allows also testing of all the cliques present in the graph by setting \texttt{testCliques=TRUE}. Please note that these tests may take quite a long time. The implementation returns also a gene-level statistics of the differential expression of genes performed via moderated t-test from \texttt{limma} package. These statistics are later used in the visualization of a selected pathway. \section{DEGraph} Another multivariable method implemented in the package is DEGraph. This method assumes the same direction in the differential expresion of genes belonging to a pathway. It performs the regular Hotelling's T2 test in the graph-Fourier space restricted to its first $k$ components which is more powerful than test in the full graph-Fourier space or in the original space. We apply the method with <<>>= deg<-DEGraph(exprLoi2008, classLoi2008, pathways, type="MA") res(deg) @ Apart from the expected arguments: a gene expression data matrix, a vector of class labels and a list of pathways, the user needs to specify the \texttt{type} argument which decides on the type of the data (\texttt{"MA"} is used for expression microarray and \texttt{"RNASeq"} for RNA-Seq data). The others arguments are optional. Arguments \texttt{convertTo} and \texttt{convertBy} control the conversion of the node labels in the pathways. The default setting is \texttt{convertTo="none"} which performs no conversion. Please note, that the node labels should be the same as the rownames of gene expression data matrix. Since, the DEGraph method runs a statistical test for each connected component of a pathway, a method for assigning a global p-value for whole pathway is needed. The user can select from three approaches: the minimum, the mean and the p-value of the biggest component. This is specified via \texttt{overall} argument. The implementation returns also a gene-level statistics of the differential expression of genes performed via moderated t-test from \texttt{limma} package. These statistics are later used in the visualization of a selected pathway. \section{clipper} The last multivariable method available within this package is called clipper. This method is similar to the topologyGSA as it uses the same two-step approach. However, the Iterative Proportional Scaling algorithm was subsituted with a shrinkage procedure of James-Stein-type which additionally allows proper estimates also in the situation when number of samples is smaller than the number of genes in a pathway. The tests on a pathway-level are follwed with a search for the most affected path in the graph. The method can be applied with <>= cli<-clipper( exprLoi2008, classLoi2008, pathways,type="MA", method="mean") #99 node labels mapped to the expression data #Average coverage 31.47657 % #0 (out of 5) pathways without a mapped node #0 pathways were filtered out #Analysing pathway: # #Acute myeloid leukemia #Adherens junction #Adipocytokine signaling pathway #Adrenergic signaling in cardiomyocytes #African trypanosomiasis #0 denoted as 0 # 1 denoted as 1 # Contrasts: 1 - 0 #Warning messages: #1: In getJunctionTreePaths(graph, root) : # The DAG presents cliques that are not connected. #2: In prunePaths(clipped, pruneLevel) : pathSummary is NULL #3: In getJunctionTreePaths(graph, root) : # The DAG presents cliques that are not connected. #4: In prunePaths(clipped, pruneLevel) : pathSummary is NULL res(cli)$results[[1]] # alphaVar alphaMean mean.q.value var.q.value #Acute myeloid leukemia 0.735 0.009 0.0150 0.91875 #Adherens junction 0.101 0.022 0.0275 0.26500 #Adipocytokine signaling pathway 0.656 0.001 0.0050 0.91875 #Adrenergic signaling in cardiomyocytes 0.106 0.061 0.0610 0.26500 #African trypanosomiasis 0.953 0.007 0.0150 0.95300 @ Apart from the expected arguments: a gene expression data matrix, a vector of class labels and a list of pathways, the user needs to specify the \texttt{type} argument which decides on the type of the data (\texttt{"MA"} is used for expression microarray and \texttt{"RNASeq"} for RNA-Seq data). The others arguments are optional. Arguments \texttt{convertTo} and \texttt{convertBy} control the conversion of the node labels in the pathways. The default setting is \texttt{convertTo="none"} which performs no conversion. Please note, that the node labels should be the same as the rownames of gene expression data matrix. Also, both mean and variance tests are run, this can be changed to only variance test by setting \texttt{method="var"}. The \texttt{nperm} controls the number of permutations in the statistical tests. Similarly as in topologyGSA, the implementation allows testing of all the cliques present in the graph by setting \texttt{testCliques=TRUE}. Please note that these tests may take quite a long time. The implementation returns also a gene-level statistics of the differential expression of genes performed via moderated t-test from \texttt{limma} package. These statistics are later used in the visualization of a selected pathway. The function returns two types of the results on pathway-level. The first (printed above), is a table of p-values and q-values related to the differential expression and concentration of the pathways. The second one, is a list contating the most affected paths in each pathway - these are obtained via \texttt{easyClip} function from \texttt{clipper} package. \section{SPIA} The most well-known topology-based pathway analysis method is SPIA. In there, two evidences of differential expression of a pathway are combined. The first evidence is a regular so called overrepresentation analysis in which the statistical significance of the number of differentially expressed genes belonging to a pathway is assessed. The second evidence reflects the pathway topology and it is called the pertubation factor. The authors assume that a differentially expressed gene at the begining of a pathway topology (e.g. a receptor in a signaling pathway) has a stronger effect on the functionality of a pathway than a differentially expressed gene at the end of a pathway (e.g. a transcription factor in a signaling pathway). The pertubation factors of all genes are calculated from a system of linear equations and then combined within a pathway. The two evidences in a form of p-values are finally combined into a global p-value, which is used to rank the pathways. <<>>= spi<-SPIA(exprLoi2008, classLoi2008,pathways , type="MA", logFC.th=-1) res(spi) @ Apart from the expected arguments: a gene expression data matrix, a vector of class labels and a list of pathways, the user needs to specify the \texttt{type} argument which decides on the type of the data (\texttt{"MA"} is used for expression microarray and \texttt{"RNASeq"} for RNA-Seq data). Alternatively, the user can supply the results of the differential expression analysis of genes in two forms: \begin{enumerate} \item a data.frame with columns: \emph{ID} gene identifiers (they must match with the node labels), \emph{logFC} log fold-changes, \emph{t} - t-statistics, \emph{pval} p-values, \emph{padj} adjusted p-values. Then the user sets \texttt{type} to \texttt{DEtable} \item a list with two slots: named vector of log fold-changes of differentially expressed genes and a vector of names of all genes analysed. Then the user sets \texttt{type} to \texttt{DElist} \end{enumerate} The others arguments are optional. Arguments \texttt{convertTo} and \texttt{convertBy} control the conversion of the node labels in the pathways. The default setting is \texttt{convertTo="none"} which performs no conversion. Please note, that the node labels should be the same as the rownames of gene expression data matrix. The default thresholds for the differential expression analysis of genes (the moderated t-test from \texttt{limma} is used) are set with arguments \texttt{logFC.th} and \texttt{p.val.th}. The user can omit one of these criteria by setting the agrument negative value, as is shown also in the example. The implementation returns also a gene-level statistics of the differential expression of genes. These statistics are later used in the visualization of a selected pathway. \section{TAPPA} TAPPA was among the first topology-based pathway analysis methods. It was inspired in chemointformatics and their models for predicting the structure of molecules. In TAPPA, the gene expression values are standardized and sigma-transformed within a samples. Then, a pathway is seen a molecule, individual genes as atoms and the energy of a molecule is a score defined for one sample. This score is called Pathway Connectivity Index. The difference of expression is assessed via a common univariable two sample test - Mann-Whitney in our implemetation. <<>>= tap<-TAPPA(exprLoi2008, classLoi2008, pathways, type="MA") res(tap) @ Apart from the expected arguments: a gene expression data matrix, a vector of class labels and a list of pathways, the user needs to specify the \texttt{type} argument which decides on the type of the data (\texttt{"MA"} is used for expression microarray and \texttt{"RNASeq"} for RNA-Seq data). The others arguments are optional. Arguments \texttt{convertTo} and \texttt{convertBy} control the conversion of the node labels in the pathways. The default setting is \texttt{convertTo="none"} which performs no conversion. Please note, that the node labels should be the same as the rownames of gene expression data matrix. The user can also specified whether the normalization step (standardization and sigma-transformation) should be perfomed (\texttt{normalize=TRUE}). If \texttt{verbose=TRUE}, function prints out the titles of pathways as their are analysed. The implementation returns also a gene-level statistics of the differential expression of genes. These statistics are later used in the visualization of a selected pathway. \section{PRS} PRS is another method that works with gene-level statistics and a list of differentially expresed genes. The pathway topology is incorporated as the number of downstream differentially expressed genes. The gene-level log fold-changes are weigted by this number and sumed up into a pathway-level score. A statistical significance is assessed by a permutations of genes. <>= Prs<-PRS( exprLoi2008, classLoi2008, pathways, type="MA", logFC.th=-1, nperm=100) res(Prs) @ Arguments of this functions are almost the same as in \texttt{SPIA}. Apart from the expected arguments: a gene expression data matrix, a vector of class labels and a list of pathways, the user needs to specify the \texttt{type} argument which decides on the type of the data (\texttt{"MA"} is used for expression microarray and \texttt{"RNASeq"} for RNA-Seq data). Alternatively, the user can supply the results of the differential expression analysis of genes in two forms: \begin{enumerate} \item a data.frame with columns: \emph{ID} gene identifiers (they must match with the node labels), \emph{logFC} log fold-changes, \emph{t} - t-statistics, \emph{pval} p-values, \emph{padj} adjusted p-values. Then the user sets \texttt{type} to \texttt{DEtable} \item a list with two slots: named vector of log fold-changes of differentially expressed genes and a vector of names of all genes analysed. Then the user sets \texttt{type} to \texttt{DElist} \end{enumerate} The others arguments are optional. Arguments \texttt{convertTo} and \texttt{convertBy} control the conversion of the node labels in the pathways. The default setting is \texttt{convertTo="none"} which performs no conversion. Please note, that the node labels should be the same as the rownames of gene expression data matrix. The default thresholds for the differential expression analysis of genes (the moderated t-test from \texttt{limma} is used) are set with arguments \texttt{logFC.th} and \texttt{p.val.th}. The user can omit one of these criteria by setting the agrument negative value, as is shown also in the example. The implementation returns also a gene-level statistics of the differential expression of genes. These statistics are later used in the visualization of a selected pathway. There is one extra argument \texttt{nperm} which controls the number of permutations. \section{PWEA} The last method available in this package is called PathWay Enrichment Analysis (PWEA). This is actually a weigthed form of common Gene Set Enrichment Analysis (GSEA). The weights are called Topological Influence Factor (TIF) and are defined as a geometic mean of ratios of Pearson's correlation coefficient and the distance of two genes in a pathway. The weights of genes outside a pathway are assigned randomly from normal distribution with parameters estimated from the weights of genes in all pathways. A statistical significance of a pathway is assessed via Kolmogorov-Simirnov-like test statistic comparing two cumulative distribution functions with class label permutations. <>= pwe<-PWEA(exprLoi2008, classLoi2008, pathways, type="MA", nperm=100) #0 denoted as 0 # 1 denoted as 1 # Contrasts: 1 - 0 #29 node labels mapped to the expression data #Average coverage 5.752782 % #1 (out of 5) pathways without a mapped node #1 pathways were filtered out # Preparing permutations.. res(pwe) #$results # ES p.value q.value #Acute myeloid leukemia -0.1516072 0.36 0.5066667 #Adherens junction 0.2576037 1.00 1.0000000 #Adipocytokine signaling pathway 0.2221782 0.38 0.5066667 #Adrenergic signaling in cardiomyocytes -0.2265755 0.05 0.2000000 # #$errors #named list() @ Apart from the expected arguments: a gene expression data matrix, a vector of class labels and a list of pathways, the user needs to specify the \texttt{type} argument which decides on the type of the data (\texttt{"MA"} is used for expression microarray and \texttt{"RNASeq"} for RNA-Seq data). Alternatively, the user can supply a list of observed and random gene-level statistics and set \texttt{type} to \texttt{DEtable}. The observed gene-level statistics are expected as data frame with columns: \emph{ID} gene identifiers (they must match with the node labels), \emph{logFC} log fold-changes, \emph{t} - t-statistics, \emph{pval} p-values, \emph{padj} adjusted p-values.. A data.frame of similar data.frames is expected for random statistics (it is an output from sapply function when the applied function returns a data frame). Columns should refer to the results from individual analyses after class label permutation. The others arguments are optional.Arguments \texttt{convertTo} and \texttt{convertBy} control the conversion of the node labels in the pathways. The default setting is \texttt{convertTo="none"} which performs no conversion. Please note, that the node labels should be the same as the rownames of gene expression data matrix. The \texttt{alpha} parameter sets a threshold for gene weights. The purpose of this filtering is to reduce the possiblity that a weight of a gene that is tighly correlated with a few genes are lowered by the weak correlation with other genes in a pathway. The implementation returns also a gene-level statistics of the differential expression of genes. These statistics are later used in the visualization of a selected pathway. The \texttt{nperm} argument controls the number of permutations. \chapter{Analysis of RNA-Seq data} All of the methods metioned in the previus chapter were designed for the microarray data. However, the RNA-Seq technology is gaining popularity and becomes widely used. Unfortunatelly, the topology-based pathway analysis methods are not available for this type of the data. Therefore, we adapted the selected methods for RNA-Seq count matrices. Two types of adaptations were used. If a method works directly with the expression profiles (multivariable methods and TAPPA), then the count matrix is normalized and transformed either by TMM or DESeq2 method. The remaining methods use also or only the gene-level statistics like log fold-change. The differential expression analysis of genes with either \texttt{DESeq2} or \texttt{limma} package is a part of their implementation. We will use the data from \texttt{gageData} for an example analysis. <>= library(gageData) data(hnrnp.cnts) hnrnp.cnts<-hnrnp.cnts[rowSums(hnrnp.cnts)>0,] group<-c(rep("sample",4), rep("control",4)) pathways<-pathways("hsapiens", "kegg") @ \section{TopologyGSA} TopologyGSA represents a multivariable method in which the expression of genes is modelled with Gausian Graphical Models with covariance matrix reflecting the pathway topology. It uses the the Iterative Proportional Scaling algorithm to estimate the covariance matrices. The testing procedure is a two-step process. First the equality of covariance matrices is testes via a likelihood ratio test. Then, when the null hypothesis of equality of covariance matrices is not rejected, the differential expression is testes via multivariate analysis of variance. On the other hand, when the convariance matrices are not equal, then Behrens-Fisher method for testing the equality of means in a two sample problem with unequal covariance matrices is employed. The method can be used with a single command <>= top<-TopologyGSA(hnrnp.cnts, group, pathways[1:3], type="RNASeq", nperm=1000) #528 node labels mapped to the expression data #Average coverage 83.16538 #0 (out of 10) pathways without a mapped node #Normalization method was not specified. TMM used as default #Acute myeloid leukemia #Adherens junction #Adipocytokine signaling pathway res(top) #data frame with 0 columns and 1 rows @ Apart from the expected arguments: a gene expression data matrix, a vector of class labels and a list of pathways, the user needs to specify the \texttt{type} argument which decides on the type of the data (\texttt{"MA"} is used for expression microarray and \texttt{"RNASeq"} for RNA-Seq data). The others arguments are optional. The \texttt{perms} argument sets the number of permutations to be used in the statistical tests. By default both mean and variance tests are run, this can be changed to only variance test by setting \texttt{method="var"}. Arguments \texttt{convertTo} and \texttt{convertBy} control the conversion of the node labels in the pathways. The default setting is \texttt{convertTo="none"} which performs no conversion. Please note, that the node labels should be the same as the rownames of gene expression data matrix. The threshold for variance test is specified with \texttt{alpha} argument. The implementation allows also testing of all the cliques present in the graph by setting \texttt{testCliques=TRUE}. Please note that these tests may take quite a long time. The implementation returns also a gene-level statistics of the differential expression of genes performed via moderated t-test from \texttt{limma} package. These statistics are later used in the visualization of a selected pathway. Unfortunatelly, this method requires more samples than nodes in a pathway. Therefore there is an empty output in the example above. \section{DEGraph} Another multivariable method implemented in the package is DEGraph. This method assumes the same direction in the differential expresion of genes belonging to a pathway. It performs the regular Hotelling's T2 test in the graph-Fourier space restricted to its first $k$ components which is more powerful than test in the full graph-Fourier space or in the original space. We apply the method with <>= deg<-DEGraph(hnrnp.cnts, group, pathways, type="RNASeq") res(deg)[[1]][[1]] @ Apart from the expected arguments: a gene expression data matrix, a vector of class labels and a list of pathways, the user needs to specify the \texttt{type} argument which decides on the type of the data (\texttt{"MA"} is used for expression microarray and \texttt{"RNASeq"} for RNA-Seq data). The others arguments are optional. Arguments \texttt{convertTo} and \texttt{convertBy} control the conversion of the node labels in the pathways. The default setting is \texttt{convertTo="none"} which performs no conversion. Please note, that the node labels should be the same as the rownames of gene expression data matrix. Since, the DEGraph method runs a statistical test for each connected component of a pathway, a method for assigning a global p-value for whole pathway is needed. The user can select from three approaches: the minimum, the mean and the p-value of the biggest component. This is specified via \texttt{overall} argument. The implementation returns also a gene-level statistics of the differential expression of genes performed via moderated t-test from \texttt{limma} package. These statistics are later used in the visualization of a selected pathway. \section{clipper} The last multivariable method available within this package is called clipper. This method is similar to the topologyGSA as it uses the same two-step approach. However, the Iterative Proportional Scaling algorithm was subsituted with a shrinkage procedure of James-Stein-type which additionally allows proper estimates also in the situation when number of samples is smaller than the number of genes in a pathway. The tests on a pathway-level are follwed with a search for the most affected path in the graph. The method can be applied with <>= cli<-clipper(hnrnp.cnts, group, pathways, type="RNASeq", method="mean") #530 node labels mapped to the expression data #Average coverage 82.98681 % #0 (out of 10) pathways without a mapped node #1 pathways were filtered out #Analysing pathway: # #Acute myeloid leukemia #Adherens junction #Adipocytokine signaling pathway #Adrenergic signaling in cardiomyocytes #African trypanosomiasis #Alanine, aspartate and glutamate metabolism #Alcoholism #Aldosterone-regulated sodium reabsorption #Allograft rejection #alpha-Linolenic acid metabolism res(cli)$results[[1]][1:2,] # alphaVar alphaMean mean.q.value var.q.value #Acute myeloid leukemia 0.026 0.010 0.016 0.033 #Adherens junction 0.030 0.009 0.016 0.033 @ Apart from the expected arguments: a gene expression data matrix, a vector of class labels and a list of pathways, the user needs to specify the \texttt{type} argument which decides on the type of the data (\texttt{"MA"} is used for expression microarray and \texttt{"RNASeq"} for RNA-Seq data). The others arguments are optional. Arguments \texttt{convertTo} and \texttt{convertBy} control the conversion of the node labels in the pathways. The default setting is \texttt{convertTo="none"} which performs no conversion. Please note, that the node labels should be the same as the rownames of gene expression data matrix. Also, both mean and variance tests are run, this can be changed to only variance test by setting \texttt{method="var"}. The \texttt{nperm} controls the number of permutations in the statistical tests. Similarly as in topologyGSA, the implementation allows testing of all the cliques present in the graph by setting \texttt{testCliques=TRUE}. Please note that these tests may take quite a long time. The implementation returns also a gene-level statistics of the differential expression of genes performed via moderated t-test from \texttt{limma} package. These statistics are later used in the visualization of a selected pathway. \section{SPIA} The most well-known topology-based pathway analysis method is SPIA. In there, two evidences of differential expression of a pathway are combined. The first evidence is a regular so called overrepresentation analysis in which the statistical significance of the number of differentially expressed genes belonging to a pathway is assessed. The second evidence reflects the pathway topology and it is called the pertubation factor. The authors assume that a differentially expressed gene at the begining of a pathway topology (e.g. a receptor in a signaling pathway) has a stronger effect on the functionality of a pathway than a differentially expressed gene at the end of a pathway (e.g. a transcription factor in a signaling pathway). The pertubation factors of all genes are calculated from a system of linear equations and then combined within a pathway. The two evidences in a form of p-values are finally combined into a global p-value, which is used to rank the pathways. <>= spi<-SPIA(hnrnp.cnts, group, pathways, type="RNASeq", logFC.th=-1) res(spi) @ Apart from the expected arguments: a gene expression data matrix, a vector of class labels and a list of pathways, the user needs to specify the \texttt{type} argument which decides on the type of the data (\texttt{"MA"} is used for expression microarray and \texttt{"RNASeq"} for RNA-Seq data). Alternatively, the user can supply the results of the differential expression analysis of genes in two forms: \begin{enumerate} \item a data.frame with columns: \emph{ID} gene identifiers (they must match with the node labels), \emph{logFC} log fold-changes, \emph{t} - t-statistics, \emph{pval} p-values, \emph{padj} adjusted p-values. Then the user sets \texttt{type} to \texttt{DEtable} \item a list with two slots: named vector of log fold-changes of differentially expressed genes and a vector of names of all genes analysed. Then the user sets \texttt{type} to \texttt{DElist} \end{enumerate} The others arguments are optional. Arguments \texttt{convertTo} and \texttt{convertBy} control the conversion of the node labels in the pathways. The default setting is \texttt{convertTo="none"} which performs no conversion. Please note, that the node labels should be the same as the rownames of gene expression data matrix. The default thresholds for the differential expression analysis of genes (the moderated t-test from \texttt{limma} is used) are set with arguments \texttt{logFC.th} and \texttt{p.val.th}. The user can omit one of these criteria by setting the agrument negative value, as is shown also in the example. The implementation returns also a gene-level statistics of the differential expression of genes. These statistics are later used in the visualization of a selected pathway. \section{TAPPA} TAPPA was among the first topology-based pathway analysis methods. It was inspired in chemointformatics and their models for predicting the structure of molecules. In TAPPA, the gene expression values are standardized and sigma-transformed within a samples. Then, a pathway is seen a molecule, individual genes as atoms and the energy of a molecule is a score defined for one sample. This score is called Pathway Connectivity Index. The difference of expression is assessed via a common univariable two sample test - Mann-Whitney in our implemetation. <>= tap<-TAPPA(hnrnp.cnts, group, pathways, type="RNASeq") res(tap) @ Apart from the expected arguments: a gene expression data matrix, a vector of class labels and a list of pathways, the user needs to specify the \texttt{type} argument which decides on the type of the data (\texttt{"MA"} is used for expression microarray and \texttt{"RNASeq"} for RNA-Seq data). The others arguments are optional. Arguments \texttt{convertTo} and \texttt{convertBy} control the conversion of the node labels in the pathways. The default setting is \texttt{convertTo="none"} which performs no conversion. Please note, that the node labels should be the same as the rownames of gene expression data matrix. The user can also specified whether the normalization step (standardization and sigma-transformation) should be perfomed (\texttt{normalize=TRUE}). If \texttt{verbose=TRUE}, function prints out the titles of pathways as their are analysed. The implementation returns also a gene-level statistics of the differential expression of genes. These statistics are later used in the visualization of a selected pathway. \section{PRS} PRS is another method that works with gene-level statistics and a list of differentially expresed genes. The pathway topology is incorporated as the number of downstream differentially expressed genes. The gene-level log fold-changes are weigted by this numeber and sumed up into a pathway-level score. A statistical significance is assessed by a permutations of genes. <>= Prs<-PRS(hnrnp.cnts, group, pathways, type="RNASeq", logFC.th=-1, nperm=100) res(Prs) @ Arguments of this functions are almost the same as in \texttt{SPIA}. Apart from the expected arguments: a gene expression data matrix, a vector of class labels and a list of pathways, the user needs to specify the \texttt{type} argument which decides on the type of the data (\texttt{"MA"} is used for expression microarray and \texttt{"RNASeq"} for RNA-Seq data). Alternatively, the user can supply the results of the differential expression analysis of genes in two forms: \begin{enumerate} \item a data.frame with columns: \emph{ID} gene identifiers (they must match with the node labels), \emph{logFC} log fold-changes, \emph{t} - t-statistics, \emph{pval} p-values, \emph{padj} adjusted p-values. Then the user sets \texttt{type} to \texttt{DEtable} \item a list with two slots: named vector of log fold-changes of differentially expressed genes and a vector of names of all genes analysed. Then the user sets \texttt{type} to \texttt{DElist} \end{enumerate} The others arguments are optional. Arguments \texttt{convertTo} and \texttt{convertBy} control the conversion of the node labels in the pathways. The default setting is \texttt{convertTo="none"} which performs no conversion. Please note, that the node labels should be the same as the rownames of gene expression data matrix. The default thresholds for the differential expression analysis of genes (the moderated t-test from \texttt{limma} is used) are set with arguments \texttt{logFC.th} and \texttt{p.val.th}. The user can omit one of these criteria by setting the agrument negative value, as is shown also in the example. The implementation returns also a gene-level statistics of the differential expression of genes. These statistics are later used in the visualization of a selected pathway. There is one extra argument \texttt{nperm} which controls the number of permutations. \section{PWEA} The last method available in this package is called PathWay Enrichment Analysis (PWEA). This is actually a weigthed form of common Gene Set Enrichment Analysis (GSEA). The weights are called Topological Influence Factor (TIF) and are defined as a geometic mean of ratios of Pearson's correlation coefficient and the distance of two genes in a pathway. The weights of genes outside a pathway are assigned randomly from normal distribution with parameters estimated from the weights of genes in all pathways. A statistical significance of a pathway is assessed via Kolmogorov-Simirnov-like test statistic comparing two cumulative distribution functions with class label permutations. <>= pwe<-PWEA(hnrnp.cnts, group, pathways, type="RNASeq", nperm=100) #528 node labels mapped to the expression data #Average coverage 83.16538 #0 (out of 10) pathways without a mapped node #Acute myeloid leukemia #Adherens junction #Adipocytokine signaling pathway #Adrenergic signaling in cardiomyocytes #African trypanosomiasis #Alanine, aspartate and glutamate metabolism #Alcoholism #Aldosterone-regulated sodium reabsorption #Allograft rejection #alpha-Linolenic acid metabolism res(pwe) # ES p p.adj #Acute myeloid leukemia 0.3526104 0.29 0.4142857 #Adherens junction 0.3829831 1.00 1.0000000 #Adipocytokine signaling pathway 0.3102945 1.00 1.0000000 #Adrenergic signaling in cardiomyocytes 0.3611207 0.20 0.3333333 #African trypanosomiasis 0.3272899 0.20 0.3333333 #Alanine, aspartate and glutamate metabolism 0.2720946 0.20 0.3333333 #Alcoholism 0.4708293 0.86 1.0000000 #Aldosterone-regulated sodium reabsorption 0.3951037 0.20 0.3333333 #Allograft rejection 0.9421248 0.03 0.3000000 #alpha-Linolenic acid metabolism 0.6587026 0.20 0.3333333 @ Apart from the expected arguments: a gene expression data matrix, a vector of class labels and a list of pathways, the user needs to specify the \texttt{type} argument which decides on the type of the data (\texttt{"MA"} is used for expression microarray and \texttt{"RNASeq"} for RNA-Seq data). The others arguments are optional.Arguments \texttt{convertTo} and \texttt{convertBy} control the conversion of the node labels in the pathways. The default setting is \texttt{convertTo="none"} which performs no conversion. Please note, that the node labels should be the same as the rownames of gene expression data matrix. The \texttt{alpha} parameter sets a threshold for gene weights. The purpose of this filtering is to reduce the possiblity that a weight of a gene that is tighly correlated with a few genes are lowered by the weak correlation with other genes in a pathway. The implementation returns also a gene-level statistics of the differential expression of genes. These statistics are later used in the visualization of a selected pathway. The \texttt{nperm} argument controls the number of permutations. \chapter{Outputs and visualization of the results for one pathway} All the functions mentioned in this vignette return an object of class \texttt{topResult}. It is a list with three slots. The first one is called \texttt{res} and contains a data frame of the results for all the pathways. The actual informations there differ among the methods and are described in the manual. The second slot is called \texttt{topo.sig} and it is a list of topological significances of genes in pathways. The term topologial significance means scores used to measure the importance of a gene in a pathway. The higher the score the more important gene. It is \texttt{NULL} for TAPPA and DEGraph method, because they do not provide any measure of this kind. The last slot contains the log fold-changes or test statistics of differential expression at gene level. They are necessary in the \texttt{plot} function for all the methods except TopologyGSA and clipper. The \texttt{plot()} function has three necessarry arguments when it is to be applied on \texttt{topResult} object. The first one is an output from any of the methods. The second one is either a name of a pathway or its number in a list of pathways. And the last one is a list of pathways used in the analysis. The final visualization of the results for one pathway is method specific. Three arguments that are common to all methods are: \begin{itemize} \item \texttt{IDs} - the type of gene labels in the original data, \texttt{"entrez"} by default \item \texttt{graphIDS} - the type of gene labels to be used in plot, \texttt{"symbol"} by default \item \texttt{layout} - the layout of the graph from \texttt{Rgraphviz} package, \texttt{"dot"} by default, other possibilities are e.g. \texttt{"neato"} or \texttt{"twopi"} \end{itemize} The significant cliques are enhanced in the results of TopologyGSA and clipper. Since the whole analysis with these method is done on transformed topology (moralized then triangulated graphs), the transformed topology is also drawn in the visualization. The user can specify the color which used for edges between nodes from a significant clique (default value is \texttt{cli.color="red"} and can be either a character or a function that returns a color pallette) and the color of nodes (default value is \texttt{cli.node.color="white"}. The \texttt{alpha} controls the significance threshold for the cliques. If \texttt{add.legend=TRUE} then a legend is drawn containing the colors of edges of individual cliques, their genes and p-value. The \texttt{intersp} can be used to adjust the space between items of legened. << plot1, fig=false, width=8, height=7, eval=false>>= #Fails during check library(gageData) data(hnrnp.cnts) group<-c(rep("sample",4), rep("control",4)) hnrnp.cnts<-hnrnp.cnts[rowSums(hnrnp.cnts)>0,] res<-clipper(hnrnp.cnts, group, pathways[1:2], type="RNASeq", testCliques=TRUE) plot(res,1, pathways) @ In the visualization of the results from PRS, PWEA or SPIA method, the nodes are colored accoring to the selected gene-level statistic and the size of node reflects the topological significance of a node. Because TAPPA and DEGraph do not provide any specific topological or statistical measure at gene-level, only the coloring of the nodes according to gene-level statistics is used. The user can specify the number of breaks for gene statistics and topological significance of genes (default values are 100 and 5, \texttt{breaks=c(100,5)}), colors in the pallete for the gene statistics (default is \texttt{pallete.colors=c("blue","white", "red")} and a color for missing nodes \texttt{na.col="grey"}. The \texttt{stats} argument controls the label of the gene statistics and \texttt{title} controls whether the name of a pathway and its p-value should be written as a title. The user can also adjust the size of the nodes (\texttt{nodesize}) and font (\texttt{fontsize}) <>= library(gageData) data(hnrnp.cnts) group<-c(rep("sample",4), rep("control",4)) hnrnp.cnts<-hnrnp.cnts[rowSums(hnrnp.cnts)>0,] pathways<-pathways("hsapiens", "kegg")[50:55] spi<-SPIA(hnrnp.cnts, group, pathways, type="RNASeq", logFC.th=-1) plot(spi,"Complement and coagulation cascades", pathways, fontsize=50) @ \begin{figure}[tbp] \centering \includegraphics{plot} \caption{} \end{figure} \begin{thebibliography}{} \bibitem[Al-Haj~Ibrahim {\em et~al.}(2012)]{Ibrahim} Al-Haj~Ibrahim, M., Jassim, S., Cawthorne, M.~A., and Langlands, K. (2012). A topology-based score for pathway enrichment. {\em J Comput Biol\/}. \bibitem[Anders and Huber(2010)]{DESeq} Anders, S. and Huber, W. (2010). Differential expression analysis for sequence count data. {\em Genome Biology\/}, {\bf 11}(10), R106. \bibitem[Dillies {\em et~al.}(2013)]{Dillies} Dillies, M.-A., Rau, A., Aubert, J., Hennequet-Antier, C., Jeanmougin, M., Servant, N., Keime, C., Marot, G., Castel, D., Estelle, J., Guernec, G., Jagla, B., Jouneau, L., Laloe, D., Le~Gall, C., Schaeffer, B., Le~Crom, S., Guedj, M., and Jaffrezic, F. (2013). A comprehensive evaluation of normalization methods for illumina high-throughput rna sequencing data analysis. {\em Briefings in Bioinformatics\/}, {\bf 14}(6), 671--683. \bibitem[Draghici {\em et~al.}(2007)]{Draghici} Draghici, S., Khatri, P., Tarca, A.~L., Amin, K., Done, A., Voichita, C., Georgescu, C., and Romero, R. (2007). A systems biology approach for pathway level analysis. {\em Genome Research\/}, {\bf 17}(10), 000. \bibitem[Gao and Wang(2007)]{TAPPA} Gao, S. and Wang, X. (2007). Tappa: topological analysis of pathway phenotype association. {\em Bioinformatics\/}, {\bf 23}(22), 3100--3102. \bibitem[Hung {\em et~al.}(2010)]{Hung} Hung, J.-H., Whitfield, T., Yang, T.-H., Hu, Z., Weng, Z., and DeLisi, C. (2010). Identification of functional modules that correlate with phenotypic difference: the influence of network topology. {\em Genome Biology\/}, {\bf 11}(2), R23. \bibitem[{Jacob} {\em et~al.}(2010)]{Jacob} {Jacob}, L., {Neuvial}, P., and {Dudoit}, S. (2010). {Gains in Power from Structured Two-Sample Tests of Means on Graphs}. {\em ArXiv e-prints\/}. \bibitem[Martini {\em et~al.}(2012)]{clipper} Martini, P., Sales, G., Massa, M.~S., Chiogna, M., and Romualdi, C. (2012). Along signal paths: an empirical gene set approach exploiting pathway topology. {\em Nucleic Acids Research\/}. \bibitem[Massa {\em et~al.}(2010)]{Massa} Massa, M., Chiogna, M., and Romualdi, C. (2010). Gene set analysis exploiting the topology of a pathway. {\em BMC Systems Biology\/}, {\bf 4}(1), 121. \bibitem[{R Core Team}(2014)]{R} {R Core Team} (2014). {\em R: A Language and Environment for Statistical Computing\/}. R Foundation for Statistical Computing, Vienna, Austria. \bibitem[Robinson and Oshlack(2010]{TMM} Robinson, M. and Oshlack, A. (2010). A scaling normalization method for differential expression analysis of rna-seq data. {\em Genome Biology\/}, {\bf 11}(3), R25. \bibitem[Sales {\em et~al.}(2012)]{graphite} Sales, G., Calura, E., Cavalieri, D., and Romualdi, C. (2012). graphite - a bioconductor package to convert pathway topology to gene network. {\em BMC Bioinformatics\/}, {\bf 13}(1), 20. \bibitem[Tarca {\em et~al.}(2009)]{Tarca} Tarca, A.~L., Draghici, S., Khatri, P., Hassan, S.~S., Mittal, P., Kim, J.-s., Kim, C.~J., Kusanovic, J.~P., and Romero, R. (2009). A novel signaling pathway impact analysis. {\em Bioinformatics\/}, {\bf 25}(1), 75--82. \end{thebibliography} \end{document}