Repository navigation
Tutorial R Interface
#R Interface
The R interface can be used to interact with the LibNet library through a terminal on either Linux or Mac OSX operating systems.
##Installation
In order to run the c interface you will first need to run the following commands:
make (from the project's root directory)
cd bin
./generateHash <filepath to your pathway file>
cd ../net
make
Once the LibNet shared library has been created (r_package/libnetR/lib/libnetR.so the c interface should be made.
cd r_package/libnetR (from the project's root directory)
make
##Changing pathways
In order to change the pathway you will need to run the following commands:
cd bin (from the project's root directory)
./generateHash <filepath to your new pathway file>
cd ../net
make clean; make
##R interface
In order to go to run the package you will need to go to start from r_package (for OS X) and form r_package/libnetR for Linux and then type R or Rstudio (depending on which one you have installed / prefer.
path = "<project_home>/r_package/libnetR/lib/libnetR.so"
dyn.load(path);
####Available functions:.Call("r_reaction_logic_to_factorgraph", "../../test/data1/munin4_pairwise.txt", "../../test/data1/logical_factorgraph.txt",2)
All filepaths can be either full or abolute paths and the rest of the variables should be supplied as integer values.
The three available functions are:
r_reaction_logic_to_factorgraph(SEXP reaction_logic_pathway_filepath_, SEXP pathway_filepath_, SEXP number_of_states_)
r_learning_discrete_BayNet(SEXP pathway_filepath_, SEXP observed_data_filepath_, SEXP estimated_parameters_filepath_, SEXP number_of_states_, SEXP em_max_iterations_, SEXP em_log_likelihood_change_limit_, SEXP map_flag_, SEXP logging_)
Logging should be set to 1 if you want a log file to be generated while learning is running. This could help you determine if the program is conversing on a solution and how many iterations it has performed so far.
r_doLBPinference(SEXP pathway_filepath_, SEXP observed_data_filepath_, SEXP posterior_probabilities_filepath_, SEXP number_of_states_)
####Call available functions:
All filepaths are full file paths and the rest of the variables should be supplied as integer values. Functions will return 0 upon success and error codes otherwise.
#####Reaction Logic to Factorgraph .Call("r_reaction_logic_to_factorgraph", "../../test/data1/munin4_pairwise.txt", "../../test/data1/logical_factorgraph.txt",2)
####Learning .Call("r_learning_discrete_BayNet", "../../test/data1/logical_factorgraph.txt", "../../test/data1/visibleSet_0.5.txt", "../../test/data1/estimated_parameters_0.5.txt", 2, 4000, 1e-5, 1e-3, 1, 1)
####Inference .Call("r_doLBPinference","../../test/data1/estimated_parameters_0.5.txt", "../../test/data1/visibleSet_0.7.txt","../../test/data1/visibleSet_0.5.txt", 2)