-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.m
63 lines (50 loc) · 2 KB
/
main.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
function main
clear all; clc;
%--------------------------------------------------------------------------------------------------
% User defined parameters and the necessary input files are defined here.
% User can change the values/file name against each variables defined here.
% Input - fraction of each cell type in the population
popFraction = xlsread('FractionCellType.xlsx');
% Input - fold change data
foldChange = xlsread('FoldChange.xlsx');
% Number of unknown parameters to be estimated for all time points
numOfUnk = 15;
% Number of cell states without dead state
numCellState = 3;
%-------------------------------------------------------------------------------------------------
% Computes the average fold change
numReplicate = size(foldChange, 1);
TEMP = mean(foldChange, 1);
foldChange = repmat(TEMP, numReplicate, 1);
% Converts the input cell fractions to a 3D array
k=0;
num = numOfUnk/numCellState;
rowNum = size(popFraction, 1);
popFract = zeros(rowNum, numCellState, num);
for j=1:num
popFract(:,:,j) = popFraction(:,(1+k:numCellState+k));
k = j*numCellState;
end
% Lower and Upper bounds of the parameters
lb = reshape(zeros(numOfUnk, 1), numCellState, num);
ub = reshape(ones(numOfUnk, 1), numCellState, num);
% Initial values of the unknown parameters
q0 = reshape(zeros(numOfUnk, 1), numCellState, num);
% Initialises temporary varibales to store the results of optimisation
q = zeros(numCellState, num);
% Iteratively executes optimisation for each time interval
for i = 1:num
fd = foldChange(:,i) - 1;
q(:,i) = optim(popFract(:,:,i), fd, lb(:,i), ub(:,i), q0(:,i));
end
% Saves the result in a tab delimited text file
Text(q);
end
function cellDiv = optim(f, k, lb, ub, q0)
% Performs optimisation using leat square linear solver
cellDiv = lsqlin(f,k,[],[],[],[],lb,ub,q0);
end
function Text(q)
% Exports the estimated parameters and the residuals in a tab deimited text file
dlmwrite('fractionalCellDivision.txt', q, 'delimiter', '\t');
end