Creating Interactive Omics Network Objects

Loading data is relatively straightforward. This package is primarily designed for undirected and simple networks. Simple graphs do not have multiple edges (different modes of regulation) and do not contain loops (self-regulation). If you are building network objects from unweighted or weighted adjacency matrices, the graph objects will be looking at the lower portion of the matrix (although symmetric matrices are fine).

Adjacency Matrix

set.seed(1)
adj <- ex.adj()
print(adj)
      10413 25937 9113 26524 983
10413     0     0    0     0   0
25937     1     0    0     0   0
9113      1     0    0     0   0
26524     1     0    0     0   0
983       0     1    0     0   0

We could use this as is but vertices need to be unique, this causes a problem when there is multi-mapping of probes to genes, proteins, etc. Therefore when building a network object, you can pass a mapping of vertex identifiers to gene symbols. This allows downstream methods to switch between vertex ids and human-readable symbols. If no symbols are provided, the vertex ids will be used by default.

symbols <- LETTERS[1:5]
names(symbols) <- colnames(adj)
head(symbols)
10413 25937  9113 26524   983 
  "A"   "B"   "C"   "D"   "E" 
ionet <- create.ionet(adj, type="adj", symbols=symbols)
ionet$plt.subnetwork("10413", degree=2, use.symbols=TRUE)

Weighted Adjaceny Matrix

set.seed(1)
wadj <- ex.wadj()
print(wadj)

ionet <- create.ionet(wadj, type="wadj", symbols=symbols)

Graph Objects

The easiest method is to start with a properly formatted igraph object.

data(ig)

ig
IGRAPH 0e74c33 UN-- 10 9 -- 
+ attr: name (v/c)
+ edges from 0e74c33 (vertex names):
[1] 10413--25937 10413--9113  10413--26524 10413--983   10413--6788  26524--55233 26524--9891  983  --4771  6788 --60485

See here the nodes are entrez ids. Also, please make sure your ids are characters when working with igraph…

ids <- as_ids(V(ig))
head(ids)
[1] "10413" "25937" "9113"  "26524" "983"   "55233"

Here we can use this helper function to make a mapping to hugo symbols…

library(biomaRt)
ensembl <- biomaRt::useMart("ensembl", dataset="hsapiens_gene_ensembl")
convert.ids <- function(ids, type=NULL) {
    conversion <- biomaRt::getBM(attributes=c(type, "hgnc_symbol"), filters=type, values=ids, mart=ensembl)
    symbols <- conversion$hgnc_symbol[match(ids, conversion[,type])]
    names(symbols) <- ids
    return(symbols)
}
symbols <- convert.ids(ids, type="entrezgene_id")
symbols
  10413   25937    9113   26524     983   55233    6788    4771   60485    9891 
 "YAP1" "WWTR1" "LATS1" "LATS2"  "CDK1" "MOB1A"  "STK3"   "NF2"  "SAV1" "NUAK1" 
ionet <- create.ionet(ig, type="ig", symbols=symbols)

Object Structure

str(ionet)
Classes 'interactive.omics.network', 'R6' <interactive.omics.network>
  Public:
    clone: function (deep = FALSE) 
    edges: data.frame
    get.interactors: function (ids, degree = 1, remove.ids = TRUE, use.symbols = FALSE) 
    get.subnetwork: function (ids, degree = 1, indirect.edges = FALSE) 
    get.symbols: function (ids) 
    ig: igraph
    init.edges: function () 
    init.nodes: function (symbols = NULL, measures = c(), quiet = TRUE) 
    init.properties: function (measures = c(), quiet = TRUE) 
    initialize: function (ig, symbols = NULL, graph.measures = c("nodes", "edges", 
    nodes: data.frame
    pca: PCA, list
    plt.subnetwork: function (ids, degree = 1, indirect.edges = FALSE, use.symbols = FALSE, 
    print: function () 
    properties: list 
head(ionet$nodes)
         id label symbol degree     eigen betweenness stress
10413 10413 10413   YAP1      5 1.0000000          31     31
25937 25937 25937  WWTR1      1 0.4110917           0      0
9113   9113  9113  LATS1      1 0.4110917           0      0
26524 26524 26524  LATS2      3 0.6209777          15     15
983     983   983   CDK1      2 0.4946931           8      8
55233 55233 55233  MOB1A      1 0.2552788           0      0

Lots of Networks

A main focus of this package is to compare networks. A lot of functions simply take a list of network objects as a primary argument. The only strong suggestion here is that the dimensions of your networks should be the same. This is typically not a problem when your networks are reconstructions between different phenotypes, but can be problematic (and impossible) when comparing networks from completely different sources.

This also means you should be using the same vector of symbols when generating each of the objects This isn’t required for command line usage, but it is for the shiny application, and it’ll save you a lot of headaches down the line. With that being said, if it makes sense for you networks to have the same set of vertices, please try to do so.

In the future we plan to implement methods for comparing networks with different vertex sets.

igs <- list("N1"=ig, "N2"=ig, "N3"=ig)

ionets <- lapply(igs, function(x) {
    create.ionet(x, type="ig")
})

# or
ionets <- create.ionets(igs, type="ig")
print(ionets)
$N1
IGRAPH 0e74c33 UN-- 10 9 -- 
+ attr: name (v/c)
+ edges from 0e74c33 (vertex names):
[1] 10413--25937 10413--9113  10413--26524 10413--983   10413--6788  26524--55233 26524--9891  983  --4771  6788 --60485

$N2
IGRAPH 0e74c33 UN-- 10 9 -- 
+ attr: name (v/c)
+ edges from 0e74c33 (vertex names):
[1] 10413--25937 10413--9113  10413--26524 10413--983   10413--6788  26524--55233 26524--9891  983  --4771  6788 --60485

$N3
IGRAPH 0e74c33 UN-- 10 9 -- 
+ attr: name (v/c)
+ edges from 0e74c33 (vertex names):
[1] 10413--25937 10413--9113  10413--26524 10413--983   10413--6788  26524--55233 26524--9891  983  --4771  6788 --60485

Omics Network Objects

Interactive omics networks are an extension of the omics network object written specifically for the Bieulergy R package and Shiny application. It’s designed for interactive analysis of multiple networks with accessory omics data. If you are working with omics network objects, the constructor function will help you make it compatible with Bieulergy.

devtools::install_github("montilab/omics-network")
data(omics)
onet <- omics.network$new(omics)
onet$peek()
Omics Network Object
IGRAPH d2faa53 UN-- 331 362 -- 
+ attr: name (v/c), label (v/c), is_tf (v/l), lfc_rna (v/n), snp_frq (v/n), cor (e/n), name (e/c)
+ edges from d2faa53 (vertex names):
  [1] 749--751 749--109 743--692 740--737 740--452 737--454 737--637 735--702 733--398 717--256 715--288 711--442 708--747 708--707 704--177 704--176 702--529 692--694 692--212 690--544 688--234 686--215 683-- 79 674--243 668--262 666--285 664--622 662--261 659--578 659--153 659--729 659--727 659--725 659--134 659--722 659--657 657--577 646--648 646--122 643--371 643--366 640--545 640--329 631--186 631--185 629--230 622--416 620--603 215--618 618--617 615-- 62 615--614 612--300 612--294 285--612 609--325 607--107 285--603 614--601 637--601 601--599 599--478 593--349 591--353 591--590 325--581
 [67] 581--193 578--577 574--340 571--409 571--246 552--558 552--527 548--554 552--548 548--534 527--548 548--526 544--545 542--124 540--343 538--324 527--534 532--516 529--530 527--526 107--522 520-- 99 503--504 501--195 498--499 495--224 285--495 285--493 491--259 489--127 487--341 487--486 224--484 484--482 482--226 478--479 476--447 473--474 470--471 468--241 325--466 464--429 452--460 452--458 452--456 452--454 452--167 449--450 447--146 285--445 442--443 440--337 609--438 438--352 438--162 438--159 438--437 434--435 431--432 429--198 427--696 427--426 423--424 421--720 421--189 421--420
[133] 416--417 215--414 406--412 406--344 409--406 406--407 404--327 401--506 401--597 401--595 454--401 401--400 398--167 640--395 468--395 395--391 387--157 387--155 391--387 387--132 387--130 387--128 381--385 381--383 381--378 378--379 376--249 224--374 374--235 371--372 369--183 366--367 353--364 364--587 364--585 224--362 359--360 597--356 595--356 356--355 353--352 349--350 343--347 343--290 343--344 493--341 341--309 340--341 337--338 506--335 335--334 329--332 329--330 285--327 325--434 325--435 325--324 322--311 316--292 285--316 316--315 322--313 215--309 306--307 686--298 445--298
[199] 612--296 296--104 532--292 285--300 285--298 285--296 285--294 285--292 285--290 288--285 285--286 224--280 280--264 280--270 280--268 278--303 303--276 167--276 278--275 276--275 272--273 264--270 264--268 261--266 261--264 262--261 259--258 256--251 298--254 254--253 249--244 409--247 246--247 362--244 243--244 241--676 414--239 272--237 234--241 234--239 234--237 234--235 230--232 230--228 230--226 230--482 230--482 230--224 230--264 230--374 230--221 224--226 224--464 224--347 224--136 232--222 230--222 228--222 226--222 224--221 221--222 219--536 215--217 215--581 215--192 215--650
[265] 212--217 212--215 212--213 207--210 207--208 406--203 195--205 195--203 195--201 195--142 195--198 195--196 193--192 189--190 186--369 185-- 77 186--185 183--179 179--181 136--179 177--176 285--174 172--512 313--170 311--170 251--168 167--174 167--172 167--170 167--168 164--165 162--160 159--160 235--142 128--219 127--157 127--155 153--127 127--125 127--150 127--148 127--146 127--144 127--142 127--140 127--138 127--136 134--127 127--132 127--130 127--128 387--125 124--125 122--121 646--119 306--119 607--117 522--117 117--106 364--114 207--110 109--119 109--117 109--107 109--114 109--112
[331] 109--110 107--106 300--104 294--104 285--104 104--286 104--101 101--102  99--672  99--391 122-- 99  99-- 98  93-- 91  91-- 90  93-- 88  90-- 88  88-- 87  84-- 85  79--518  79--516  79--514  79-- 77  77-- 76  74-- 65  72-- 81  81-- 70  72-- 69  70-- 69  65-- 67  65-- 64  62-- 84  62-- 61
head(onet$nodes.attributes())
    name label is_tf    lfc_rna     snp_frq
749  749  MTH1 FALSE -0.4385177 0.035319994
751  751  SNF3 FALSE  0.1285503 0.003035238
109  109  LSM8 FALSE -0.5849400 0.062844766
743  743  ASN1 FALSE  1.1166966 0.229042875
692  692 SPC24 FALSE  0.2306554 0.009771783
740  740  GIP2 FALSE -0.5743279 0.060585153
symbols <- onet$nodes("label")
names(symbols) <- onet$nodes("name")
ionet <- create.ionet(onet, type="onet", symbols=symbols)

Network Data Exchange

The Network Data Exchange (NDEx) Project is an open-source framework for storing, sharing, and manipulating published biological networks. Here we provide a useful wrapper function for pulling NDEx objects and formatting them into Interactive Omics Network objects for use in Bieulergy.

ndex <- function(uuid) {
    ndexcon <- ndex_connect()
    data <- ndex_get_network(ndexcon, uuid)
    mat <- as.matrix(data$edges)
    storage.mode(mat) <- "character"
    ig <- igraph::graph_from_edgelist(mat[,c("s", "t")], directed=FALSE)
    ids <- data$nodes[match(as.numeric(igraph::as_ids(V(ig))), data$nodes[,"@id"]), "n"]
    V(ig)$label <- ids
    return(ig)
}
# Global landscape of HIV–human protein complexes.
# Jaeger et al. Nature. 2011 Dec 21; 481(7381): 365–370
# @UUID: 1cbe89ab-fb5d-11e9-bb65-0ac135e8bacf

ig <- ndex("1cbe89ab-fb5d-11e9-bb65-0ac135e8bacf")
ionet <- create.ionet(ig, type="ig")