-
Notifications
You must be signed in to change notification settings - Fork 0
/
fig6.m
173 lines (147 loc) · 4.97 KB
/
fig6.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
clc
clear all
N = 19;
data_ = table2array(readtable('WT-new.csv'));
main_path = '2- Cell cycle generative model';
paths = ["N=1"; "N=2"; "N=3";];
h = figure
t = tiledlayout(3,1,'TileSpacing','Compact','Padding','Compact');
ax1 = nexttile;
cmap = jet(20);
data19 = zeros(19, 250);
cmap = jet(20);
data20 = zeros(20, 250);
for i=1:19
[newBBnum, rowBBnum, BBnum] = oneRow(main_path, paths, i, 19);
params = lwpparams('EPA', 1, false, 0.25, 'robust', true);
data19(i, :) = lwppredict(BBnum', newBBnum'./rowBBnum', params, linspace(350, 600, 250)');
end
hp_all1 = zeros(19, 1);
for i=1:19
if i==1
nums = (data19(19, :) + data19(1, :) + data19(2, :))/3;
elseif i==19
nums = (data19(19, :) + data19(1, :) + data19(18, :))/3;
else
nums = (data19(i-1, :) + data19(i, :) + data19(i+1, :))/3;
end
plot(linspace(350, 600, 250)', nums, 'LineWidth', 2, 'Color', cmap(i, :));
hp = find_half_point(nums);
hp_all1(i) = hp;
hold on
plot([350 + hp, 350 + hp], [0, nums(hp)], '--', 'LineWidth', 1.5, 'Color', cmap(i, :));
hold on
end
hold off
xlim([350, 600])
xlabel('Number of BBs', 'FontSize', 14);
ylabel('Fraction of new BBs', 'FontSize', 14);
title('19 ciliary row cell population', 'FontSize', 14);
ax2 = nexttile;
for i=1:20
[newBBnum, rowBBnum, BBnum] = oneRow(main_path, paths, i, 20);
params = lwpparams('EPA', 1, false, 0.25, 'robust', true);
data20(i, :) = lwppredict(BBnum', newBBnum'./rowBBnum', params, linspace(350, 600, 250)');
end
hp_all2 = zeros(20, 1);
for i=1:20
if i==1
nums = (data20(20, :) + data20(1, :) + data20(2, :))/3;
elseif i==20
nums = (data20(20, :) + data20(1, :) + data20(19, :))/3;
else
nums = (data20(i-1, :) + data20(i, :) + data20(i+1, :))/3;
end
plot(linspace(350, 600, 250)', nums, 'LineWidth', 2, 'Color', cmap(i, :));
hp = find_half_point(nums);
hp_all2(i) = hp;
hold on
plot([350 + hp, 350 + hp], [0, nums(hp)], '--', 'LineWidth', 1.5, 'Color', cmap(i, :),'HandleVisibility','off');
hold on
end
hold off
xlim([350, 600])
lgd = legend({'row 1', 'row 2', 'row 3', 'row 4', 'row 5', 'row 6', 'row 7', 'row 8', 'row 9', 'row 10',...
'row 11', 'row 12', 'row 13', 'row 14', 'row 15', 'row 16', 'row 17', 'row 18', 'row 19' 'row 20'}, 'location','eastoutside','FontSize', 14);
lgd.NumColumns = 5;
xlabel('Number of BBs', 'FontSize', 14);
ylabel('Fraction of new BBs', 'FontSize', 14);
title('20 ciliary row cell population', 'FontSize', 14);
linkaxes([ax1, ax2], 'y');
ax1.FontSize = 14;
ax2.FontSize = 14;
lgd.Layout.Tile = 3;
figure()
plot((1:19)/19, 350+hp_all1, 'o-', 'LineWidth', 1.5);
hold on
plot((1:20)/20, 350+hp_all2, 'o-', 'LineWidth', 1.5);
xlabel('Normalized row index', 'FontSize', 14);
ylabel({'Number of BBs at ciliary rows'; 'with 50% of their BBs assembled'})
legend('19 ciliary rows','20 ciliary rows', 'FontSize', 14);
ax = gca;
ax.FontSize = 14;
table = readtable('combined_data.csv', 'ReadVariableNames', true, 'ReadRowNames', true);
data = table2array(table);
[y, x]=histcounts(data(:, 8), 25, 'Normalization','cdf');
y = 3 * y';
x = x';
x(1:end-1) = x(1:end-1) + (x(2) - x(1))/2;
f=fit(y, x(1:end-1), 'smoothingspline', 'SmoothingParam',0.9995);
d1 = differentiate(f, y);
h=figure();
yyaxis left
plot(f, y, x(1:end-1));
hold on
ylabel('Number of BBs', 'FontSize', 14);
yyaxis right
plot(y, d1);
xlabel('Relative time (fraction of cell cycle)', 'FontSize', 14);
ylabel('BB replication rate (BB/h)', 'FontSize', 14);
ax = gca;
ax.FontSize = 14;
function [newBBnum, rowBBnum, BBnum] = oneRow(main_path, paths, row_, N)
r = 2;
newBBnum = [];
BBnum = [];
rowBBnum = [];
D = dir(main_path);
for j=1:length(paths)
full_path = fullfile(main_path, paths(j));
D = dir(full_path);
for k = 3:length(D)
if D(k).isdir
currD = D(k).name;
tempPath = fullfile(full_path, currD);
data = csvread(fullfile(tempPath, 'intensityAnalysis.csv'));
alignment = csvread(fullfile(tempPath, 'Alignment.csv'));
if size(alignment, 1) ~= N
continue
end
nRow = size(alignment, 1);
rowBBnum(end + 1) = sum(alignment(row_, :) > 0);
idx_ = find(data(:, 4)>r);
countTemp = zeros(size(alignment, 1), 4);
BBnum(end + 1) = size(data, 1);
temp = 0;
for ii=1:length(idx_)
[row ~]=find(alignment == idx_(ii));
if row == row_
temp =temp + 1;
end
end
newBBnum(end + 1) = temp;
end
end
end
end
function hp = find_half_point(nums)
total = sum(nums);
running_sum = 0;
for i=1:length(nums)
running_sum = running_sum + nums(i);
if running_sum > 0.5 * total
hp = i;
break
end
end
end