calcMDVfromSamp

PURPOSE ^

SYNOPSIS ^

function [output] = calcMDVfromSamp(glc,points,experiment)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [output] = calcMDVfromSamp(glc,points,experiment)
0002 
0003 npoints = size(points,2);
0004 fprintf('found %d samples in input\n',npoints);
0005 
0006 % hard set for # of samples we will convert to mdv.
0007 % npoints = 2;
0008 fprintf('processing %d samples\n',npoints);
0009 
0010 output = struct;
0011 mdv = [];
0012 
0013 if isempty(glc)
0014     glc = experiment.inputfrag;
0015 else
0016     glc = convert_input(glc);
0017 end
0018 if isempty(experiment)
0019     o = slvrEMU_fast(points(:,1), glc);
0020     names = fields(o);
0021 else
0022     names = fields(experiment.fragments);
0023 end
0024 
0025 parfor c = 1:npoints 
0026     o = slvrEMU_fast(points(:,c), glc);
0027     tmdv = zeros(0,1);
0028     if ~ isempty(experiment)
0029         for l = 1:length(names)
0030             name = names{l};
0031             tname = experiment.fragments.(name).metfrag;
0032             tresult = o.(tname);
0033             tmdv = [tmdv; tresult];
0034         end
0035     else
0036         for l = 1:length(names)
0037             tresult = o.(names{l});
0038             tmdv = [tmdv; tresult];
0039         end
0040     end
0041     mdv(:,c) = tmdv;
0042 end
0043 
0044 o = slvrEMU_fast(points(:,1), glc);
0045 mdvnames = {};
0046 k = 1;
0047 for l = 1:length(names)
0048     name = names{l};
0049     if isempty(experiment)
0050         tname = name; 
0051     else
0052         tname = experiment.fragments.(name).metfrag;
0053     end
0054     tresult = o.(tname);
0055     for i = 1:length(tresult)
0056         newname = strcat(name, num2str(i-1));
0057         mdvnames{k,1} = newname;
0058         k = k+1;
0059     end
0060 end
0061             
0062 
0063 %Here's what the function does.
0064 %Apply slvrEMU_fast to each point
0065 %for each field in the output, apply iso2mdv to get a much shorter vector.
0066 %store all the mdv's for each point and for each metabolite in both sets.
0067 %
0068 %Compute the mean and standard deviation of each mdv and then get a z-score
0069 % between them (=(mean1-mean2)/(sqrt(sd1^2+sd2^2))).
0070 %Add up all the z-scores (their absolute value) and have this function return
0071 % that value.
0072 %
0073 %Intuitively what we're doing here is comparing the two sets based on
0074 % how different the mdv's appear.
0075 %We're going to see if different glucose mixtures result in different values.
0076 %I'm going to rewrite part of slvrEMU_fast.m so it doesn't return every metabolite
0077 % but only those we can actually measure, but for now just make it generic.
0078 
0079 %calculate mean and stdev for each metabolite
0080 ave = mean(mdv,2);
0081 stdev = std(mdv,0,2);
0082    
0083 output.mdv = mdv;
0084 output.names = mdvnames;
0085 output.ave = ave;
0086 output.stdev = stdev;
0087 if ~isempty(experiment)
0088     output.xglc = experiment.input;
0089 end
0090 
0091 return
0092 end

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