Skip to content

R interface for the network inference MCMC C software graph_sampler (very raw prototype)

Notifications You must be signed in to change notification settings

wwiecek/rgraphsampler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rgraphsampler

Graph_Sampler is a network inference and simulation package developed by Frederic Bois. Graph_Sampler allows you to generate structured random graphs and perform fully Bayesian inference on Bayesian networks' or dynamic Bayesian networks' structure. If you are not familiar with graph_sampler, please refer to the project's website, http://www.nongnu.org/graphsampler/.

rgraphsampler is a simple R interface for calling graph_sampler's C code (v3.1) from R and manipulating the results, designed primarily for non-Linux users.

The objective of rgraphsampler is two-fold:

  1. To make available to R users a convenient tool for performing inference in Graph_Sampler
  2. To make working with outputs of Graph_Sampler analyses easier.

Installation and basic use case

C code included in the package requires compilation from source. Installing from GitHub under Windows, RTools should be enough to compile code.

devtools::install_github("wwiecek/rgraphsampler", build_vignettes = TRUE, 
                         build_opts = c("--no-resave-data", "--no-manual"))

graph_sampler scripts are ran with rgs(); rgs(file_in, file_out) is equivalent to graph_sampler <file_in> <file_out>

library(rgraphsampler)
#select one of the built-in example scripts:
script_file <- system.file(package="rgraphsampler", 
                           "test_scripts", "script_test_1.txt")
rgs(file_in = script_file, 
    file_out = "gs_output")

See ?rgs for more examples and vignette("rgraphsampler") for a short demonstration.

Differences between R and C versions

R version is fully featured in that it directly uses unmodified graph_sampler code within the package. However, GSL versions of functions are disabled to decrease dependencies for non-Linux users. Therefore the results obtained through R version should be equivalent to running non-GSL version of graph_sampler.

Known bugs, state of the project

Due to nature of bison parsing engine (the tool for reading in input scripts), when errors occur (e.g. due to malformed input script) in the parser, it is recommended to unload the dynamic library before working with any other scripts. This helps R delete some static variables generated by the parser, which otherwise may not reset on errors. To unload the namespace it is enough to do this:

unloadNamespace("rgraphsampler")
library(rgraphsampler)

All of the code included here has been tested with the scripts from graph_sampler's (C version) testing suite. That means this package produces outputs identical to GSL version of graph_sampler that we've tested. However, there is no automated testing of R code and caution is advised.

About

R interface for the network inference MCMC C software graph_sampler (very raw prototype)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published