library(knitr) opts_chunk$set(out.extra='style="display:block; margin: auto"', fig.align="center", fig.width=12, fig.height=12, tidy=TRUE)
BiocStyle::markdown()
The netboxr package composes a number of functions to retrive and process genetic data from large-scale genomics projects (e.g. TCGA projects) including from mutations, copy number alterations, gene expression and DNA methylation. The netboxr package implements NetBox algorithm in R package. NetBox algorithm integrates genetic alterations with literature-curated pathway knowledge to identify pathway modules in cancer. NetBox algorithm uses (1) global network null model and (2) local network null model to access the statistic significance of the discovered pathway modules.
BiocManager::install("netboxr")
Load netboxr package:
library(netboxr)
A list of all accessible vignettes and methods is available with the following command:
help(package="netboxr")
For help on any netboxr package functions, use one of the following command formats:
help(geneConnector) ?geneConnector
This is an example to reproduce the network discovered on Cerami et al.(2010).
The results presented here are comparable to the those from Cerami et al. 2010 though the unadjusted p-values for linker genes are not the same. It is because the unadjusted p-value of linker genes in Cerami et al. 2010 were calculated by the probabiliy of the observed data point, Pr(X). The netboxr used the probability of an observed or more extreme assuming the null hypothesis is true, Pr(X>=x|H), as unadjusted p-value for linker genes. The final number of linker genes after FDR correction are the same between netboxr result and original Cerami et al. 2010.
Load pre-defined HIN network and simplify the interactions by removing loops and duplicated interactions in the network. The netowork after reduction contains 9264 nodes and 68111 interactions.
data(netbox2010) sifNetwork <- netbox2010$network graphReduced <- networkSimplify(sifNetwork,directed = FALSE)
The altered gene list contains 517 candidates from mutations and copy number alterations.
geneList <- as.character(netbox2010$geneList) length(geneList)
The geneConnector function in the netboxr package takes altered gene list as input and maps the genes on the curated network to find the local processes represented by the gene list.
## Use Benjamini-Hochberg method to do multiple hypothesis ## correction for linker candidates. ## Use edge-betweeness method to detect community structure in the network. threshold <- 0.05 results <- geneConnector(geneList=geneList, networkGraph=graphReduced, directed=FALSE, pValueAdj="BH", pValueCutoff=threshold, communityMethod="ebc", keepIsolatedNodes=FALSE) # Add edge annotations library(RColorBrewer) edges <- results$netboxOutput interactionType<-unique(edges[,2]) interactionTypeColor<-brewer.pal(length(interactionType),name="Spectral") edgeColors<-data.frame(interactionType,interactionTypeColor,stringsAsFactors = FALSE) colnames(edgeColors)<-c("INTERACTION_TYPE","COLOR") netboxGraphAnnotated <- annotateGraph(netboxResults = results, edgeColors = edgeColors, directed = FALSE, linker = TRUE) # Check the p-value of the selected linker linkerDF <- results$neighborData linkerDF[linkerDF$pValueFDR<threshold,] # The geneConnector function returns a list of data frames. names(results) # Plot graph with the Fruchterman-Reingold layout algorithm # As an example, plot both the original and the annotated graphs # Save the layout for easier comparison graph_layout <- layout_with_fr(results$netboxGraph) # plot the original graph plot(results$netboxCommunity,results$netboxGraph, layout=graph_layout) # Plot the edge annotated graph plot(results$netboxCommunity, netboxGraphAnnotated, layout = graph_layout, vertex.size = 10, vertex.shape = V(netboxGraphAnnotated)$shape, edge.color = E(netboxGraphAnnotated)$interactionColor, edge.width = 3) # Add interaction type annotations legend("bottomleft", legend=interactionType, col=interactionTypeColor, lty=1,lwd=2, bty="n", cex=1)
The GBM result by netboxr identified exactly the same linker genes (6 linker genes), the same number of modules (10 modules) and the same genes in each identified module as GBM result in Cerami et al. 2010.
The results of netboxr are consistent with previous implementation of the NetBox algorithm. The RB1 and PIK3R1 modules are clearly represented in the figure. For example, the RB1 module contains genes in blue color and enclosed by light orange circle. The PIK3R1 module contains genes in orange color and enclosed by pink circle.
NetBox algorithm used (1) global network null model and (2) local network null model to access the statistical significance of the discovered network.
The global network null model calculates the empirical p-value as the number of times (over a set of iterations) the size of the largest connected component (the giant component) in the network coming from the same number of randomly selected genes (number of genes is 274 in this example) equals or exceeds the size of the largest connected component in the observed network. The suggested iterations are 1000.
## This function will need a lot of time to complete. globalTest <- globalNullModel(netboxGraph=results$netboxGraph, networkGraph=graphReduced, iterations=10, numOfGenes = 274)
Local network null model evaluates the deviation of modularity in the observed network from modularity distribution in the random network. For each interaction, a random network is produced from local re-wiring of literature curated network. It means all nodes in the network kept the same degree of connections but connect to new neighbors randomly. Suggested iterations is 1000.
localTest <- localNullModel(netboxGraph=results$netboxGraph, iterations=1000)
Through 1000 iterations, we can obtain the mean and the standard deviation of modularity in the local network null model. Using the mean (~0.3) and the standard deviation (0.06), we can covert the observed modularity in the network (0.519) into a Z-score (~3.8). From the Z-score, we can calculate one-tail p-value. If one-tail pvalue is less than 0.05, the observed modularity is significantly different from random. In the histogram, the blue region is the distribution of modularity in the local network null model. The red vertical line is the observed modularity in the NetBox results.
h<-hist(localTest$randomModularityScore,breaks=35,plot=FALSE) h$density = h$counts/sum(h$counts) plot(h,freq=FALSE,ylim=c(0,0.1),xlim=c(0.1,0.6), col="lightblue") abline(v=localTest$modularityScoreObs,col="red")
The global null model is used to assess the global connectivity (number of nodes and edges) of the largest module in the identified network compared with the same number but randomly selected gene list.
The local null model is used to assess the network modularity in the identified network compared with random re-wired network.
The table below shows the module memberships for all genes.
DT::datatable(results$moduleMembership, rownames = FALSE)
# Write results for further visilaztion in the cytoscape software. # # network.sif file is the NetBox algorithm output in SIF format. write.table(results$netboxOutput, file="network.sif", sep="\t", quote=FALSE, col.names=FALSE, row.names=FALSE) # # netighborList.txt file contains the information of all neighbor nodes. write.table(results$neighborData, file="neighborList.txt", sep="\t", quote=FALSE, col.names=TRUE, row.names=FALSE) # # community.membership.txt file indicates the identified pathway module numbers. write.table(results$moduleMembership, file="community.membership.txt", sep="\t", quote=FALSE, col.names=FALSE, row.names=FALSE) # # nodeType.txt file indicates the node is "linker" node or "candidate" node. write.table(results$nodeType,file="nodeType.txt", sep="\t", quote=FALSE, col.names=FALSE, row.names=FALSE)
After module identification, one main task is understanding the biological processes that may be represented by the returned modules. Here we use the Bioncoductor clusterProfiler to do an enrichment analysis using GO Biological Process terms on a selected module.
library(clusterProfiler) library(org.Hs.eg.db) module <- 6 selectedModule <- results$moduleMembership[results$moduleMembership$membership == module,] geneList <-selectedModule$geneSymbol # Check available ID types in for the org.Hs.eg.db annotation package keytypes(org.Hs.eg.db) ids <- bitr(geneList, fromType="SYMBOL", toType=c("ENTREZID"), OrgDb="org.Hs.eg.db") head(ids) ego <- enrichGO(gene = ids$ENTREZID, OrgDb = org.Hs.eg.db, ont = "BP", pAdjustMethod = "BH", pvalueCutoff = 0.01, qvalueCutoff = 0.05, readable = TRUE)
head(ego)
dotplot(ego)
In netboxr, we used the Girvan-Newman algorithm (communityMethod="ebc") as the default method to detect community membership in the identified network. The Girvan-Newman algorithm iteratativly removes the edge in the network with highest edge betweeness until no edges left. When the identified network contains many edges, the Girvan-Newman algorithm will spend a large amount of time to remove edges and re-calucalte the edge betweenese score in the network. If the user cannot get the community detection result in reasonable time, we suggest to switch to leading eigenvector method (communityMethod="lec") for community detection. Users can check original papers of the Girvan-Newman algorithm and leading eigenvector method for more details.
Users can load alternative pathway data formatted in the SIF format (Simple Interaction Format). SIF is a space/tab separated format that summarizes interactions in a graph as an edgelist. In the format, every row corresponds to an individual interaction (edge) between a source and a target node. NOTE: An arbitrary interaction type can be used, such as "interacts" if the true interaction type is unknown.
PARTICIPANT_A INTERACTION_TYPE PARTICIPANT_B nodeA relationship nodeB nodeC relationship nodeA nodeD relationship nodeE
Resources, such as the Functional Interaction network from Reactome (https://reactome.org/download-data) and StringDB (https://string-db.org/) provide network information in formats reusable as a SIF. NOTE: The next section demonstrates how to retrieve SIF-based networks for many well-known interaction databases using paxtoolsr.
SIF formatted data can be passed to networkSimplify(). The result of which is used with the geneConnector() function as other examples in this vignette demonstrate.
example <- "PARTICIPANT_A INTERACTION_TYPE PARTICIPANT_B TP53 interacts MDM2 MDM2 interacts MDM4" sif <- read.table(text=example, header=TRUE, sep="\t", stringsAsFactors=FALSE) graphReduced <- networkSimplify(sif, directed = FALSE)
Users can load alternative pathway data from the Pathway Commons repository using the paxtoolsr package from Bioconductor. This pathway data represents an update to the Pathway Commons data used in the original 2010 NetBox publication. Below is an example that makes use of data from the Reactome pathway database.
NOTE: Downloaded data is automatically cached to avoid unnecessary downloads.
library(paxtoolsr) filename <- "PathwayCommons.8.reactome.EXTENDED_BINARY_SIF.hgnc.txt.gz" sif <- downloadPc2(filename, version="8") # Filter interactions for specific types interactionTypes <- getSifInteractionCategories() filteredSif <- filterSif(sif$edges, interactionTypes=interactionTypes[["BetweenProteins"]]) filteredSif <- filteredSif[(filteredSif$INTERACTION_TYPE %in% "in-complex-with"), ] # Re-run NetBox algorithm with new network graphReduced <- networkSimplify(filteredSif, directed=FALSE) geneList <- as.character(netbox2010$geneList) threshold <- 0.05 pcResults <- geneConnector(geneList=geneList, networkGraph=graphReduced, directed=FALSE, pValueAdj="BH", pValueCutoff=threshold, communityMethod="lec", keepIsolatedNodes=FALSE) # Check the p-value of the selected linker linkerDF <- results$neighborData linkerDF[linkerDF$pValueFDR<threshold,] # The geneConnector function returns a list of data frames. names(results) # plot graph with the Fruchterman-Reingold layout algorithm plot(results$netboxCommunity,results$netboxGraph, layout=layout_with_fr)
The main input for the NetBox algorithm is an input list of "significantly" altered genes. Each project is different, unique considerations for how significance should be considered may be required. Researchers may seek stronger thresholds of significance for particular questions and different profiling technologies may have their own considerations. It is beyond the scope of this work to provide guidance for all situations.
However, to help users better understand the process of generating an input gene list we provide examples using best practices derived from the The Cancer Genome Project using the cBioPortal (http://cbioportal.org/), a platform that aggregates clinical genomics datasets into a standard representation. As of August 2020, cBioPortal has approximately 290 studies. In cases where appropriate data is available a similar procedure to the example can be used.
For TCGA studies on cBioPortal, users can access pre-processed datasets from the cBioPortal DataHub that contain significantly altered genes by mutations and copy number. Example study link: https://github.com/cBioPortal/datahub/tree/master/public/acc_tcga
Users are directed to the accompanying study publications; study publication details are in the 'meta_study.txt' file for a study.
Users can download cancer alteration data from cBioPortal using the cgdsr package from CRAN. Here we show how a simple example for selecting genes for use with netboxr for datasets provided by cBioPortal using a using a 10% alteration frequency threshold to select genes; this general procedure has previously been used as part of TCGA studies. In the example, we consider:
The resulting gene list then becomes an input for netboxr. The resulting gene list will select EGFR and TP53, which have high alteration frequencies in glioblastoma (GBM) over the housekeeping genes ACTB and GAPDH, which have very low alteration frequencies.
library(cBioPortalData) cbio <- cBioPortal(hostname = "www.cbioportal.org", protocol = "https", api. = "/api/api-docs") # Find available studies, caselists, and geneticProfiles studies <- getStudies(cbio) samps<-sampleLists(cbio, "gbm_tcga_pub") # find samples with both mutation and copy number data caseList <- "gbm_tcga_pub_cnaseq" geneticProfileTables <- molecularProfiles(api = cbio, studyId = "gbm_tcga_pub") genes <- c("EGFR", "TP53", "RB1") results <- sapply(genes, function(gene) { message(sprintf("Work on %s gene",gene)) cna <- getDataByGenes( cbio, studyId = "gbm_tcga_pub", genes = gene, by = "hugoGeneSymbol", molecularProfileId = "gbm_tcga_pub_cna_consensus", sampleListId = caseList) mut <- getDataByGenes( cbio, studyId = "gbm_tcga_pub", genes = gene, by = "hugoGeneSymbol", molecularProfileId = "gbm_tcga_pub_mutations", sampleListId = caseList) cna <- cbind(cna[[1]][5], cna[[1]][8]) mut <- cbind(mut[[1]][4], mut[[1]][14]) dat <- merge(cna, mut, by = "sampleId", all = TRUE) cna <- dat$value mut <- dat$proteinChange tmp <- data.frame(cna=cna, mut=mut, stringsAsFactors = FALSE) tmp$isAltered <- abs(tmp$cna) == 2 | !is.na(tmp$mut) # Amplification or Deep Deletion or any mutation freq<-length(which(tmp$isAltered))/nrow(tmp) return(freq) }, USE.NAMES = TRUE) # 10 percent alteration frequency cutoff geneList <- names(results)[results > 0.1]
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.