annotate egglib/egglib-2.1.5/include/egglib-cpp/MicrosatelliteDiversity.hpp @ 1:420b57c3c185 draft

Uploaded
author dereeper
date Fri, 10 Jul 2015 04:39:30 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
1 /*
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
2 Copyright 2008-2010 Stéphane De Mita, Mathieu Siol
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
3
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
4 This file is part of the EggLib library.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
5
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
6 EggLib is free software: you can redistribute it and/or modify
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
8 the Free Software Foundation, either version 3 of the License, or
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
9 (at your option) any later version.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
10
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
11 EggLib is distributed in the hope that it will be useful,
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
14 GNU General Public License for more details.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
15
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
17 along with EggLib. If not, see <http://www.gnu.org/licenses/>.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
18 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
19
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
20 #ifndef EGGLIB_MICROSATELLITEDIVERSITY_HPP
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
21 #define EGGLIB_MICROSATELLITEDIVERSITY_HPP
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
22
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
23 #include "DataMatrix.hpp"
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
24 #include <cstdlib>
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
25
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
26 namespace egglib {
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
27
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
28 /** \brief Analyzes microsatellite data
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
29 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
30 * \ingroup polymorphism
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
31 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
32 * Use the load() method to analyze data. All sites will be analyzed
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
33 * and accessors allow to access the value of a given statistics for
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
34 * a given site. There is no out-of-bound checking implemented in
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
35 * accessors.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
36 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
37 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
38 class MicrosatelliteDiversity {
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
39
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
40 public:
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
41
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
42 /** \brief Creates an object
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
43 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
44 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
45 MicrosatelliteDiversity();
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
46
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
47
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
48 /** \brief Destroys an object
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
49 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
50 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
51 virtual ~MicrosatelliteDiversity();
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
52
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
53
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
54 /** \brief Performs the analysis
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
55 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
56 * \param dataMatrix the object to analyze.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
57 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
58 * \param missingData the integer identifying missing data.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
59 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
60 * \param noMissingData if true, no allele will be
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
61 * excluded (including the one identified by the argument
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
62 * missingData).
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
63 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
64 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
65 void load(const DataMatrix& dataMatrix,
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
66 int missingData=999, bool noMissingData=false);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
67
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
68
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
69 /// Number of sites (or markers)
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
70 unsigned int numberOfSites() const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
71
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
72 /// Heterozygosity
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
73 double He(unsigned int siteIndex) const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
74
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
75 /// Number of alleles
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
76 unsigned int numberOfAlleles(unsigned int siteIndex) const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
77
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
78 /// Variance of allele size
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
79 double sizeVariance(unsigned int siteIndex) const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
80
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
81 /// IAM-based estimator of theta
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
82 double thetaAssumingIAM(unsigned int siteIndex) const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
83
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
84 /// SMM-based estimator of theta, calculated from He
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
85 double thetaAssumingSMMfromHe(unsigned int siteIndex) const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
86
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
87 /// SMM-based estimator of theta, calculated from VarSize
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
88 double thetaAssumingSMMfromSizeVariance(unsigned int siteIndex) const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
89
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
90
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
91 protected:
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
92
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
93 unsigned int v_numberOfSites;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
94 double *v_He;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
95 unsigned int *v_numberOfAlleles;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
96 double *v_sizeVariance;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
97 double *v_thetaAssumingIAM;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
98 double *v_thetaAssumingSMMfromHe;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
99 double *v_thetaAssumingSMMfromSizeVariance;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
100
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
101 void init();
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
102 void clear();
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
103
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
104
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
105 private:
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
106
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
107
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
108 /// No copy allowed
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
109 MicrosatelliteDiversity(const MicrosatelliteDiversity& source) {
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
110 }
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
111
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
112 /// No copy allowed
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
113 MicrosatelliteDiversity& operator=(const MicrosatelliteDiversity& source) {
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
114 return *this;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
115 }
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
116
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
117 };
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
118 }
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
119
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
120 #endif