Run a GOBNILP, Bayesian networks (BNs) learning task and/or post-run routines on learning output.
Post processing includes the generation of Fisher based visualisation and family heatmaps.
Assumes gobnlip is in your path. Currently only tested on *nix based systems.
To install
?- pack_install(gbn).
to load
?- use_module(library(gbn)).
Main predicate for both running the BN experiment and post-processing is:
?- gbn. true. ?- ls. % asia-24.07.13/ true.
?- gbn(debug(true)). % Turning debugging on for predicate handle: gbn(gbn) % Options: [$restore(gbn,debug,false),copy(false),data(pack(gbn/data/asia.dat)),display_dot(svg),odir(_33202),std_output(std_file)] % Output directory: 'asia-24.07.13' % Settings on: asia.set true.
A more complex example
?- [cancer(aml)]. ?- absolute_file_name( pack('gbn/run/gbns_in_cancer'), Abs ), | ls( Abs ). % aml.pl coa.pl data/ gbm.pl mpn.pl mye.pl plots/ Abs = '/home/nicos/.local/share/swi-prolog/pack/gbn/run/gbns_in_cancer'. ?- aml. % Starting: aml % Starting: fisher_nets % Starting: fam_hmaps % Starting: gates_nets % Starting: svg_legend % Finished: aml true.
?- gbn_version( Vers, Date ). V = 0:2:0, D = date(2021, 1, 23).
Options is a term or list of:
false
(also true_=_gbn or all).std_output.txt
?- absolute_file_name( pack(gbn/examples/crc.bn), Crc ), gbn_term( Crc, Bn, Adorned ). Crc = '/home/na11/lib/swipl/pack/gnb/examples/crc.bn'. Bn = ['ACVR2A'-['ARID1A', 'FBXW7', 'PTEN'], 'AMER1'-[], 'APC'-['ACVR2A', 'AMER1'], 'ARID1A'-[], 'ATM'-['ACVR2A'], 'BRAF'-['APC'], 'FBXW7'-[], 'KRAS'-[...], ... - ...|...], Adorned = ['ACVR2A'-['ARID1A', 'FBXW7', 'PTEN']- -60.029495, 'AMER1'-[]- -79.527071, 'APC'-['ACVR2A', 'AMER1']- -131.057359, 'ARID1A'-[]- -84.299473, 'ATM'-['ACVR2A']- -43.772266, 'BRAF'-[...]- -110.700005, ... - ... - -86.616242, ... - ...|...]- -1567.186608.
Options Opts are also passed to disp_bn/2.
Opts
adjust()
functionorg
theme is:
bic
theme is:
ClrCoSgn
"#35978F"
(bluegreen)ClrExSgn
"#BF812D"
(golden)po(Pval,Odds)
test()
)
Requires pack(real)
with RcolorBrewer installed.
For now it assumes a single .dat file in current directory and runs this against all .bn files creating os_postfix/3 results files with postfix=fish.
pupsh gbn_fisher_nets postfix=wb graphbgcolor
white
Options are passed to gbn_fisher_net/4 except for dir(Dir)
.
Opts
dir(Dir='.')
directory to change to
rec(Rec=false)
allow recursive descend call
% pupsh gbn_fisher_nets bground=white clr_theme=bic
Creates an undirected version of the above:
% pupsh gbn_fisher_nets bground=white clr_theme=bic type=graph postfix=biu
Requires pack(mtx)
and pack(os)
to work. pack(os)
is only required if DatF is a variable.
Loading does not complain if this lib does not load properly (this is to avoid annoying message
for user that do not require this modality of the predicate).
Every file ending in .bn is taken to a (Gobnilp generated) BN. There should be a single .dat file in the directory,
that is taken to hold the data used to create all BNs (Gobnilp default format).
Opts:
format(s)
- propagates to multi_cow_plot/2 as ext()
Options are also passed to gbn_family_gates/5 and multi_cow_plot/2.
For each value of Cid1 a row is created in PAMtx. For each value in Cid2 a column is created in PAMtx.
Values in PAMtx are binary and show presence (1) or absence of the particular Cid1/Cid2 values in Mtx.
PAMtx contains a header (all the Cid2 values, ordered) but now row names.
?- Mtx = [r(a,b,c),r(1,2,1),r(2,2,2)], gbn_mtx_paired( Mtx, a, c, PA ). PA = [row(1, 2), row(1, 0), row(0, 1)]. ?- Mtx = [r(ps,xs,ys),r(p1,x1,y1),r(p2,x2,y2),r(p1,x2,y3),r(p3,x3,y3)], gbn_mtx_paired( Mtx, ps, xs, PA ). PA = [row(x1, x2, x3), row(1, 1, 0), row(0, 1, 0), row(0, 0, 1)]. ?- Mtx = [r(ps,xs,ys),r(p1,x1,y1),r(p2,x2,y2),r(p1,x2,y3),r(p3,x3,y3),r(p1,x1,y1)], gbn_mtx_paired( Mtx, ps, xs, PA ). Mtx = [r(ps, xs, ys), r(p1, x1, y1), r(p2, x2, y2), r(p1, x2, y3), r(p3, x3, y3), r(p1, x1, y1)], PA = [row(x1, x2, x3), row(1, 1, 0), row(0, 1, 0), row(0, 0, 1)].
Opts
Gatrix
The first row holds the Child and the Parents consecutively.
Gatrix is passed through mtx/2 before being returned. Mtx is similarly treated as mtx/2 input.
BnVars is a list of atomic Bn variables. OutFile is an open/3 compatible file for writing.
Opts
Currently, this is the gate with smallest p.value. Ignoring direction seems the best default.
If no output file is given, it is constructed from DotF by postfixing (os_postfix/3) gates_best to the filename.
Opts
var(Dot)
)Opts
Opts See svg_legend/1.
?-
Files can be partially instantiated, to dictate the number of returned files.
Use debug(mtx_mins)
to display the Min cutoffs, and the size of each matrix.
Opts
mins(Mins=[_,_,_,_,_])
If ground, a list of the Mins to consider.
if non-ground, returns those that were generated
(can be a vars list to pass the implied Len)
from(From=5)
starting point for Mins, when generating them
by(By=5)
step
length(Len=5)
if Mins is a variable, use this to determine length of Mins
?-