Preparing data in R

53 views
Skip to first unread message

Ivan Swart

unread,
Feb 9, 2017, 11:59:50 AM2/9/17
to BioFabric-users
Hello, i've just found biofabric and am excited to what it can do for my data. Until now, all of my data analysis and work has been done in R, more specifically R studio(I'm on a mac as well).  My question is, how do I prepare my data so that it's ready for import into the biofabric visualization. My data is in an adjancency matrix with ID's as the rows and columns. I've tried finding what seems to be a package for R known as bioFabric and have found some results on github, but way to download the package for use.
Any help in this matter would be really appreciated.

Thanks,
Ivan Swart
Northern Michigan University. 

William Longabaugh

unread,
Feb 9, 2017, 1:37:50 PM2/9/17
to biofabr...@googlegroups.com
Ivan:

If you want to use BioFabric in R, then you have the option of using
RBioFabric. Here is a snippet showing how it can be used:

http://stackoverflow.com/questions/22453273/how-to-visualize-a-large-network-in-r

The key library here is igraph, which will allow you to create a network
model from your adjacency matrix. RBioFabric will then take this and
visualize it.

Note that the RBioFabric version is not very full-featured. Another
option is to export a .sif file of your network from R Studio. Again,
igraph should be able to convert your matrix to an interaction list,
which is what a .sif file is. The format for a SIF file is:

node1 [tab] linktag [tab] node2

Singleton nodes are specified as:

node1

Here are some examples:

http://www.biofabric.org/sifFiles.html

If you import the .sif file, you will be able to use the interactive
features of the Java BioFabric version.

In general, being able to create your own network layouts by generating
node row assignments helps immensely to view your data. Here is a post
on that topic:

https://groups.google.com/forum/?nomobile=true#!msg/biofabric-users/uTrTDkzvMSA/nGvv0lQroY4J

Hope this helps. Thanks for your interest in BioFabric!

Bill
> --
> You received this message because you are subscribed to the Google
> Groups "BioFabric-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to biofabric-use...@googlegroups.com
> <mailto:biofabric-use...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Ivan Swart

unread,
Feb 9, 2017, 3:04:30 PM2/9/17
to BioFabric-users
Thanks for the speedy response. I'm now trying to explore igraph to find functions to write the .sif file in the format that you mentioned. Do you know of igraph functions that would be useful in this manner? something like as_adj_list? I tried using write_graph to write the adjacency matrix and got something similar to the examples biofabrics/sifFiles but I know these won't work as they are still just .txt files. Thanks for your help

Ivan Swart

unread,
Feb 9, 2017, 3:06:51 PM2/9/17
to BioFabric-users
thanks for the speedy reply Bill. I am now messing with igraph to convert my matrix into the sif format you have mentioned. I've tried a few things like as_adj_list as well as just write_graph which gave me a .txt file that looked at least similar to the sif files found on bioFabric/sifFile but is obviously not a sif file. Do you know of nay igraph functions that specifically allow me to change my data into the sif format? Thanks for your help. 


On Thursday, February 9, 2017 at 11:59:50 AM UTC-5, Ivan Swart wrote:

Bill Longabaugh

unread,
Feb 9, 2017, 3:16:56 PM2/9/17
to BioFabric-users
I think your best bet is to use write_graph(). That will get the edgelist out into a txt file. You will need to then tweak that file to change the single space to [tab]label[tab] format. Your choice on the label. You can do this with Unix command line tools (e.g. awk, sed). Though if your node names names have spaces in them, you will have a problem. You also will not be handling singleton (degree 0) nodes that have no edges. I imagine you could just iterate through the igraph edgelist and do this manually, though I have not looked into it. 

Bill Longabaugh

unread,
Feb 9, 2017, 8:42:21 PM2/9/17
to BioFabric-users
I have posted some (pretty crude) R code as a gist on GitHub that should get you started:

https://gist.github.com/wjrl/f382598751d44397219ea037dd7a6581

I have a new blog post that describes it as well:

http://biofabric.blogspot.com/2017/02/from-r-igraph-to-java-biofabric-in-one.html

Good luck!

Bill
Reply all
Reply to author
Forward
0 new messages