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