|
22 | 22 | #include <string> |
23 | 23 |
|
24 | 24 | struct LevelsCounter { |
| 25 | + |
| 26 | + // context is the dinucleotide or trinucleotide in which this |
| 27 | + // cytosine resides. The documentation for the counts and levels |
| 28 | + // tools provide more information about this context string. |
25 | 29 | std::string context; |
| 30 | + |
| 31 | + // total_sites is the total number of sites summarized, all of which |
| 32 | + // are consistent with the context string. If the context string is |
| 33 | + // empty or not used, then any constraints on which sites are |
| 34 | + // counted among this total is defined separately. |
26 | 35 | uint64_t total_sites{}; |
| 36 | + |
| 37 | + // sites_covered is the number of reference genome sites analyzed |
| 38 | + // that have at least one mapped read covering them. |
27 | 39 | uint64_t sites_covered{}; |
| 40 | + |
| 41 | + // max_depth is the number of reads covering the reference genome |
| 42 | + // site having the most mapped reads covering it. |
28 | 43 | uint64_t max_depth{}; |
| 44 | + |
| 45 | + // mutations is the number of sites tagged as having been mutated in |
| 46 | + // the sample based on the mapped reads in comparisin with the |
| 47 | + // underlying reference genome site. This may be indicated in |
| 48 | + // various ways and defined in various ways. |
29 | 49 | uint64_t mutations{}; |
30 | | - uint64_t total_c{}, total_t{}; |
31 | | - uint64_t called_meth{}, called_unmeth{}; |
32 | | - double total_meth{}; |
33 | | - LevelsCounter(const std::string &c) : context{c} {} |
34 | 50 |
|
35 | | - LevelsCounter() = default; |
| 51 | + // total_c is the number of cytosines in mapped reads covering |
| 52 | + // relevant cytosines in the reference genome. |
| 53 | + uint64_t total_c{}; |
36 | 54 |
|
37 | | - LevelsCounter &operator+=(const LevelsCounter &rhs); |
| 55 | + // total_t is the number of thymines in mapped reads covering |
| 56 | + // relevant cytosines in the reference genome. |
| 57 | + uint64_t total_t{}; |
38 | 58 |
|
39 | | - void update(const MSite &s); |
| 59 | + // called_meth is the number of cytosines in the reference genome |
| 60 | + // "called" as being methylated using some statistical criteria. |
| 61 | + uint64_t called_meth{}; |
| 62 | + |
| 63 | + // called_unmeth is the number of cytosines in the reference genome |
| 64 | + // "called" as being unmethylated using some statistical criteria. |
| 65 | + uint64_t called_unmeth{}; |
| 66 | + |
| 67 | + // total_meth is the sum over all relevant cytosines of the |
| 68 | + // methylation level estimated at that cytosine using the mapped |
| 69 | + // reads. This value contributes to the unweighted mean methylation. |
| 70 | + double total_meth{}; |
40 | 71 |
|
| 72 | + // coverage is equal to total_c plus total_t. These are the counts |
| 73 | + // that contribute towards estimates of the various methylation |
| 74 | + // levels. |
41 | 75 | uint64_t coverage() const {return total_c + total_t;} |
| 76 | + |
| 77 | + // total_called is equal to called_meth plus called_unmeth |
42 | 78 | uint64_t total_called() const {return called_meth + called_unmeth;} |
43 | 79 |
|
| 80 | + // mean_meth_weighted is the unweighted mean methylation level. This |
| 81 | + // is the ratio of total_c divided by coverage. This value is always |
| 82 | + // between 0 and 1. |
44 | 83 | double mean_meth_weighted() const { |
45 | 84 | return static_cast<double>(total_c)/std::max(coverage(), 1ul); |
46 | 85 | } |
| 86 | + |
| 87 | + // fractional_meth is the fraction of "called" sites that are called |
| 88 | + // methylated. It is the ratio of called_meth divided by |
| 89 | + // total_called. This value is always between 0 and 1. |
47 | 90 | double fractional_meth() const { |
48 | 91 | return static_cast<double>(called_meth)/std::max(total_called(), 1ul); |
49 | 92 | } |
| 93 | + |
| 94 | + // mean_meth is the unweighted mean methylation level. This is the |
| 95 | + // ratio of total_meth divided by sites_covered. This value is |
| 96 | + // always between 0 and 1. |
50 | 97 | double mean_meth() const { |
51 | 98 | return static_cast<double>(total_meth)/std::max(sites_covered, 1ul); |
52 | 99 | } |
53 | 100 |
|
| 101 | + LevelsCounter(const std::string &c) : context{c} {} |
| 102 | + |
| 103 | + LevelsCounter() = default; |
| 104 | + |
| 105 | + LevelsCounter &operator+=(const LevelsCounter &rhs); |
| 106 | + |
| 107 | + void update(const MSite &s); |
| 108 | + |
54 | 109 | std::string tostring() const; |
55 | 110 | std::string format_row() const; |
56 | 111 | static std::string format_header(); |
|
0 commit comments