-
Notifications
You must be signed in to change notification settings - Fork 3
Tutorial R Interface
#R Interface
The R interface can be used to interact with the PGMLaB 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
##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/pgmlabR for Linux and then type R or Rstudio (depending on which one you have installed / prefer.
path = "<project_home>/r_package/pgmlabR/lib/pgmlabR.so"
dyn.load(path);
####Available functions:
All file paths can be either full or absolute 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 reaction_logic_pathway_filepath_, 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 reaction_logic_pathway_filepath_, 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/munin4_pairwise.txt", "../../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/munin4_pairwise.txt", "../../test/data1/estimated_parameters_0.5.txt", "../../test/data1/visibleSet_0.7.txt","../../test/data1/visibleSet_0.5.txt", 2)