From 74b673ba4a706085201a5610b938ff98f08f641d Mon Sep 17 00:00:00 2001 From: ziejd2 Date: Wed, 25 Apr 2018 16:43:19 -0500 Subject: Bug fixes, code comments, and minor changes --- BNW_parameter_learning/Predictmultiple.m | 22 +- .../Predictmultipleintervention.m | 107 + BNW_parameter_learning/checkDiscreteNodes.m | 2 + BNW_parameter_learning/checkStructure.m | 8 +- BNW_parameter_learning/drawFigure.m | 191 +- BNW_parameter_learning/drawFigureM.m | 11 +- BNW_parameter_learning/parameterLearning.m | 31 + BNW_parameter_learning/prepareInput.m | 21 +- BNW_parameter_learning/readInput.m | 3 + BNW_parameter_learning/readInputData.m | 4 + BNW_parameter_learning/readInputStructure.m | 3 + BNW_parameter_learning/runBN_initial.m | 15 +- BNW_parameter_learning/standardizeData.m | 9 +- BNW_parameter_learning/writeParameters.m | 5 + BNW_parameter_learning/writeParameters_ev.m | 6 + BNW_parameter_learning/writeParameters_int.m | 6 +- sourcecodes/BNW_workflow_net1.htm | 10 +- sourcecodes/BNW_workflow_sci.htm | 6 + sourcecodes/add_evd.php | 7 +- sourcecodes/add_evd_example.php | 9 +- sourcecodes/add_inv.php | 7 +- sourcecodes/add_inv_example.php | 7 +- sourcecodes/bn_file_load_gom.php | 22 +- .../BNT/potentials/@cgpot/marginalize_pot.m | 2 +- sourcecodes/bnt-master/KPMstats/clg_Mstep.m | 8 +- sourcecodes/bnt-master/graph/findroot.m | 2 +- sourcecodes/bnt-master/graph/findroot.m~ | 24 + sourcecodes/create_tiers_gom.php | 3 + sourcecodes/data/example1/Bqxmap.txt | 16 +- sourcecodes/data/example1/Bqxparameters.txt | 34 + sourcecodes/data/example2/hQGmap.txt | 16 +- sourcecodes/data/example2/hQGparameters.txt | 34 + sourcecodes/data/example_chl/bWRmap.txt | 10 +- sourcecodes/data/example_chl/bWRnet_figure.txt | 808 +++--- sourcecodes/data/example_chl/bWRparameters.txt | 21 + sourcecodes/data/example_chr2_spleen/cuLmap.txt | 28 +- .../data/example_chr2_spleen/cuLnet_figure.txt | 2626 ++++++++++---------- .../data/example_chr2_spleen/cuLparameters.txt | 57 + sourcecodes/data/example_sci/Llumap.txt | 10 +- sourcecodes/data/example_sci/Llunet_figure.txt | 808 +++--- sourcecodes/data/example_sci/Lluparameters.txt | 21 + sourcecodes/data/example_time_series/TEbmap.txt | 20 +- .../data/example_time_series/TEbnet_figure.txt | 1818 +++++++------- .../data/example_time_series/TEbparameters.txt | 41 + sourcecodes/data/examplecar15node/MtXmap.txt | 30 +- sourcecodes/data/examplecar15node/eIAmap.txt | 30 +- .../data/examplecar15node/eIAparameters.txt | 82 + sourcecodes/data/old/example_sci_bk/Lluban.txt | 15 + .../old/example_sci_bk/Llucontinuous_input.txt | 503 ++++ .../data/old/example_sci_bk/Llugraphviz.txt | 10 + sourcecodes/data/old/example_sci_bk/Lluk.txt | 1 + sourcecodes/data/old/example_sci_bk/Llumap.txt | 5 + sourcecodes/data/old/example_sci_bk/Llumapdata.txt | 1 + sourcecodes/data/old/example_sci_bk/Lluname.txt | 1 + .../data/old/example_sci_bk/Llunet_figure.txt | 433 ++++ .../data/old/example_sci_bk/Llunet_figure_new.txt | 433 ++++ sourcecodes/data/old/example_sci_bk/Llunlevels.txt | 2 + sourcecodes/data/old/example_sci_bk/Llunnode.txt | 1 + sourcecodes/data/old/example_sci_bk/Llunrows.txt | 1 + sourcecodes/data/old/example_sci_bk/Lluparent.txt | 1 + .../data/old/example_sci_bk/Llustructure_input.txt | 6 + .../old/example_sci_bk/Llustructure_input_temp.txt | 6 + .../data/old/example_sci_bk/Llustructure_old.txt | 5 + sourcecodes/data/old/example_sci_bk/Lluthr.txt | 1 + sourcecodes/data/old/example_sci_bk/Llutier.txt | 1 + sourcecodes/data/old/example_sci_bk/Llutype.txt | 2 + sourcecodes/data/old/example_sci_bk/Lluvar.txt | 1 + sourcecodes/data/old/example_sci_bk/Lluvardata.txt | 1 + sourcecodes/data/old/example_sci_bk/Lluvarname.txt | 1 + sourcecodes/data/old/example_sci_bk/Lluwhite.txt | 1 + .../example_sci_bk/old/Llurun_evidencemodified.sh | 38 + .../example_sci_bk/old/Llurun_initialstructure.sh | 38 + sourcecodes/data/old/examplecar/OVIban.txt | 1 + .../data/old/examplecar/OVIcontinuous_input.txt | 1004 ++++++++ sourcecodes/data/old/examplecar/OVIgraphviz.txt | 70 + sourcecodes/data/old/examplecar/OVIk.txt | 1 + sourcecodes/data/old/examplecar/OVImap.txt | 19 + sourcecodes/data/old/examplecar/OVImapdata.txt | 1 + sourcecodes/data/old/examplecar/OVIname.txt | 1 + sourcecodes/data/old/examplecar/OVInet_figure.txt | 237 ++ .../data/old/examplecar/OVInet_figure_new.txt | 138 + sourcecodes/data/old/examplecar/OVInnode.txt | 1 + sourcecodes/data/old/examplecar/OVInrows.txt | 1 + sourcecodes/data/old/examplecar/OVIparent.txt | 1 + .../data/old/examplecar/OVIstructure_input.txt | 20 + .../old/examplecar/OVIstructure_input_temp.txt | 20 + .../data/old/examplecar/OVIstructure_old.txt | 19 + sourcecodes/data/old/examplecar/OVIthr.txt | 1 + sourcecodes/data/old/examplecar/OVItype.txt | 2 + sourcecodes/data/old/examplecar/OVIvar.txt | 1 + sourcecodes/data/old/examplecar/OVIvardata.txt | 1 + sourcecodes/data/old/examplecar/OVIvarname.txt | 1 + sourcecodes/data/old/examplecar/OVIwhite.txt | 1 + .../old/examplecar/old/OVIrun_evidencemodified.sh | 38 + .../old/examplecar/old/OVIrun_initialstructure.sh | 38 + sourcecodes/data/old/examplezoo/fSfban.txt | 261 ++ .../data/old/examplezoo/fSfcontinuous_input.txt | 104 + sourcecodes/data/old/examplezoo/fSfgraphviz.txt | 61 + sourcecodes/data/old/examplezoo/fSfk.txt | 1 + sourcecodes/data/old/examplezoo/fSfmap.txt | 17 + sourcecodes/data/old/examplezoo/fSfmapdata.txt | 1 + sourcecodes/data/old/examplezoo/fSfname.txt | 1 + sourcecodes/data/old/examplezoo/fSfnet_figure.txt | 130 + sourcecodes/data/old/examplezoo/fSfnnode.txt | 1 + sourcecodes/data/old/examplezoo/fSfnrows.txt | 1 + sourcecodes/data/old/examplezoo/fSfparent.txt | 1 + .../data/old/examplezoo/fSfstructure_input.txt | 18 + .../old/examplezoo/fSfstructure_input_temp.txt | 18 + .../data/old/examplezoo/fSfstructure_old.txt | 16 + sourcecodes/data/old/examplezoo/fSfthr.txt | 1 + sourcecodes/data/old/examplezoo/fSftier.txt | 1 + sourcecodes/data/old/examplezoo/fSftype.txt | 2 + sourcecodes/data/old/examplezoo/fSfwhite.txt | 1 + .../old/examplezoo/old/fSfrun_initialstructure.sh | 38 + .../data/old/examplezoo/standardized_data.txt | 102 + sourcecodes/execute_bn_gom.php | 9 - sourcecodes/faq.php | 6 +- sourcecodes/help.php | 48 +- sourcecodes/home.php | 8 +- sourcecodes/k-best/index.html | 2 +- sourcecodes/network_layout_evd.php | 14 +- sourcecodes/network_layout_evd_2.php | 17 +- sourcecodes/network_layout_evd_2_example.php | 21 +- sourcecodes/network_layout_evd_example.php | 14 +- sourcecodes/network_layout_inv.php | 20 +- sourcecodes/network_layout_inv_2.php | 32 +- sourcecodes/network_layout_inv_2_example.php | 23 +- sourcecodes/network_layout_inv_example.php | 18 +- sourcecodes/parameter_learning/Predictmultiple.m | 22 +- .../Predictmultipleintervention.m | 107 + .../parameter_learning/checkDiscreteNodes.m | 2 + sourcecodes/parameter_learning/checkStructure.m | 8 +- .../code_backup/Predictmultiple.m | 72 + .../code_backup/Predictmultipleintrvention.m | 95 + .../code_backup/checkDiscreteNodes.m | 37 + .../code_backup/checkStructure.m | 78 + .../parameter_learning/code_backup/drawFigure.m | 390 +++ .../parameter_learning/code_backup/drawFigure.m~ | 388 +++ .../parameter_learning/code_backup/drawFigureM.m | 230 ++ .../parameter_learning/code_backup/getParams.m | 22 + .../code_backup/parameterLearning.m | 17 + .../parameter_learning/code_backup/prepareInput.m | 294 +++ .../parameter_learning/code_backup/prepareInput.m~ | 294 +++ .../parameter_learning/code_backup/readInput.m | 63 + .../parameter_learning/code_backup/readInputData.m | 75 + .../code_backup/readInputStructure.m | 72 + .../parameter_learning/code_backup/runBN_initial.m | 57 + .../code_backup/standardizeData.m | 25 + .../code_backup/writeParameters.m | 106 + .../code_backup/writeParameters_ev.m | 151 ++ .../code_backup/writeParameters_int.m | 186 ++ sourcecodes/parameter_learning/drawFigure.m | 191 +- sourcecodes/parameter_learning/drawFigureM.m | 11 +- sourcecodes/parameter_learning/parameterLearning.m | 31 + sourcecodes/parameter_learning/prepareInput.m | 21 +- sourcecodes/parameter_learning/readInput.m | 3 + sourcecodes/parameter_learning/readInputData.m | 4 + .../parameter_learning/readInputStructure.m | 3 + sourcecodes/parameter_learning/runBN_initial.m | 15 +- sourcecodes/parameter_learning/standardizeData.m | 9 +- sourcecodes/parameter_learning/writeParameters.m | 5 + .../parameter_learning/writeParameters_ev.m | 6 + .../parameter_learning/writeParameters_int.m | 6 +- sourcecodes/run_octave_inv | 2 +- sourcecodes/upload_structure_file.php | 270 +- 165 files changed, 10637 insertions(+), 3925 deletions(-) create mode 100644 BNW_parameter_learning/Predictmultipleintervention.m create mode 100644 sourcecodes/bnt-master/graph/findroot.m~ create mode 100644 sourcecodes/data/example1/Bqxparameters.txt create mode 100644 sourcecodes/data/example2/hQGparameters.txt create mode 100644 sourcecodes/data/example_chl/bWRparameters.txt create mode 100644 sourcecodes/data/example_chr2_spleen/cuLparameters.txt create mode 100644 sourcecodes/data/example_sci/Lluparameters.txt create mode 100644 sourcecodes/data/example_time_series/TEbparameters.txt create mode 100644 sourcecodes/data/examplecar15node/eIAparameters.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Lluban.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Llucontinuous_input.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Llugraphviz.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Lluk.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Llumap.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Llumapdata.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Lluname.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Llunet_figure.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Llunet_figure_new.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Llunlevels.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Llunnode.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Llunrows.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Lluparent.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Llustructure_input.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Llustructure_input_temp.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Llustructure_old.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Lluthr.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Llutier.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Llutype.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Lluvar.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Lluvardata.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Lluvarname.txt create mode 100644 sourcecodes/data/old/example_sci_bk/Lluwhite.txt create mode 100644 sourcecodes/data/old/example_sci_bk/old/Llurun_evidencemodified.sh create mode 100644 sourcecodes/data/old/example_sci_bk/old/Llurun_initialstructure.sh create mode 100644 sourcecodes/data/old/examplecar/OVIban.txt create mode 100644 sourcecodes/data/old/examplecar/OVIcontinuous_input.txt create mode 100644 sourcecodes/data/old/examplecar/OVIgraphviz.txt create mode 100644 sourcecodes/data/old/examplecar/OVIk.txt create mode 100644 sourcecodes/data/old/examplecar/OVImap.txt create mode 100644 sourcecodes/data/old/examplecar/OVImapdata.txt create mode 100644 sourcecodes/data/old/examplecar/OVIname.txt create mode 100644 sourcecodes/data/old/examplecar/OVInet_figure.txt create mode 100644 sourcecodes/data/old/examplecar/OVInet_figure_new.txt create mode 100644 sourcecodes/data/old/examplecar/OVInnode.txt create mode 100644 sourcecodes/data/old/examplecar/OVInrows.txt create mode 100644 sourcecodes/data/old/examplecar/OVIparent.txt create mode 100644 sourcecodes/data/old/examplecar/OVIstructure_input.txt create mode 100644 sourcecodes/data/old/examplecar/OVIstructure_input_temp.txt create mode 100644 sourcecodes/data/old/examplecar/OVIstructure_old.txt create mode 100644 sourcecodes/data/old/examplecar/OVIthr.txt create mode 100644 sourcecodes/data/old/examplecar/OVItype.txt create mode 100644 sourcecodes/data/old/examplecar/OVIvar.txt create mode 100644 sourcecodes/data/old/examplecar/OVIvardata.txt create mode 100644 sourcecodes/data/old/examplecar/OVIvarname.txt create mode 100644 sourcecodes/data/old/examplecar/OVIwhite.txt create mode 100644 sourcecodes/data/old/examplecar/old/OVIrun_evidencemodified.sh create mode 100644 sourcecodes/data/old/examplecar/old/OVIrun_initialstructure.sh create mode 100644 sourcecodes/data/old/examplezoo/fSfban.txt create mode 100644 sourcecodes/data/old/examplezoo/fSfcontinuous_input.txt create mode 100644 sourcecodes/data/old/examplezoo/fSfgraphviz.txt create mode 100644 sourcecodes/data/old/examplezoo/fSfk.txt create mode 100644 sourcecodes/data/old/examplezoo/fSfmap.txt create mode 100644 sourcecodes/data/old/examplezoo/fSfmapdata.txt create mode 100644 sourcecodes/data/old/examplezoo/fSfname.txt create mode 100644 sourcecodes/data/old/examplezoo/fSfnet_figure.txt create mode 100644 sourcecodes/data/old/examplezoo/fSfnnode.txt create mode 100644 sourcecodes/data/old/examplezoo/fSfnrows.txt create mode 100644 sourcecodes/data/old/examplezoo/fSfparent.txt create mode 100644 sourcecodes/data/old/examplezoo/fSfstructure_input.txt create mode 100644 sourcecodes/data/old/examplezoo/fSfstructure_input_temp.txt create mode 100644 sourcecodes/data/old/examplezoo/fSfstructure_old.txt create mode 100644 sourcecodes/data/old/examplezoo/fSfthr.txt create mode 100644 sourcecodes/data/old/examplezoo/fSftier.txt create mode 100644 sourcecodes/data/old/examplezoo/fSftype.txt create mode 100644 sourcecodes/data/old/examplezoo/fSfwhite.txt create mode 100644 sourcecodes/data/old/examplezoo/old/fSfrun_initialstructure.sh create mode 100644 sourcecodes/data/old/examplezoo/standardized_data.txt create mode 100644 sourcecodes/parameter_learning/Predictmultipleintervention.m create mode 100644 sourcecodes/parameter_learning/code_backup/Predictmultiple.m create mode 100644 sourcecodes/parameter_learning/code_backup/Predictmultipleintrvention.m create mode 100644 sourcecodes/parameter_learning/code_backup/checkDiscreteNodes.m create mode 100644 sourcecodes/parameter_learning/code_backup/checkStructure.m create mode 100644 sourcecodes/parameter_learning/code_backup/drawFigure.m create mode 100644 sourcecodes/parameter_learning/code_backup/drawFigure.m~ create mode 100644 sourcecodes/parameter_learning/code_backup/drawFigureM.m create mode 100644 sourcecodes/parameter_learning/code_backup/getParams.m create mode 100644 sourcecodes/parameter_learning/code_backup/parameterLearning.m create mode 100644 sourcecodes/parameter_learning/code_backup/prepareInput.m create mode 100644 sourcecodes/parameter_learning/code_backup/prepareInput.m~ create mode 100644 sourcecodes/parameter_learning/code_backup/readInput.m create mode 100644 sourcecodes/parameter_learning/code_backup/readInputData.m create mode 100644 sourcecodes/parameter_learning/code_backup/readInputStructure.m create mode 100644 sourcecodes/parameter_learning/code_backup/runBN_initial.m create mode 100644 sourcecodes/parameter_learning/code_backup/standardizeData.m create mode 100644 sourcecodes/parameter_learning/code_backup/writeParameters.m create mode 100644 sourcecodes/parameter_learning/code_backup/writeParameters_ev.m create mode 100644 sourcecodes/parameter_learning/code_backup/writeParameters_int.m diff --git a/BNW_parameter_learning/Predictmultiple.m b/BNW_parameter_learning/Predictmultiple.m index 781c64a4..019488a3 100644 --- a/BNW_parameter_learning/Predictmultiple.m +++ b/BNW_parameter_learning/Predictmultiple.m @@ -1,4 +1,18 @@ function Predictmultiple(pre) +% Predictmultiple is used when predicting the impact of entering +% evidence on the network. The 'multiple' part refers to +% it working when evidence for multiple nodes is entered. +% +% The input is 'pre'-- the prefix for the network and data +% in BNW. It reads information from several files from BNW. +% +% The output is ???net_figure_new.txt. It also calls +% writeParameters_ev to write the parameter file. +% +% It is called by the run_octave_evd file in the 'sourcecodes' directory. + + + dfile=strcat(pre,'structure_input.txt'); sfile=dfile; dfile=strcat(pre,'continuous_input.txt'); @@ -28,14 +42,14 @@ mapfile = strcat(pre,'map.txt'); fmap = fopen(mapfile,'r'); for i=1:nnodes buffer = fgetl(mapfile); - temp = cell(1,4); - for j=1:4 + temp = cell(1,3); + for j=1:3 [next,buffer] = strtok(buffer); temp{j} = next; end labels_orig{i} = temp{1}; - means_orig{i} = str2num(temp{4}); - stdevs_orig{i} = str2num(temp{3}); + means_orig{i} = str2num(temp{3}); + stdevs_orig{i} = str2num(temp{2}); end fclose(fmap); diff --git a/BNW_parameter_learning/Predictmultipleintervention.m b/BNW_parameter_learning/Predictmultipleintervention.m new file mode 100644 index 00000000..7e6140a9 --- /dev/null +++ b/BNW_parameter_learning/Predictmultipleintervention.m @@ -0,0 +1,107 @@ +function Predictmultipleintervention(pre) +% Predictmultipleintervention is used when predicting the impact of +% intervention on the network. The 'multiple' part refers to +% it working when intervention for multiple nodes is entered. +% +% The input is 'pre'-- the prefix for the network and data +% in BNW. It reads information from several files from BNW. +% +% The output is ???net_figure_new.txt. It also calls +% writeParameters_int to write the parameter file. +% +% It is called by the run_octave_inv file in the 'sourcecodes' directory. + +dfile=strcat(pre,'structure_input.txt'); +sfile=dfile; +dfile=strcat(pre,'continuous_input.txt'); +nnodefile=strcat(pre,'nnode.txt'); + +fnnode = fopen(nnodefile,'r'); +nnodes = fscanf(fnnode,'%d'); + +fvarnamefile=strcat(pre,'varname.txt'); + +varfile = fopen(fvarnamefile,'r'); + +Std_flag=true; +[labels,cases,bnet]=readInput(dfile,sfile,nnodes,Std_flag); + +[bnet]=parameterLearning(bnet,cases); + +fvarfile=strcat(pre,'var.txt'); +fvar = fopen(fvarfile,'r'); +select_var_new = fscanf(fvar,'%d'); + +nm = numel(select_var_new); + +varlabels = cell(1,nm); +varbuffer = fgetl(varfile); %get header line as a string +for j=1:nm + [varnext,varbuffer] = strtok(varbuffer); + varlabels{j} = varnext; + for i=1:nnodes + if strcmp(varlabels{j},labels{i}) + select_var_new(j)=i; + end + end + +end + + + + +fvardfile=strcat(pre,'vardata.txt'); + +fvard = fopen(fvardfile,'r'); + +select_var_data_new = fscanf(fvard,'%f'); + +means_orig = cell(1,nnodes); +stdevs_orig = cell(1,nnodes); +labels_orig = cell(1,nnodes); +%Read in original means and standard deviations +mapfile = strcat(pre,'map.txt'); +fmap = fopen(mapfile,'r'); +for i=1:nnodes + buffer = fgetl(mapfile); + temp = cell(1,3); + for j=1:3 + [next,buffer] = strtok(buffer); + temp{j} = next; + end + labels_orig{i} = temp{1}; + means_orig{i} = str2num(temp{3}); + stdevs_orig{i} = str2num(temp{2}); +end +fclose(fmap); + +%Need to map the means and stdevs to the correct labels +means = cell(1,nnodes); +stdevs = cell(1,nnodes); +%Read in labels in new order. +labelsnew = cell(1,nnodes); +mapdatafile = strcat(pre,'mapdata.txt'); +fmapdata = fopen(mapdatafile,'r'); +buffer = fgetl(fmapdata); +for i = 1:nnodes + [next,buffer ] = strtok(buffer); + labelsnew{i} = next; +end +fclose(fmapdata); +for i = 1:nnodes + for j = 1:nnodes + if strcmp(labelsnew{i},labels_orig{j}) + means{i} = means_orig{j}; + stdevs{i} = stdevs_orig{j}; + break + end + end +end + +filename=strcat(pre,'net_figure_new.txt'); + +drawFigureM(nnodes,bnet,labels,filename,cases,stdevs,means,select_var_new,select_var_data_new); + +writeParameters_int(pre,bnet,nnodes,labels,cases,stdevs,means,select_var_new,select_var_data_new); + +end diff --git a/BNW_parameter_learning/checkDiscreteNodes.m b/BNW_parameter_learning/checkDiscreteNodes.m index 7b2a695f..919128e4 100644 --- a/BNW_parameter_learning/checkDiscreteNodes.m +++ b/BNW_parameter_learning/checkDiscreteNodes.m @@ -7,7 +7,9 @@ function [ ] = checkDiscreteNodes( bnet, cases) % bnet: BNT bnet % cases: cell array of data % +% checkDiscreteNodes is called by readInput.m % + node_sizes = bnet.node_sizes; dnodes = bnet.dnodes; ndisc = size(dnodes,2); diff --git a/BNW_parameter_learning/checkStructure.m b/BNW_parameter_learning/checkStructure.m index fc72e4b7..104e39e1 100644 --- a/BNW_parameter_learning/checkStructure.m +++ b/BNW_parameter_learning/checkStructure.m @@ -1,7 +1,7 @@ function [ labels, cases, dag, node_sizes, ord_flag ] = checkStructure(labels, cases, dag, node_sizes) - %checkStructure Check to see if nodes are sorted correctly. They must be + %checkStructure Check to see if nodes are sorted correctly. Nodes must be % in topological order (i.e., parents before children) before parameter - % learning can take place. + % learning can take place. This function performs this sorting. % %Input and output have the same meaning. The output has just been %topologically ordered. @@ -9,6 +9,10 @@ function [ labels, cases, dag, node_sizes, ord_flag ] = checkStructure(labels, c % cases = cell array with the data. % dag = matrix with the strucutre of the network. % node_sizes = vector with the size of each node. +% +% checkStructure is called by readInput.m + + %make connections array %count how big you need the connections array to be diff --git a/BNW_parameter_learning/drawFigure.m b/BNW_parameter_learning/drawFigure.m index fa963a4b..599d8f3b 100644 --- a/BNW_parameter_learning/drawFigure.m +++ b/BNW_parameter_learning/drawFigure.m @@ -1,186 +1,17 @@ -function [] = drawFigure(nnodes,bnet,labels,filename,cases,stdevs,means,selectvar,selectdata) +function [] = drawFigure(nnodes,bnet,labels,filename,cases,stdevs,means) %drawFigure writes the parameters and data that are needed to draw the -%structure of a Bayesian network. - - -if nargin < 8, - drawFigureNoEv(nnodes,bnet,labels,filename,cases,stdevs,means); -else - drawFigureEv(nnodes,bnet,labels,filename,cases,stdevs,means,selectvar,selectdata); -end; - -end - - - -function [] = drawFigureEv(nnodes,bnet,labels,filename,cases,stdevs,means,selectvar,selectdata) -%Function to use if there is no entered evidence. -% +%structure of a Bayesian network for BNW. +% This is the function that is called to create the initial +% net_figure file for the network (before evidence or intervention). % -%Before each printed line, I will have a line that starts with %%% -% that describes what will be on that line - -%Create an empty evidence cell array. - -%val=cases; -%for i = 1:nnodes -% val(i,1)=val(i,2); - -%end - -A=cell2mat(cases'); -Amax=max(A); -Amin=min(A); - - -evidence = cell(1,nnodes); -engine = jtree_inf_engine(bnet); - -evidence{selectvar}=selectdata; - -[engine,loglik]=enter_evidence(engine,evidence); - -%Open the file, and write the nodes to a file. -fileID = fopen(filename,'w'); - -%%%%Evidence node -fprintf(fileID,'%i\n',selectvar); -%%% The number of nodes -fprintf(fileID,'%i\n',nnodes); -%Get canvas size -labels_temp = cellstr(labels); -[x,y] = make_layout(bnet.dag); - -x = x - min(x); -y = 1 - y; -y = y - min(y); - -[x_dim,y_dim] = canvasSize(nnodes,x,y); - -%%% The dimensions of the canvas for the javascript code -fprintf(fileID,'%i\t%i\t\n',x_dim,y_dim) - -x = x*x_dim; -y = y*y_dim; -for i = 1:nnodes, -%%% The name and X- and Y-positions of each node - fprintf(fileID,'%s\t%i\t%i\n',labels{i},round(x(i)),round(y(i))); -end - -%Get the number of parents and children for each node. -num_par = zeros(1,nnodes); -%For parents, sum down columns -for i = 1:nnodes, - for j = 1:nnodes, - if bnet.dag(j,i) == 1, - num_par(i) = num_par(i) + 1; - end - end -end -num_child = zeros(1,nnodes); -for i = 1:nnodes, - for j = 1:nnodes, - if bnet.dag(i,j) == 1, - num_child(i) = num_child(i) + 1; - end - end -end - - -for i = 1:nnodes, - %%% The name and type of each node (1=continuous, the number of states - %%% if it is discrete - fprintf(fileID,'%s\t%i\n',labels{i},bnet.node_sizes(i)); - %%% The size of the node, I am going to keep them - %%% 250(width) by 150(height) for now - %Could modify this to change the width based on the length of the node - %name - fprintf(fileID,'%i\t%i\n',250,150); - %%% The number of parents of the node, and the parents - if num_par(i) == 0; - %%% If no parents: - fprintf(fileID,'%i\n',num_par(i)); - else - parents = zeros(1,num_par(i)); - k = 1; - for j = 1:nnodes, - if bnet.dag(j,i) == 1, - parents(1,k) = j; - k = k + 1; - end - end - format = '%i\t'; - for j = 1:num_par(i)-1, - format = strcat(format,'%i\t'); - end - format = strcat(format,'%i\n'); - %%%If there are parents: - fprintf(fileID,format,num_par(i),parents(1,:)); - end - - - %%% The number of children of the node, and the children - if num_child(i) == 0; - %%% If no children: - fprintf(fileID,'%i\n',num_child(i)); - else - children = zeros(1,num_child(i)); - k = 1; - for j = 1:nnodes, - if bnet.dag(i,j) == 1, - children(1,k) = j; - k = k + 1; - end - end - format = '%i\t'; - for j = 1:num_child(i)-1, - format = strcat(format,'%i\t'); - end - format = strcat(format,'%i\n'); - %%%If there are parents: - fprintf(fileID,format,num_child(i),children(1,:)); - end - - predict = marginal_nodes(engine,i); - if isempty(evidence{i}) - if bnet.node_sizes(i) ~= 1, - for j = 1:bnet.node_sizes(i), - %%%For discrete nodes, the state and the percent of that state - fprintf(fileID,'%i\t%6.4f\n',j,predict.T(j)); - end; - else - - [x_vals,y_vals] = calcGaussian(predict.mu,predict.Sigma,Amax(i),Amin(i)); - %%%For continuous nodes, print x and the pdf of a normal curve. - for j = 1:101, - %%Undo standardization - xvals(j,1) = xvals(j,1)*stdevs{i}+means{i} - fprintf(fileID,'%6.4f\t%6.4f\n',x_vals(j,1),y_vals(j,1)); - end; - end; - else - fprintf(fileID,'%6.4f\t%6.4f\n',selectdata,1); - end - -end -%fprintf(fileID,'%s\t %\n',labels_temp{:}); - - -fclose(fileID); - -end - - - - - - -function [] = drawFigureNoEv(nnodes,bnet,labels,filename,cases,stdevs,means) -%Function to use if there is no entered evidence. -% % -%Before each printed line, I will have a line that starts with %%% -% that describes what will be on that line +% The output is the file specified by 'filename'. +% For BNW, this file is called: ???net_figure.txt +% where ??? is the prefix. +% +% drawFigure is called by runBN_intial.m +% + A=cell2mat(cases'); Amax=max(A); Amin=min(A); diff --git a/BNW_parameter_learning/drawFigureM.m b/BNW_parameter_learning/drawFigureM.m index 9aa77d35..0e0d9b6e 100644 --- a/BNW_parameter_learning/drawFigureM.m +++ b/BNW_parameter_learning/drawFigureM.m @@ -1,6 +1,15 @@ function [] = drawFigureM(nnodes,bnet,labels,filename,cases,stdevs,means,selectvar,selectdata) %drawFigureM writes the parameters and data that are needed to draw the -%structure of a Bayesian network after added evidence or intervention +%structure of a Bayesian network after adding evidence or intervention +%It creates the net_figure_new file after evidence/intervetion. +% +% The output file is specified by 'filename'. +% For BNW, the file is named ???net_figure_new.txt +% where ??? is the prefix. +% +% drawFigureM is called by Predictmultiple.m and Predictmultipleintervention.m + + fileID = fopen(filename,'w'); diff --git a/BNW_parameter_learning/parameterLearning.m b/BNW_parameter_learning/parameterLearning.m index d4b67c87..414ffe6c 100644 --- a/BNW_parameter_learning/parameterLearning.m +++ b/BNW_parameter_learning/parameterLearning.m @@ -1,5 +1,14 @@ function [ bnet ] = parameterLearning( bnet,cases,engine_name ) %parameterLearning Do parameter learning and inference +% It returns the bnet with parameters learned from the data in cases. +% +% This is very basic now. It could be modified to use different engine +% types in the future. Now, I always use the 'jtree_inf_engine'. +% +% +% parameterLearning is called by runBN_initial.m, +% Predictmultiple.m, and Predictmultipleintervention.m + %engine is an optional argument if nargin < 3 @@ -15,3 +24,25 @@ end end +function [ bnet ] = getParams( bnet, cases ) +%getParams Code to initialize CPT and do parameter learning. +%This will be very basic for now. I can add more options later. +% + +dnodes = bnet.dnodes; +cnodes = bnet.cnodes; +nnodes = size(dnodes,2)+size(cnodes,2); + +%make dnodes tabular_CPT +for i = 1:size(dnodes,2) + bnet.CPD{dnodes(i)} = tabular_CPD(bnet,dnodes(i)); +end + +for i = 1:size(cnodes,2) + bnet.CPD{cnodes(i)} = gaussian_CPD(bnet,cnodes(i)); +end + +bnet = learn_params(bnet,cases); + + +end diff --git a/BNW_parameter_learning/prepareInput.m b/BNW_parameter_learning/prepareInput.m index 28a06c15..84d2ae17 100644 --- a/BNW_parameter_learning/prepareInput.m +++ b/BNW_parameter_learning/prepareInput.m @@ -39,6 +39,8 @@ function [ ] = prepareInput( pre ) % 8-12) ???ban.txt, ???white.txt, ???k.txt, ???thr.txt, and % ???parent.txt: Files with default values for structure learning. % + % It is called by the run_prep_input script in the 'sourcecodes' directory. + % open file for input, include error handling dfile=strcat(pre,'continuous_input_orig.txt'); @@ -81,28 +83,36 @@ for j = 1:nnodes levels{j} = size(states{j},1); end +reason = cell(1,nnodes); %Now do some checks to see if nodes are discrete or continuous for j = 1:nnodes % If there are 3 or less unique values, I will assume that the node is discrete. if levels{j} < 4; + reason{j} = "It was determined to be discrete because there are a small number (<4) of possible values."; continue % If there are as many unique values as a third of the number of cases, % I will assume that the node is continuous. elseif levels{j} > ncases/3; levels{j} = 1; + reason{j} = "It was determined to be continuous because there are a large number of possible values compared to the number of cases."; + continue % If there are more than twenty unique values, % I will assume that the node is continuous. elseif levels{j} > 20; levels{j} = 1; + reason{j} = "It was determined to be continuous because there are many (>20) possible values."; + continue % Otherwise, I will scan through the individual values. % If any of the values contain a '.', I will assume it is continuous. else + reason{j} = "It was determined to be discrete by default."; period_test = 0; column = data(:,j); k = 1; while period_test == 0 period_test = sum(cell2mat(strfind(column(k),"."))); if period_test != 0; + reason{j} = "This variable was determined to be continuous because there were several possible values and at least one value contained a period(.)."; levels{j} = 1; end k++; @@ -131,6 +141,7 @@ if max_disc > min_cont labels_old = labels; data_old = data; states_old = states; + reason_old = reason; new_order = {}; for i=1:nnodes if levels_old{i} > 1 @@ -145,10 +156,12 @@ if max_disc > min_cont labels = {}; levels = {}; states = {}; + reason = {}; for i =1:nnodes labels{i} = labels_old{new_order{i}}; levels{i} = levels_old{new_order{i}}; states{i} = states_old{new_order{i}}; + reason{i} = reason_old{new_order{i}}; for j=1:ncases data{j,i} = data_old{j,new_order{i}}; end @@ -228,19 +241,21 @@ descfile = strcat(pre,'input_desc.txt'); dout = fopen(descfile,'w'); fprintf(dout,['As loaded, the input file had the following properties:\n\n']); dout = fopen(descfile,'a'); -fprintf(dout,'There are %i variables and %i cases(rows)\n',size(labels,2),ncases); +fprintf(dout,'There are %i variables and %i cases(rows).\n',size(labels,2),ncases); fprintf(dout,'The variable names are:\n'); fprintf(dout,'%s\t',labels{1:end-1}); fprintf(dout,'%s\n\n',labels{end}); for i=1:nnodes if levels{i} == 1 - fprintf(dout,'%s is a continuous variable\n',labels{i}); + fprintf(dout,'%s is a continuous variable.\n',labels{i}); + fprintf(dout,'%s\n',reason{i}); column = str2double(data(:,i)); colmean = mean(column); colstd = std(column); fprintf(dout,'It has a mean of %6.3f and a standard deviation of %6.3f\n\n',mean(column),std(column)) else - fprintf(dout,'%s is a discrete variable with %i states\n',labels{i},levels{i}); + fprintf(dout,'%s is a discrete variable with %i states.\n',labels{i},levels{i}); + fprintf(dout,'%s\n',reason{i}); fprintf(dout,'The states are: '); fprintf(dout,'%s ',states{i}{1:end-1}); fprintf(dout,'%s\n\n',states{i}{end}); diff --git a/BNW_parameter_learning/readInput.m b/BNW_parameter_learning/readInput.m index 2be0af29..f291b06d 100644 --- a/BNW_parameter_learning/readInput.m +++ b/BNW_parameter_learning/readInput.m @@ -15,6 +15,9 @@ function [ labels, cases, bnet, node_sizes, data,labelsold] = readInput( dfile, % labels = cell array with the names of the nodes. % cases = cell array with the data. % bnet = BNT bayesian network with the input structure. + % + % readInput is called by runBN_initial.m + if nargin < 4 std_flag = false(1); diff --git a/BNW_parameter_learning/readInputData.m b/BNW_parameter_learning/readInputData.m index 2df158f9..d92ec015 100644 --- a/BNW_parameter_learning/readInputData.m +++ b/BNW_parameter_learning/readInputData.m @@ -26,6 +26,10 @@ function [ labels , node_sizes, cases, data] = readInputData( dfile , nnodes ) % cases = cell array with the data. The cases array is transposed % in comparison with the input data to agree with the format of % cell data used in BNT. + % + % readInputData is called by readInput.m + + % open file for input, include error handling fin = fopen(dfile,'r'); diff --git a/BNW_parameter_learning/readInputStructure.m b/BNW_parameter_learning/readInputStructure.m index 72c39f46..9d5e2056 100644 --- a/BNW_parameter_learning/readInputStructure.m +++ b/BNW_parameter_learning/readInputStructure.m @@ -21,6 +21,9 @@ function [ dag ] = readInputStructure( sfile, labels ) % Output: % dag = matrix with the structure. % +% readInputStructure is called by runBN_initial.m + + % Read in first line of the structure file % open file for input, include error handling fin = fopen(sfile,'r'); diff --git a/BNW_parameter_learning/runBN_initial.m b/BNW_parameter_learning/runBN_initial.m index 43caf402..614accc5 100644 --- a/BNW_parameter_learning/runBN_initial.m +++ b/BNW_parameter_learning/runBN_initial.m @@ -1,4 +1,17 @@ function runBN_initial(pre) +% runBN_initial is used to create the net_figure file +% for a network without entered evidence or intervention. +% +% The input is 'pre'-- the prefix for the network and data +% in BNW. It uses this identifier to read several files from +% BNW. +% +% The output is ???net_figure.txt. It also calls writeParameters +% to write the parameter file. +% +% runBN_initial is called by run_octave in the 'sourcecodes' directory. +% + sfile=strcat(pre,'structure_input.txt'); dfile=strcat(pre,'continuous_input.txt'); @@ -21,7 +34,7 @@ s=std(data,0,1); m=mean(data); for i=1:nnodes - fprintf(mapval,'%s\t%d\t%f\t%f\n',labelsold{i},node_sizes(i),s(i),m(i)); + fprintf(mapval,'%s\t%f\t%f\n',labelsold{i},s(i),m(i)); end fprintf(mapfile,'%s',labels{1}); diff --git a/BNW_parameter_learning/standardizeData.m b/BNW_parameter_learning/standardizeData.m index 449aa440..b7673a1a 100644 --- a/BNW_parameter_learning/standardizeData.m +++ b/BNW_parameter_learning/standardizeData.m @@ -1,7 +1,8 @@ function [ cases ] = standardizeData( labels, node_sizes, cases ) %standardizeData standardizes continuous nodes so they have a mean = 0 % and standard deviation = 1 - +% +% standardizeData is called by readInput.m nnodes = size(labels,2); @@ -14,12 +15,6 @@ for i = 1:nnodes end end -%write standardized data to file -%fprintf(['Standardized data is written to file standardized_data.txt\n']) -%fout = 'standardized_data.txt'; -%txt = sprintf([repmat('%s\t',1,size(labels,2))],labels{:}); -%dlmwrite(fout,txt,''); -%dlmwrite(fout,cell2num(cases'),'-append','delimiter','\t'); end diff --git a/BNW_parameter_learning/writeParameters.m b/BNW_parameter_learning/writeParameters.m index 0790a8e2..42b2a4ef 100644 --- a/BNW_parameter_learning/writeParameters.m +++ b/BNW_parameter_learning/writeParameters.m @@ -1,5 +1,10 @@ function [] = writeParameters(pre,nnodes,bnet,labels,cases,labelsold,s,m) %Writes a file that contains the parameters of the network with no evidence. +% +% The file is called ???parameters.txt where ??? is the prefix in BNW +% for the network. +% +% writeParameters is called by runBN_intial.m %%Get the types of the nodes. diff --git a/BNW_parameter_learning/writeParameters_ev.m b/BNW_parameter_learning/writeParameters_ev.m index fc24e2e5..1f07c745 100644 --- a/BNW_parameter_learning/writeParameters_ev.m +++ b/BNW_parameter_learning/writeParameters_ev.m @@ -1,5 +1,11 @@ function [] = writeParameters_ev(pre,bnet,nnodes,labels,cases,stdevs,means,selectvar,selectdata) %Writes a file that contains the parameters of the network after entering evidence. +% +% The file is called ???parameters_ev.txt where ??? is the prefix in BNW +% for the network. +% +% It is called by Predictmultiple.m + %Read in original node labels to get node IDs. infile = strcat(pre,'continuous_input.txt'); diff --git a/BNW_parameter_learning/writeParameters_int.m b/BNW_parameter_learning/writeParameters_int.m index ed92d593..69dcbb93 100644 --- a/BNW_parameter_learning/writeParameters_int.m +++ b/BNW_parameter_learning/writeParameters_int.m @@ -1,6 +1,10 @@ function [] = writeParameters_int(pre,bnet,nnodes,labels,cases,stdevs,means,selectvar,selectdata) %Writes a file that contains the parameters of the network after intervention. - +% +% The file is called ???parameters_ev.txt where ??? is the prefix in BNW +% for the network. +% +% writeParameters is called by Predictmultipleintervention.m %First read input file to get node labels to get node IDs. infile = strcat(pre,'continuous_input.txt'); diff --git a/sourcecodes/BNW_workflow_net1.htm b/sourcecodes/BNW_workflow_net1.htm index e82f1f41..d69ddf84 100644 --- a/sourcecodes/BNW_workflow_net1.htm +++ b/sourcecodes/BNW_workflow_net1.htm @@ -291,8 +291,10 @@ ul

This tutorial provides -an overview of using BNW to build a Bayesian network model from a dataset and use the network to make predictions. The dataset used in this tutorial is a synthetic example of a genetic dataset that has a total of 8 variables. Two of the variables are genotypes labeled Geno1 and Geno2, and the remaining 6 variables are gene expression levels or other quantitative traits that are labeled Trait1 to Trait6. The dataset is available here.

The data file is formatted according to the guidelines on the BNW help page. The first row of the file contains the names of the variables and the remaining rows contain the data for each sample of the dataset. The genotypes (Geno1 and Geno2), which are the only discrete variables in the network, are the leftmost variables in the input file and are integer values (1 and 2) for all of the samples. The quantitative traits are continuous variables, and, therefore, all contain a "." in at least one of the samples.

+line-height:115%;font-family:"Arial","sans-serif"'> +**Recent updates to BNW may result in slight differences between what is described/shown below and what would currently be experienced in BNW.**

+This tutorial provides +an overview of using BNW to build a Bayesian network model from a dataset and use the network to make predictions. The dataset used in this tutorial is a synthetic example of a genetic dataset that has a total of 8 variables. Two of the variables are genotypes labeled Geno1 and Geno2, and the remaining 6 variables are gene expression levels or other quantitative traits that are labeled Trait1 to Trait6. The dataset is available here.

The data file is formatted according to the guidelines on the BNW help page. The first row of the file contains the names of the variables and the remaining rows contain the data for each sample of the dataset. The genotypes (Geno1 and Geno2), which are the only discrete variables in the network, are the leftmost variables in the input file and are integer values (1 and 2) for all of the samples. The quantitative traits are continuous variables, and, therefore, all contain a "." in at least one of the samples.

1. Structure learning using default options

@@ -322,7 +324,7 @@ normal'>In order to test if edges present the single best scoring network are conserved across high scoring networks. We can modify the structure learning settings to get identify the structures of many high scoring networks and perform model averaging over these structures. To do this, return to the BNW home page, select Learn a network model from data, and upload the datafile. Instead of using the default settings, select Go to structure learning settings and the BNW structural constraint interface. A more detailed overview of use of the structural constraint interface is provided in another tutorial, but, here, we will investigate the impact of modifying some of the structure learning settings shown below:


+line-height:115%;font-family:"Arial","sans-serif";mso-no-proof:yes'>In order to test if edges present the single best scoring network are conserved across high scoring networks. We can modify the structure learning settings to get identify the structures of many high scoring networks and perform model averaging over these structures. To do this, return to the BNW home page, select Learn a network model from data, and upload the datafile. Instead of using the default settings, select Go to structure learning settings and the BNW structural constraint interface. A more detailed overview of use of the structural constraint interface is provided in another tutorial, but, here, we will investigate the impact of modifying some of the structure learning settings shown below:


@@ -356,7 +358,7 @@ normal'>
To make predictions with the network, we will use the structure learned after model averaging of the top 100 highest scoring networks. First, we will use the model to compare the expected values for nodes in the network based on observed genotypes. For these predictions, we will keep the prediction in evidence mode. The difference between evidence and intervention modes is discussed in the BNW FAQ page. To use the model to make predictions based on Geno1, click on one of the blue bars in the Geno1 node and enter 1 or 2 to indicate which genotype value should be used to predict the values of the other network nodes. In the figure below, Geno1 is outlined in red and state 2 has a 100% probability, indicating that the value of this node has been entered as evidence. The red lines in the figure show the predicted distributions of the nodes after this evidence is known and can be compared with the blue lines which show the distributions for variables using the original data.


+line-height:115%;font-family:"Arial","sans-serif";mso-no-proof:yes'>
To make predictions with the network, we will use the structure learned after model averaging of the top 100 highest scoring networks. First, we will use the model to compare the expected values for nodes in the network based on observed genotypes. For these predictions, we will keep the prediction in evidence mode. The difference between evidence and intervention modes is discussed in the BNW FAQ page. To use the model to make predictions based on Geno1, click on one of the blue bars in the Geno1 node and enter 1 or 2 to indicate which genotype value should be used to predict the values of the other network nodes. In the figure below, Geno1 is outlined in red and state 2 has a 100% probability, indicating that the value of this node has been entered as evidence. The red lines in the figure show the predicted distributions of the nodes after this evidence is known and can be compared with the blue lines which show the distributions for variables using the original data.


diff --git a/sourcecodes/BNW_workflow_sci.htm b/sourcecodes/BNW_workflow_sci.htm index 73451b4c..8adbc7b7 100644 --- a/sourcecodes/BNW_workflow_sci.htm +++ b/sourcecodes/BNW_workflow_sci.htm @@ -315,6 +315,12 @@ ul

+

+**Recent updates to BNW may result in slight differences between what is described/shown below and what would currently be experienced in BNW.** +

+

1. A genetic network linking genotype and phenotype

diff --git a/sourcecodes/add_evd.php b/sourcecodes/add_evd.php index 191dc244..92aca69f 100644 --- a/sourcecodes/add_evd.php +++ b/sourcecodes/add_evd.php @@ -2,7 +2,7 @@ $keyval=trim($_GET['My_key']); -include("restructuremap.php"); +//include("restructuremap.php"); function discretemap($textdata,$sym,$dmapdata) @@ -104,11 +104,6 @@ for($j=0;$j<$nn;$j++) } $dt=$type_d[$s]; - -//if($dt==1) -// $textdata=reversemap($sym,$textdata,$keyval); -//else -// $textdata=discretemap($textdata,$sym,$dmapdata); if($dt!=1) $textdata=discretemap($textdata,$sym,$dmapdata); diff --git a/sourcecodes/add_evd_example.php b/sourcecodes/add_evd_example.php index 03846663..a38d4474 100644 --- a/sourcecodes/add_evd_example.php +++ b/sourcecodes/add_evd_example.php @@ -2,7 +2,7 @@ $keyval=trim($_GET['My_key']); -include("restructuremap.php"); +//include("restructuremap.php"); function discretemap($textdata,$sym,$dmapdata) @@ -104,11 +104,6 @@ for($j=0;$j<$nn;$j++) } $dt=$type_d[$s]; - -//if($dt==1) -// $textdata=reversemap($sym,$textdata,$keyval); -//else -// $textdata=discretemap($textdata,$sym,$dmapdata); if($dt!=1) $textdata=discretemap($textdata,$sym,$dmapdata); @@ -189,7 +184,7 @@ else } - + // $file1="./data/".$keyval."run_evidencemodified.sh"; // $initiallines=file_get_contents("./data/temp_evidence_file"); // $all_lines="$initiallines"."$keyval\nfi\nexit"; diff --git a/sourcecodes/add_inv.php b/sourcecodes/add_inv.php index d9ec7cbb..c2953f85 100644 --- a/sourcecodes/add_inv.php +++ b/sourcecodes/add_inv.php @@ -1,5 +1,5 @@ @@ -51,18 +51,6 @@ if($searchID!="") - - - +

n0 root = i ; diff --git a/sourcecodes/bnt-master/graph/findroot.m~ b/sourcecodes/bnt-master/graph/findroot.m~ new file mode 100644 index 00000000..d242a3a3 --- /dev/null +++ b/sourcecodes/bnt-master/graph/findroot.m~ @@ -0,0 +1,24 @@ +function root = findroot(bnet, cliques) + +%% findroot is to find the strong root in a clique tree assume it has one +%% in the tree. For a clique tree constructed from a strongly triangulated +%% graph, an interface clique that contains all discrete parents +%% and at least one continuous node from a connected continuous component +%% is for sure to be available as a guaranteed strong root. +%% -By Wei Sun, George Mason University, 4/17/2010. + +%% We choose the interface clique that contains the max number +%% of interface nodes to be the strong root. +n0 = 0 ; +for i=1:length(cliques) + % check hybrid cliques + hc = intersect(cliques{i}, bnet.cnodes) ; + hd = intersect(cliques{i}, bnet.dnodes) ; + if ~isempty(hd) & ~isempty(hc) + nd = length(hd) ; + if nd > n0 + root = i ; + n0 = nd ; + end + end +end diff --git a/sourcecodes/create_tiers_gom.php b/sourcecodes/create_tiers_gom.php index 0f332eef..be8e2fc2 100644 --- a/sourcecodes/create_tiers_gom.php +++ b/sourcecodes/create_tiers_gom.php @@ -90,6 +90,9 @@ $runtime=exe_time($keyval,$parent_number,$k_number);