|
a |
|
b/matlab_source/prioritization.m |
|
|
1 |
function [ ranked_list_genes, ranked_scores ] = prioritization( samples, F, F_opp, network_genes, choose_up_down_flag, rank_method_str) |
|
|
2 |
|
|
|
3 |
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|
|
4 |
% INPUTS: |
|
|
5 |
% samples: cell array of samples, contains the DNA changes and differentially expressed genes of each sample |
|
|
6 |
% F: diffused network (insulated heat diffusion). |
|
|
7 |
% F_opp: diffused network opposite direction (insulated heat diffusion). |
|
|
8 |
% network_genes: the names of all the network genes in the same order they appear in the adjacency matrix. |
|
|
9 |
% choose_up_down_flag: 1 diffuse only from mutations, 2 diffuse only from differentially expressed genes, 3 diffuse from both. |
|
|
10 |
% rank_method_str: 'MEDIAN' uses the median of the sample-specific ranks. |
|
|
11 |
% 'RRA' uses the Robust Rank Aggregation method to integrate sample-specific ranked lists. |
|
|
12 |
% 'SUM' uses the summation of the sample-specific ranks. |
|
|
13 |
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|
|
14 |
% OUTPUTS: |
|
|
15 |
% ranked_list_genes: list with the ranked gene names |
|
|
16 |
% ranked_scores: list with the scores of the ranked gene names |
|
|
17 |
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|
|
18 |
|
|
|
19 |
weights_all = zeros(length(samples.DNA_network),length(network_genes)); |
|
|
20 |
positions_sorted = zeros(length(network_genes),length(samples.DNA_network)); |
|
|
21 |
[final_weights_median,final_weights_sum,final_weights_rho] = deal(zeros(1,length(network_genes))); |
|
|
22 |
|
|
|
23 |
for i = 1:length(samples.DNA_network), %number of samples |
|
|
24 |
weights_all(i,:) = diffuse_all(choose_up_down_flag, samples.DNA_network{i}, samples.RNA_network{i}, network_genes, F, F_opp); |
|
|
25 |
to_sort_sorted = sortrows([weights_all(i,:) ;1:length(weights_all(i,:))]'); |
|
|
26 |
positions_sorted(:,i) = fliplr(to_sort_sorted(:,2)')'; |
|
|
27 |
end |
|
|
28 |
for j = 1:length(network_genes), % number of genes |
|
|
29 |
rank = zeros(length(samples.DNA_network),1); |
|
|
30 |
for i = 1:length(samples.DNA_network), % number of samples |
|
|
31 |
rank(i) = find(positions_sorted(:,i) == j); |
|
|
32 |
end |
|
|
33 |
final_weights_median(j) = median(rank); |
|
|
34 |
final_weights_sum(j) = sum(rank); |
|
|
35 |
final_weights_rho(j) = rhoScores(rank/max(rank)); |
|
|
36 |
end |
|
|
37 |
|
|
|
38 |
%choose the aggregation method |
|
|
39 |
if strcmp(rank_method_str, 'MEDIAN'), |
|
|
40 |
scores = final_weights_median; |
|
|
41 |
elseif strcmp(rank_method_str, 'SUM'), |
|
|
42 |
scores = final_weights_sum; |
|
|
43 |
else |
|
|
44 |
scores = final_weights_rho; |
|
|
45 |
end |
|
|
46 |
|
|
|
47 |
%sort scores |
|
|
48 |
to_sort_sorted_rho = sortrows([scores ;1:length(scores)]'); |
|
|
49 |
ranked_list_genes = network_genes(to_sort_sorted_rho(:,2)); |
|
|
50 |
ranked_scores = scores(to_sort_sorted_rho(:,2)); |
|
|
51 |
end |
|
|
52 |
|
|
|
53 |
function [ret_weights_all] = diffuse_all(choose_up_down_flag, sample_DNA, sample_RNA, network_genes, F, F_opp) |
|
|
54 |
%diffuse mutation labels |
|
|
55 |
if choose_up_down_flag == 1 || choose_up_down_flag == 3, |
|
|
56 |
mutation_weights = diffuse(intersect(sample_DNA,network_genes), network_genes, F); |
|
|
57 |
end |
|
|
58 |
%diffuse DE labels |
|
|
59 |
if choose_up_down_flag == 2 || choose_up_down_flag == 3, |
|
|
60 |
DE_weights = diffuse(intersect(sample_RNA,network_genes), network_genes, F_opp); |
|
|
61 |
end |
|
|
62 |
%combines scores by multiplication (use both mutations and DE) |
|
|
63 |
if choose_up_down_flag == 3, |
|
|
64 |
ret_weights_all = mutation_weights.*DE_weights; |
|
|
65 |
elseif choose_up_down_flag == 1, |
|
|
66 |
ret_weights_all = mutation_weights; |
|
|
67 |
else |
|
|
68 |
ret_weights_all = DE_weights; |
|
|
69 |
end |
|
|
70 |
end |
|
|
71 |
|
|
|
72 |
function [mutation_weights] = diffuse(inter_mut_sampl_network, network_genes, F) |
|
|
73 |
positions = find(ismember(network_genes,inter_mut_sampl_network)); |
|
|
74 |
mutation_weights= (1/length(positions))*ones(1,length(positions))*F(positions,:); |
|
|
75 |
end |