% File: get_max_fisher_genes.m
% ----------------------------
% This function takes as input a matrix of patients (rows) and corresponding
% gene expression data (columns), a vector of labels, and the desired number of genes to be
% returned.  The sorted indices of genes corresponding to the top n max. fisher
% values and the actual fisher values are returned.


function [genes,fisher_vals] = get_max_fisher_genes(data,labels,num_genes)

id1 = (labels == 1);
id2 = (labels == 2);
data1 = data(id1, :);
data2 = data(id2, :);
stdcluster = (size(data1, 1) - 1) * std(data1, 0, 1).^2 + (size(data2, 1) - 1) * std(data2, 0, 1).^2;
distance = (mean(data1, 1) - mean(data2, 1)).^2;
fisher = distance ./ stdcluster;
[temp, Peakorder] = sort(fisher);
genes = Peakorder(length(Peakorder):-1:length(Peakorder)-num_genes+1);
fisher_vals = fisher(genes);