stats_8h_source.html 15 KB
Newer Older
RomainFeron's avatar
RomainFeron committed
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Romain Feron's avatar
Romain Feron committed
2
3
4
5
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
RomainFeron's avatar
RomainFeron committed
6
<meta name="generator" content="Doxygen 1.8.17"/>
Romain Feron's avatar
Romain Feron committed
7
<meta name="viewport" content="width=device-width, initial-scale=1"/>
RomainFeron's avatar
RomainFeron committed
8
<title>RADSex: /home/romain/work/code/RadSex/src/stats.h Source File</title>
Romain Feron's avatar
Romain Feron committed
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">RADSex
   &#160;<span id="projectnumber">1.0.0</span>
   </div>
   <div id="projectbrief">RAD-Sequencing analysis pipeline for sex determination</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
RomainFeron's avatar
RomainFeron committed
38
<!-- Generated by Doxygen 1.8.17 -->
Romain Feron's avatar
Romain Feron committed
39
<script type="text/javascript">
RomainFeron's avatar
RomainFeron committed
40
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
Romain Feron's avatar
Romain Feron committed
41
var searchBox = new SearchBox("searchBox", "search",false,'Search');
RomainFeron's avatar
RomainFeron committed
42
/* @license-end */
Romain Feron's avatar
Romain Feron committed
43
44
45
46
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
RomainFeron's avatar
RomainFeron committed
47
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
Romain Feron's avatar
Romain Feron committed
48
49
50
51
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
RomainFeron's avatar
RomainFeron committed
52
/* @license-end */</script>
Romain Feron's avatar
Romain Feron committed
53
54
55
56
57
58
59
60
61
62
63
64
65
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
RomainFeron's avatar
RomainFeron committed
66
67
68
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('stats_8h_source.html',''); initResizable(); });
/* @license-end */
Romain Feron's avatar
Romain Feron committed
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">stats.h</div>  </div>
</div><!--header-->
<div class="contents">
RomainFeron's avatar
RomainFeron committed
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<a href="stats_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/*</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment">* Copyright (C) 2020 Romain Feron</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment">* This file is part of RADSex.</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"></span> </div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment">* RADSex is free software: you can redistribute it and/or modify</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment">* it under the terms of the GNU General Public License as published by</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment">* the Free Software Foundation, either version 3 of the License, or</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="comment">* (at your option) any later version.</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment"></span> </div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment">* RADSex is distributed in the hope that it will be useful,</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment">* but WITHOUT ANY WARRANTY; without even the implied warranty of</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment">* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="comment">* GNU General Public License for more details.</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="comment"></span> </div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="comment">* You should have received a copy of the GNU General Public License</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment">* along with RADSex.  If not, see &lt;https://www.gnu.org/licenses/&gt;.</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="comment">*/</span></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160; </div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="preprocessor">#pragma once</span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="preprocessor">#include &quot;kfun/kfun.h&quot;</span></div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="utils_8h.html">utils.h</a>&quot;</span></div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160; </div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160; </div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;<span class="keywordtype">double</span> <a class="code" href="stats_8h.html#a5a9da7099d84d5d32564b19258e5922e">get_chi_squared</a>(uint n_group1, uint n_group2, uint total_group1, uint total_group2);</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160; </div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160; </div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160; </div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;<span class="keywordtype">double</span> <a class="code" href="stats_8h.html#aec79b726063a68726bc46f67a25804a9">get_chi_squared_p</a>(<span class="keywordtype">double</span> chi_squared);</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160; </div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160; </div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;<span class="keywordtype">double</span> <a class="code" href="stats_8h.html#a748519ef79463c2bc861ef5f2f950cd0">get_p_association</a>(uint n_group1, uint n_group2, uint total_group1, uint total_group2);</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160; </div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160; </div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160; </div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;<span class="keyword">template</span>&lt;<span class="keyword">typename</span> T&gt;</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160; </div>
<div class="line"><a name="l00078"></a><span class="lineno"><a class="line" href="stats_8h.html#a0a6e6b063bfb0c9e74cf03c78f604596">   78</a></span>&#160;T <a class="code" href="stats_8h.html#a0a6e6b063bfb0c9e74cf03c78f604596">find_median</a>(std::vector&lt;T&gt;&amp; container) {</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160; </div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;    T median;</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160; </div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;    <span class="keyword">const</span> <span class="keyword">auto</span> start = container.begin();</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;    <span class="keyword">const</span> <span class="keyword">auto</span> end = container.end() - 1;</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;    <span class="keyword">const</span> <span class="keyword">auto</span> size = container.size();</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160; </div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;    <span class="keywordflow">if</span> (size % 2 == 0) {  <span class="comment">// Find median for an even sized container (average of two possible median points)</span></div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160; </div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;        <span class="keyword">const</span> <span class="keyword">auto</span> median_it1 = start + size / 2 - 1;</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;        <span class="keyword">const</span> <span class="keyword">auto</span> median_it2 = start + size / 2;</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160; </div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;        std::nth_element(start, median_it1 , end);</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;        <span class="keyword">const</span> <span class="keyword">auto</span> e1 = *median_it1;</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160; </div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;        std::nth_element(start, median_it2 , end);</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;        <span class="keyword">const</span> <span class="keyword">auto</span> e2 = *median_it2;</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160; </div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;        median= (e1 + e2) / 2;</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160; </div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;    } <span class="keywordflow">else</span> {  <span class="comment">// Find median for odd sized vector</span></div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160; </div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;        <span class="keyword">const</span> <span class="keyword">auto</span> median_it = start + size / 2;</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;        std::nth_element(start, median_it , end);</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;        median = *median_it;</div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;    }</div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160; </div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;    <span class="keywordflow">return</span> median;</div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;}</div>
Romain Feron's avatar
Romain Feron committed
156
157
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
RomainFeron's avatar
RomainFeron committed
158
159
160
161
162
<div class="ttc" id="astats_8h_html_aec79b726063a68726bc46f67a25804a9"><div class="ttname"><a href="stats_8h.html#aec79b726063a68726bc46f67a25804a9">get_chi_squared_p</a></div><div class="ttdeci">double get_chi_squared_p(double chi_squared)</div><div class="ttdoc">Get P-value for a Chi-squared test.</div><div class="ttdef"><b>Definition:</b> <a href="stats_8cpp_source.html#l00026">stats.cpp:26</a></div></div>
<div class="ttc" id="astats_8h_html_a748519ef79463c2bc861ef5f2f950cd0"><div class="ttname"><a href="stats_8h.html#a748519ef79463c2bc861ef5f2f950cd0">get_p_association</a></div><div class="ttdeci">double get_p_association(uint n_group1, uint n_group2, uint total_group1, uint total_group2)</div><div class="ttdoc">Compute the p-value of association with group with a Chi-squared test.</div><div class="ttdef"><b>Definition:</b> <a href="stats_8cpp_source.html#l00065">stats.cpp:65</a></div></div>
<div class="ttc" id="autils_8h_html"><div class="ttname"><a href="utils_8h.html">utils.h</a></div><div class="ttdoc">Implements general utility functions used.</div></div>
<div class="ttc" id="astats_8h_html_a0a6e6b063bfb0c9e74cf03c78f604596"><div class="ttname"><a href="stats_8h.html#a0a6e6b063bfb0c9e74cf03c78f604596">find_median</a></div><div class="ttdeci">T find_median(std::vector&lt; T &gt; &amp;container)</div><div class="ttdoc">Find median value for a vector.</div><div class="ttdef"><b>Definition:</b> <a href="stats_8h_source.html#l00078">stats.h:78</a></div></div>
<div class="ttc" id="astats_8h_html_a5a9da7099d84d5d32564b19258e5922e"><div class="ttname"><a href="stats_8h.html#a5a9da7099d84d5d32564b19258e5922e">get_chi_squared</a></div><div class="ttdeci">double get_chi_squared(uint n_group1, uint n_group2, uint total_group1, uint total_group2)</div><div class="ttdoc">Compute Chi-squared.</div><div class="ttdef"><b>Definition:</b> <a href="stats_8cpp_source.html#l00041">stats.cpp:41</a></div></div>
Romain Feron's avatar
Romain Feron committed
163
164
165
166
167
168
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="stats_8h.html">stats.h</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
RomainFeron's avatar
RomainFeron committed
169
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.17 </li>
Romain Feron's avatar
Romain Feron committed
170
171
172
173
  </ul>
</div>
</body>
</html>