When you want to get to know and love your data

Tutorial- Building Biological Networks

I love networks! Nothing is better for visualizing complex multivariate relationships be it social, virtual or biological.Bionetwork1

I recently gave a hands-on network building tutorial using R and Cytoscape to build large biological networks. In these networks Nodes represent metabolites and edges can be many things, but I specifically focused on biochemical relationships and chemical similarities. Your imagination is the limit.

genotype network


network DM

If you are interested check out the presentation below.

Here is all the R code and links to relevant data you will need to let you follow along with the tutorial.

#load needed functions: R package in progress - "devium", which is stored on github
# get sample chemical identifiers here:https://docs.google.com/spreadsheet/ccc?key=0Ap1AEMfo-fh9dFZSSm5WSHlqMC1QdkNMWFZCeWdVbEE#gid=1
#Pubchem CIDs = cids
cids # overview
nrow(cids) # how many
str(cids) # structure, wan't numeric 
cids<-as.numeric(as.character(unlist(cids))) # hack to break factor

#making an edge list based on CIDs from KEGG reactant pairs
dim(KEGG.edge.list) # a two column list with CID to CID connections based on KEGG RPAIS
# how did I get this?
#1) convert from CID to KEGG using get.CID.KEGG.pairs(), which is a table stored:https://gist.github.com/dgrapov/4964546
#2) get KEGG RPAIRS using get.KEGG.pairs() which is a table stored:https://gist.github.com/dgrapov/4964564
#3) return CID pairs

#get EDGES based on chemical similarity (Tanimoto distances >0.07)
tanimoto.edges<-CID.to.tanimoto(cids=cids, cut.off = .7, parallel=FALSE)
# how did I get this?
#1) Use R package ChemmineR to querry Pubchem PUG to get molecular fingerprints
#2) calculate simialrity coefficient
#3) return edges with similarity above cut.off

#after a little bit of formatting make combined KEGG + tanimoto edge list
# https://docs.google.com/spreadsheet/ccc?key=0Ap1AEMfo-fh9dFZSSm5WSHlqMC1QdkNMWFZCeWdVbEE#gid=2

#now upload this and a sample node attribute table (https://docs.google.com/spreadsheet/ccc?key=0Ap1AEMfo-fh9dFZSSm5WSHlqMC1QdkNMWFZCeWdVbEE#gid=1)
#to Cytoscape 

You can also download all the necessary materials HERE, which include:

  1. tutorial in powerpoint
  2. R script
  3. Network edge list and node attributes table
  4. Cytoscape file
Happy network making!



4 responses

  1. Iain Gallagher


    Looks like fun. Pulling in pastebin source leads to:

    Error in function (classes, fdef, mtable) :
    unable to find an inherited method for function “.gwindow”, for signature “guiWidgetsToolkitRGtk2”

    What do I not have? Thanks.


    Session info below.

    R version 2.15.1 (2012-06-22)
    Platform: x86_64-pc-linux-gnu (64-bit)


    attached base packages:
    [1] stats graphics grDevices utils datasets methods base

    other attached packages:
    [1] proto_0.3-9.2 gWidgets_0.0-52 RGtk2_2.20.25 RCurl_1.95-3 bitops_1.0-4.2

    loaded via a namespace (and not attached):
    [1] tools_2.15.1

    April 5, 2013 at 8:14 pm

    • Hi Iain,

      I just upgraded to R 3.0.0 and, running the code in question “source(“http://pastebin.com/raw.php?i=Y0YYEBia”)” on a fresh install gives me no problems. Comparing my and your session it looks like the error is caused by your lack of: gWidgetsRGtk2_0.0-81. Note- you don’t necessarily need the GUI and can instead get the working functions from the following repos:

      Here is my session info:

      R version 3.0.0 (2013-04-03)
      Platform: i386-w64-mingw32/i386 (32-bit)

      [1] LC_COLLATE=English_United States.1252
      [2] LC_CTYPE=English_United States.1252
      [3] LC_MONETARY=English_United States.1252
      [4] LC_NUMERIC=C
      [5] LC_TIME=English_United States.1252

      attached base packages:
      [1] stats graphics grDevices utils datasets methods
      [7] base

      other attached packages:
      [1] cairoDevice_2.19 proto_0.3-10 gWidgetsRGtk2_0.0-81
      [4] gWidgets_0.0-52 RGtk2_2.20.25 RCurl_1.95-4.1
      [7] bitops_1.0-5

      loaded via a namespace (and not attached):
      [1] tools_3.0.0

      Hope this helps!

      April 5, 2013 at 9:56 pm

      • Iain Gallagher

        Thanks Dmitry

        Source install of gWidgetsRGtk2_0.0-81 solves the problem. Will have a romp through your tutorial now.



        April 6, 2013 at 11:33 am

  2. Pingback: Tutorial- Building Biological Networks | Methodologist & Psychometrician to be

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s