forked from SysBioChalmers/RAVEN
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request SysBioChalmers#489 from SysBioChalmers/feat/misc
feat/fix: miscellaneous
- Loading branch information
Showing
23 changed files
with
1,519 additions
and
1,205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,7 +72,7 @@ | |
Zf(i)=Zf(i)*-1; | ||
end | ||
end | ||
|
||
I=Zf(i)/Tex(i); | ||
if I<0 | ||
pM(i)=erf(abs(Zf(i))); | ||
|
@@ -95,14 +95,14 @@ | |
for i=1:10 | ||
fprintf([num2str(J(i)) '\t' num2str(I(i)) '\n']); | ||
end | ||
|
||
%The top 10 hits in the first category | ||
[I, J]=sort(pH,'descend'); | ||
fprintf('\nReactions which change in expression but not in flux\nReaction\tProbability\n'); | ||
for i=1:10 | ||
fprintf([num2str(J(i)) '\t' num2str(I(i)) '\n']); | ||
end | ||
|
||
%The top 10 hits in the first category | ||
[I, J]=sort(pM,'descend'); | ||
fprintf('\nReactions which change in flux but not in expression, or in opposed directions in flux and expression\nReaction\tProbability\n'); | ||
|
@@ -111,3 +111,63 @@ | |
end | ||
end | ||
end | ||
|
||
function p = tcdf(t,v,uflag) | ||
% TCDF Student's T cumulative distribution function (cdf). | ||
% | ||
% P = TCDF(X,V) computes the cdf for Student's T distribution | ||
% with V degrees of freedom, at the values in X. V must be a | ||
% scalar or have the same size as T. | ||
% | ||
% P = TCDF(X,V,'upper') computes it for the upper tail instead | ||
% of the lower tail. | ||
% | ||
% This is an alternative to the TCDF function that is implemented | ||
% in the Matlab statistics toolbox. This version originates from | ||
% http://www.statsci.org/matlab/statbox.html and originally was called TP. | ||
% It has been renamed to TCDF for drop-in compatibility with the Matlab | ||
% version. | ||
% | ||
% Gordon Smyth, University of Queensland, [email protected] | ||
% 3 Apr 97 | ||
% | ||
% NaN compatible - Markus Bauer and Eric Maris, FCDC | ||
% 27 Jan 2005 | ||
% | ||
% fixed bug concerning NaN compatibility | ||
% 21 Aug 2006, Markus Siegel | ||
% | ||
% added support for upper tail, see http://bugzilla.fieldtriptoolbox.org/show_bug.cgi?id=3045 | ||
% 13 Jan 2016, Robert Oostenveld | ||
% | ||
% taken from https://github.com/fieldtrip/fieldtrip/blob/master/external/stats/tcdf.m | ||
% 05 May 2022 | ||
|
||
if v <= 0, error('Degrees of freedom must be positive.'); end | ||
|
||
% resize v if necessary | ||
if all(size(v)==1) | ||
v = ones(size(t))*v; | ||
end | ||
|
||
%check for NaN's - don't do calculations on them, give those out as NaNs | ||
if any( not(isfinite(t(:))) | not(isfinite(v(:))) ) | ||
sel = find(isfinite(t) & isfinite(v)); | ||
x=nan(size(t)); | ||
p=nan(size(t)); | ||
x(sel) = t(sel).^2 ./ (v(sel) + t(sel).^2) ; | ||
p(sel) = 0.5 .* ( 1 + sign(t(sel)) .* betainc( x(sel), 0.5, 0.5*v(sel) ) ); | ||
else | ||
x = t.^2 ./ (v + t.^2) ; | ||
p = 0.5 .* ( 1 + sign(t) .* betainc( x, 0.5, 0.5*v ) ); | ||
end | ||
|
||
if nargin==3 | ||
if strcmp(uflag, 'upper') | ||
% compute it for the upper tail instead of the lower tail | ||
p = 1-p; | ||
else | ||
error('incorrect specification of uflag'); | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
function printOrange(stringToPrint) | ||
% printOrange | ||
% Print orange-colored stringToPrint to the MATLAB Command Window. Only | ||
% if MATLAB is open with GUI, does not work with command-line MATLAB. | ||
% | ||
% Input: | ||
% stringToPrint string that should be printed in orange color | ||
% | ||
% Usage: printOrange(stringToPrint) | ||
try useDesktop = usejava('desktop'); catch, useDesktop = false; end | ||
if useDesktop | ||
fprintf(['[\b' stringToPrint,']\b']) | ||
else | ||
fprintf(stringToPrint) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,9 @@ <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^ | |
</ul> | ||
<!-- crossreference --> | ||
|
||
|
||
<h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> | ||
<ul style="list-style-image:url(../matlabicon.gif)"> | ||
<li><a href="#_sub1" class="code">function p = tcdf(t,v,uflag)</a></li></ul> | ||
|
||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> | ||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function scores=analyzeSampling(Tex, df, solutionsA, solutionsB, printResults)</a> | ||
|
@@ -137,23 +139,23 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr | |
0065 I=mB(i)/mA(i); | ||
0066 <span class="keyword">if</span> I<0 | ||
0067 pM(i)=erf(abs(Zf(i))); | ||
0068 pH(i)=(1-pM(i))*(2*tcdf(abs(Tex(i)),df)-1); | ||
0068 pH(i)=(1-pM(i))*(2*<a href="#_sub1" class="code" title="subfunction p = tcdf(t,v,uflag)">tcdf</a>(abs(Tex(i)),df)-1); | ||
0069 pR(i)=0; | ||
0070 <span class="keyword">else</span> | ||
0071 <span class="keyword">if</span> mB(i)<0 | ||
0072 Zf(i)=Zf(i)*-1; | ||
0073 <span class="keyword">end</span> | ||
0074 <span class="keyword">end</span> | ||
0075 | ||
0075 | ||
0076 I=Zf(i)/Tex(i); | ||
0077 <span class="keyword">if</span> I<0 | ||
0078 pM(i)=erf(abs(Zf(i))); | ||
0079 pH(i)=(1-pM(i))*(2*tcdf(abs(Tex(i)),df)-1); | ||
0079 pH(i)=(1-pM(i))*(2*<a href="#_sub1" class="code" title="subfunction p = tcdf(t,v,uflag)">tcdf</a>(abs(Tex(i)),df)-1); | ||
0080 pR(i)=0; | ||
0081 <span class="keyword">else</span> | ||
0082 pR(i)=erf(abs(Zf(i)))*(2*tcdf(abs(Tex(i)),df)-1); | ||
0083 pH(i)=(2*tcdf(abs(Tex(i)),df)-1)*(1-erf(abs(Zf(i)))); | ||
0084 pM(i)=erf(abs(Zf(i)))*(1-(2*tcdf(abs(Tex(i)),df)-1)); | ||
0082 pR(i)=erf(abs(Zf(i)))*(2*<a href="#_sub1" class="code" title="subfunction p = tcdf(t,v,uflag)">tcdf</a>(abs(Tex(i)),df)-1); | ||
0083 pH(i)=(2*<a href="#_sub1" class="code" title="subfunction p = tcdf(t,v,uflag)">tcdf</a>(abs(Tex(i)),df)-1)*(1-erf(abs(Zf(i)))); | ||
0084 pM(i)=erf(abs(Zf(i)))*(1-(2*<a href="#_sub1" class="code" title="subfunction p = tcdf(t,v,uflag)">tcdf</a>(abs(Tex(i)),df)-1)); | ||
0085 <span class="keyword">end</span> | ||
0086 <span class="keyword">end</span> | ||
0087 | ||
|
@@ -167,22 +169,82 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr | |
0095 <span class="keyword">for</span> i=1:10 | ||
0096 fprintf([num2str(J(i)) <span class="string">'\t'</span> num2str(I(i)) <span class="string">'\n'</span>]); | ||
0097 <span class="keyword">end</span> | ||
0098 | ||
0098 | ||
0099 <span class="comment">%The top 10 hits in the first category</span> | ||
0100 [I, J]=sort(pH,<span class="string">'descend'</span>); | ||
0101 fprintf(<span class="string">'\nReactions which change in expression but not in flux\nReaction\tProbability\n'</span>); | ||
0102 <span class="keyword">for</span> i=1:10 | ||
0103 fprintf([num2str(J(i)) <span class="string">'\t'</span> num2str(I(i)) <span class="string">'\n'</span>]); | ||
0104 <span class="keyword">end</span> | ||
0105 | ||
0105 | ||
0106 <span class="comment">%The top 10 hits in the first category</span> | ||
0107 [I, J]=sort(pM,<span class="string">'descend'</span>); | ||
0108 fprintf(<span class="string">'\nReactions which change in flux but not in expression, or in opposed directions in flux and expression\nReaction\tProbability\n'</span>); | ||
0109 <span class="keyword">for</span> i=1:10 | ||
0110 fprintf([num2str(J(i)) <span class="string">'\t'</span> num2str(I(i)) <span class="string">'\n'</span>]); | ||
0111 <span class="keyword">end</span> | ||
0112 <span class="keyword">end</span> | ||
0113 <span class="keyword">end</span></pre></div> | ||
0113 <span class="keyword">end</span> | ||
0114 | ||
0115 <a name="_sub1" href="#_subfunctions" class="code">function p = tcdf(t,v,uflag)</a> | ||
0116 <span class="comment">% TCDF Student's T cumulative distribution function (cdf).</span> | ||
0117 <span class="comment">%</span> | ||
0118 <span class="comment">% P = TCDF(X,V) computes the cdf for Student's T distribution</span> | ||
0119 <span class="comment">% with V degrees of freedom, at the values in X. V must be a</span> | ||
0120 <span class="comment">% scalar or have the same size as T.</span> | ||
0121 <span class="comment">%</span> | ||
0122 <span class="comment">% P = TCDF(X,V,'upper') computes it for the upper tail instead</span> | ||
0123 <span class="comment">% of the lower tail.</span> | ||
0124 <span class="comment">%</span> | ||
0125 <span class="comment">% This is an alternative to the TCDF function that is implemented</span> | ||
0126 <span class="comment">% in the Matlab statistics toolbox. This version originates from</span> | ||
0127 <span class="comment">% http://www.statsci.org/matlab/statbox.html and originally was called TP.</span> | ||
0128 <span class="comment">% It has been renamed to TCDF for drop-in compatibility with the Matlab</span> | ||
0129 <span class="comment">% version.</span> | ||
0130 <span class="comment">%</span> | ||
0131 <span class="comment">% Gordon Smyth, University of Queensland, [email protected]</span> | ||
0132 <span class="comment">% 3 Apr 97</span> | ||
0133 <span class="comment">%</span> | ||
0134 <span class="comment">% NaN compatible - Markus Bauer and Eric Maris, FCDC</span> | ||
0135 <span class="comment">% 27 Jan 2005</span> | ||
0136 <span class="comment">%</span> | ||
0137 <span class="comment">% fixed bug concerning NaN compatibility</span> | ||
0138 <span class="comment">% 21 Aug 2006, Markus Siegel</span> | ||
0139 <span class="comment">%</span> | ||
0140 <span class="comment">% added support for upper tail, see http://bugzilla.fieldtriptoolbox.org/show_bug.cgi?id=3045</span> | ||
0141 <span class="comment">% 13 Jan 2016, Robert Oostenveld</span> | ||
0142 <span class="comment">%</span> | ||
0143 <span class="comment">% taken from https://github.com/fieldtrip/fieldtrip/blob/master/external/stats/tcdf.m</span> | ||
0144 <span class="comment">% 05 May 2022</span> | ||
0145 | ||
0146 <span class="keyword">if</span> v <= 0, error(<span class="string">'Degrees of freedom must be positive.'</span>); <span class="keyword">end</span> | ||
0147 | ||
0148 <span class="comment">% resize v if necessary</span> | ||
0149 <span class="keyword">if</span> all(size(v)==1) | ||
0150 v = ones(size(t))*v; | ||
0151 <span class="keyword">end</span> | ||
0152 | ||
0153 <span class="comment">%check for NaN's - don't do calculations on them, give those out as NaNs</span> | ||
0154 <span class="keyword">if</span> any( not(isfinite(t(:))) | not(isfinite(v(:))) ) | ||
0155 sel = find(isfinite(t) & isfinite(v)); | ||
0156 x=nan(size(t)); | ||
0157 p=nan(size(t)); | ||
0158 x(sel) = t(sel).^2 ./ (v(sel) + t(sel).^2) ; | ||
0159 p(sel) = 0.5 .* ( 1 + sign(t(sel)) .* betainc( x(sel), 0.5, 0.5*v(sel) ) ); | ||
0160 <span class="keyword">else</span> | ||
0161 x = t.^2 ./ (v + t.^2) ; | ||
0162 p = 0.5 .* ( 1 + sign(t) .* betainc( x, 0.5, 0.5*v ) ); | ||
0163 <span class="keyword">end</span> | ||
0164 | ||
0165 <span class="keyword">if</span> nargin==3 | ||
0166 <span class="keyword">if</span> strcmp(uflag, <span class="string">'upper'</span>) | ||
0167 <span class="comment">% compute it for the upper tail instead of the lower tail</span> | ||
0168 p = 1-p; | ||
0169 <span class="keyword">else</span> | ||
0170 error(<span class="string">'incorrect specification of uflag'</span>); | ||
0171 <span class="keyword">end</span> | ||
0172 <span class="keyword">end</span> | ||
0173 <span class="keyword">end</span></pre></div> | ||
<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> © 2005</address> | ||
</body> | ||
</html> |
Oops, something went wrong.