-
Notifications
You must be signed in to change notification settings - Fork 2
/
potpourri.m
45 lines (33 loc) · 1.63 KB
/
potpourri.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
function potpourri( X, Y, W, k, R, SNP_info, b, omega, maxMarginalSignificance, outputFileName)
p = inputParser;
p.CaseSensitive = false;
validInfo = @(x) validateattributes(x, {'string'}, ...
{'2d', 'cell'});
validIntegerScalar = @(x) validateattributes(x, {'numeric'}, ...
{'scalar','nonempty','real','nonnan','positive','integer'});
validFloat = @(x) validateattributes(x, {'numeric'}, ...
{'nonempty','real','nonnan','nonnegative'});
addRequired(p, 'SNP_info', validInfo);
addRequired(p, 'b', validIntegerScalar);
addRequired(p, 'maxMarginalSignificance', validIntegerScalar);
addRequired(p, 'omega', validFloat);
[indicators, Info] = spadis_logistic(double(X), Y, W, k, R, omega);
group_ids = zeros(size(indicators,1),1);
chr_info = str2double(SNP_info(:,2));
group_ind = 1;
for chr = 1:max(chr_info)
ind_chr = indicators(chr_info == chr);
chr_size = size(ind_chr,1);
group_ids_chr = zeros(chr_size,1);
indices = find(ind_chr);
for i = 1:size(indices,1)
ind_chr(max(1,indices(i)-b):min(chr_size,indices(i)+b)) = 1;
group_ids_chr(max(1,indices(i)-b):min(chr_size,indices(i)+b)) = group_ind;
group_ind = group_ind + 1;
end
indicators(chr_info == chr) = ind_chr;
group_ids(chr_info == chr) = group_ids_chr;
end
Y = logical(Y);
epistasis_test_mex(transpose(X(Y,indicators)), transpose(X(~Y,indicators)), SNP_info(indicators,:), group_ids(indicators), R(indicators), cellstr(outputFileName), maxMarginalSignificance);
end