forked from lrvarshney/elegans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
multDist_gap.m
92 lines (77 loc) · 2.76 KB
/
multDist_gap.m
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
83
84
85
86
87
88
89
90
91
92
function multDist_gap(varargin)
%MULTDIST_GAP Plots the multiplicity survival function for the gap junction network.
% MULTDIST_GAP produces a plot of the survival function of the multiplicty
% of the gap junction network together with a power law fit.
%
% MULTDIST_GAP(A) produces a plot of the survival function of the
% multiplicity of an undirected network with adjacency matrix A.
%
% See also MULTDIST_CHEM.
% Copyright 2006-2009. Lav R. Varshney
%
% This software is provided without warranty.
% Related article:
%
% L. R. Varshney, B. L. Chen, E. Paniagua, D. H. Hall, and D. B.
% Chklovskii, "Structural properties of the Caenorhabditis elegans
% neuronal network," 2009, in preparation.
%adjacency matrix
if (nargin == 0)
%load the gap junction network
A = full(datareader('gap','weighted'));
elseif (nargin == 1)
A = varargin{1};
else
error('MULTDIST_GAP: incorrect number of inputs');
end
%the multiplicity
mult = zeros(1,max(max(A))+1);
for ii = 1:length(A)
for jj = 1:length(A)
if ii ~= jj
mult(A(ii,jj)+1) = mult(A(ii,jj)+1) + 1;
end
end
end
%the multiplicity distribution
p = mult./sum(mult);
%the multiplicity distribution excluding unconnected pairs
q = p(2:end)./sum(p(2:end));
mean_mult_excluding_unconnected = sum(q.*(1:length(mult)-1));
%the survival function
for ii = 0:length(mult)-1
P(ii+1) = sum(p(ii+1:end));
end
%locations where the survival function takes true values
II = find(p) - 1;
%power law fit to tail yields parameters:
if (nargin == 0)
xmin = 2;
alpha = 2.76;
end
%plot the survival function
figure
hold on
plot(0:length(mult)-1,P,'LineWidth',3)
plot(II,P(II+1),'.','MarkerSize',14)
%plot the power law fit
if (nargin == 0)
x = xmin:length(mult)-1;
plot(x,(P(xmin+1))*(Hurwitz_zeta(alpha,x)./Hurwitz_zeta(alpha,xmin)),'r','linewidth',3);
end
hold off
xlabel('multiplicity','FontSize',16)
ylabel('multiplicity survival function','FontSize',16)
if (nargin == 0)
%plot and annotate the mean with unconnected pairs excluded
hold on
plot([mean_mult_excluding_unconnected mean_mult_excluding_unconnected],[1.23*0.00001 1.23*0.00001],'Marker','v','MarkerFaceColor','b')
text(mean_mult_excluding_unconnected-log10(0.07*25),2.5*0.00001,strcat('mean=',num2str(mean_mult_excluding_unconnected,3)),'FontSize',14)
hold off
%adjust the axis limits and axis scale
axis([0 25 0.00001 1])
set(gca,'XScale','log','YScale','log','FontSize',14)
%add text arrow annotations
annotation('textarrow',[0.7173 0.75],[0.4464 0.2619],'String','PVPR-DVC','FontSize',14);
annotation('textarrow',[0.8333 0.878],[0.3968 0.2143],'String','AVFR-AVFL','FontSize',14);
end