-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpst_pfa_export_to_graphviz.m
More file actions
82 lines (61 loc) · 1.8 KB
/
pst_pfa_export_to_graphviz.m
File metadata and controls
82 lines (61 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
function pst_pfa_export_to_graphviz(PFA,varargin)
%pst_pfa_export_to_graphviz exports a PFA to a file suitable for visualization using
%graphviz
%
nparams=length(varargin);
output_dir=pwd;
filename='pfa_graphviz_export';
if mod(nparams,2)>0
error('Parameters must be specified as parameter/value pairs!');
end
for i=1:2:nparams
switch lower(varargin{i})
case 'output_dir'
output_dir=varargin{i+1};
case 'filename'
filename=varargin{i+1};
otherwise
end
end
dot_id=fopen(fullfile(output_dir,[filename '.dot']),'w');
%fprintf(noa_gsigma_id,'GsigmaS (class=String)\n');
% climb down the tree from the root node
% list all possible walks, specifying connections from one level to the next
% on each line
% first we need to
fprintf(dot_id,'digraph pfa {\n');
fprintf(dot_id,'\tnode [color=lightblue2, style=filled];\n')
fprintf(dot_id,'\trankdir=UD;\nsize="6.5,8.5"'); % changed rankdir from LR to UD
for i=2:length(PFA)
source=PFA(i).label;
for j=1:length(PFA(i).arcs)
target=PFA(i).arcs(j);
if PFA(i).arcs_p(j)<0.05
continue;
end
% gray 52 was used for paper, and 5 was added to make lines visible for talks
if PFA(i).arcs_p(j)<.2
fprintf(dot_id,'\t%s -> %s [penwidth=%g,weight=2,color=gray60]',source,PFA(target).label,5+PFA(i).arcs_p(j));
else
fprintf(dot_id,'\t%s -> %s [penwidth=%g,weight=2,color=black]',source,PFA(target).label,PFA(i).arcs_p(j)*40);
end
fprintf(dot_id,'\n');
end
end
for i=2:length(PFA)
source=PFA(i).label;
fprintf(dot_id,'\t%s [fontsize=55,ranksep=.5,nodesep=.5];\n',source);
end
%for i=2:length(PFA)
%
% source=PFA(i).label;
%
% if length(PFA(i).label)==1
% fprintf(dot_id,'\t%s [rank=source]\n',source);
% elseif length(PFA(i).label)>2
% fprintf(dot_id,'\t%s [rank=sink]\n',source);
% end
%end
fprintf(dot_id,'}')
fclose(dot_id);
% table for cytoscape 3.0