compareTwoSamp

PURPOSE ^

Compare the 2 sets of samples

SYNOPSIS ^

function [totalz,zscore,mdv1,mdv2] = compareTwoSamp(xglc,model,samp1,samp2,measuredMetabolites)

DESCRIPTION ^

 Compare the 2 sets of samples
 xglc is optional, a random sugar distribution is calculated if empty
 expects samp1 and samp2 to have a field named points containing
      an array of sampled points
 expects model.rxns to contain a list of rxn names
 measuredMetabolites is an optional parameter fed to calcMDVfromSamp.m
      which only calculates the MDVs for the metabolites listed in this
      array.  e.g.

 totalz is the sum of all zscores
 zscore is the calculated difference for each mdv element distributed
       across all the points
 mdv1,mdv2 each containing fields:
        - mdv - the calculated mdv distribution converted from the idv
        solved from each point contained in their respective samples sampX
        - names - the names of the metabolites 
        - ave - the average of each mdv element across all of the points
        - stdev - the standard dev for each mdv element across all points
 Wing Choi 2/11/08

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [totalz,zscore,mdv1,mdv2] = compareTwoSamp(xglc,model,samp1,samp2,measuredMetabolites)
0002    
0003 % Compare the 2 sets of samples
0004 % xglc is optional, a random sugar distribution is calculated if empty
0005 % expects samp1 and samp2 to have a field named points containing
0006 %      an array of sampled points
0007 % expects model.rxns to contain a list of rxn names
0008 % measuredMetabolites is an optional parameter fed to calcMDVfromSamp.m
0009 %      which only calculates the MDVs for the metabolites listed in this
0010 %      array.  e.g.
0011 %
0012 % totalz is the sum of all zscores
0013 % zscore is the calculated difference for each mdv element distributed
0014 %       across all the points
0015 % mdv1,mdv2 each containing fields:
0016 %        - mdv - the calculated mdv distribution converted from the idv
0017 %        solved from each point contained in their respective samples sampX
0018 %        - names - the names of the metabolites
0019 %        - ave - the average of each mdv element across all of the points
0020 %        - stdev - the standard dev for each mdv element across all points
0021 % Wing Choi 2/11/08
0022 
0023 %glc = zeros(62,1);
0024 %glc = [.2 ;.8 ;glc];
0025 
0026 if (nargin < 4)
0027     disp '[totalz,zscore,mdv1,mdv2] = compareTwoSamp(xglc,model,samp1,samp2,measuredMetabolites)';
0028     return;
0029 end
0030 
0031 if (nargin < 5)
0032     measuredMetabolites = [];
0033 end
0034 
0035 if (isempty(xglc))
0036     % random glucose
0037     xglc = rand(64,1);
0038     xglc = xglc/sum(xglc);
0039     xglc = idv2cdv(6)*xglc;
0040 end
0041 
0042     % generate the translation index array
0043     %   can shave time by not regenerating this array on every call.
0044     xltmdv = zeros(1,4096);    
0045     for i = 1:4096
0046         xltmdv(i) = length(strrep(dec2base(i-1,2),'0',''));
0047     end
0048 
0049 % calculate mdv for samp1 and samp2
0050 [mdv1] = calcMDVfromSamp(samp1.points,measuredMetabolites);
0051 [mdv2] = calcMDVfromSamp(samp2.points,measuredMetabolites);
0052 [totalz,zscore] = compareTwoMDVs(mdv1,mdv2);
0053 
0054 return
0055 end
0056 
0057     
0058 %Here's what the function does.
0059 %Apply slvrXXfast to each point
0060 %for each field in the output, apply iso2mdv to get a much shorter vector.
0061 %store all the mdv's for each point and for each metabolite in both sets.
0062 %
0063 %Compute the mean and standard deviation of each mdv and then get a z-score
0064 % between them (=(mean1-mean2)/(sqrt(sd1^2+sd2^2))).
0065 %Add up all the z-scores (their absolute value) and have this function return
0066 % that value.
0067 %
0068 %Intuitively what we're doing here is comparing the two sets based on
0069 % how different the mdv's appear.
0070 %We're going to see if different glucose mixtures result in different values.
0071 %I'm going to rewrite part of slvrXXfast so it doesn't return every metabolite
0072 % but only those we can actually measure, but for now just make it generic.
0073      
0074 function mdv = myidv2mdv (idv,xltmdv)
0075  
0076     % generate the mdv
0077     len = length(idv);
0078     %disp(sprintf('idv is %d long',len));
0079     mdv = zeros(1,xltmdv(len)+1);
0080     %disp(sprintf('mdv is %d long',length(mdv)));
0081     for i = 1:len
0082         idx = xltmdv(i) + 1;
0083         %disp(sprintf('idx is %d, currently on %d',idx,i));
0084         mdv(idx) = mdv(idx) + idv(i); 
0085     end
0086     
0087 return
0088 end

Generated on Thu 21-Jun-2012 15:39:23 by m2html © 2003