1818metagene (tsscpgplot): get data to plot methylation level around a TSS
1919)" ;
2020
21+ [[maybe_unused]] constexpr auto description = R"(
22+ Compute the information needed for metagene plots of DNA methylation
23+ levels. The columns in the output correspond to the fields calculated
24+ globally by the `levels` and per-region by the `roi` command. Input
25+ for features is in BED format, and when present the 6th column is used
26+ to indicate strand. For features of non-zero width (where the 2nd and
27+ 3rd columns are not identical) the negative strand will indicate that
28+ 3rd column should be used. This means, for example, if the features are
29+ genes, and the promoters are of interest, the strand will be used
30+ correctly.
31+ )" ;
32+
2133#include " Interval6.hpp"
2234#include " LevelsCounter.hpp"
2335#include " MSite.hpp"
@@ -39,8 +51,8 @@ metagene (tsscpgplot): get data to plot methylation level around a TSS
3951#include < utility>
4052#include < vector>
4153
42- static MSite
43- tss_from_gene (const Interval6 &r) {
54+ static auto
55+ tss_from_gene (const Interval6 &r) -> MSite {
4456 MSite s;
4557 s.chrom = r.chrom ;
4658 s.pos = r.strand == ' +' ? r.start : r.stop ;
@@ -54,7 +66,9 @@ process_chrom(const std::uint32_t region_size,
5466 const std::pair<std::uint32_t , std::uint32_t > &bounds,
5567 const std::vector<MSite> &sites,
5668 std::vector<LevelsCounter> &levels) {
57- const auto cmp = [](const MSite &a, const MSite &b) { return a.pos < b.pos ; };
69+ constexpr auto cmp = [](const MSite &a, const MSite &b) {
70+ return a.pos < b.pos ;
71+ };
5872 const std::uint32_t twice_rs = 2 * region_size;
5973
6074 for (auto i = bounds.first ; i < bounds.second ; ++i) {
@@ -88,20 +102,8 @@ collapse_bins(const std::uint32_t bin_size, std::vector<T> &v) {
88102 v.swap (vv);
89103}
90104
91- int
92- metagene (int argc, char *argv[]) { // NOLINT(*-avoid-c-arrays)
93- constexpr auto description =
94- R"(
95- Compute the information needed for metagene plots of DNA methylation
96- levels. The columns in the output correspond to the fields calculated
97- globally by the `levels` and per-region by the `roi` command. Input
98- for features is in BED format, and when present the 6th column is used
99- to indicate strand. For features of non-zero width (where the 2nd and
100- 3rd columns are not identical) the negative strand will indicate that
101- 3rd column should be used. This means, for example, if the features are
102- genes, and the promoters are of interest, the strand will be used
103- correctly.
104- )" ;
105+ auto
106+ metagene (int argc, char *argv[]) -> int { // NOLINT(*-avoid-c-arrays)
105107 try {
106108 std::string outfile;
107109 std::uint32_t region_size = 5000 ; // NOLINT(*-avoid-magic-numbers)
@@ -185,10 +187,9 @@ correctly.
185187 const auto bounds = lookup.find (chrom_name);
186188 if (bounds != std::cend (lookup))
187189 process_chrom (region_size, features, bounds->second , sites, levels);
188- const auto n_features = pair_diff (bounds);
189190 if (show_progress)
190191 std::cerr << " [sites=" << std::size (sites)
191- << " features=" << n_features << " ]" << ' \n ' ;
192+ << " features=" << pair_diff (bounds) << " ]" << ' \n ' ;
192193 sites.clear ();
193194 }
194195 if (show_progress)
@@ -202,10 +203,9 @@ correctly.
202203 const auto bounds = lookup.find (chrom_name);
203204 if (bounds != std::cend (lookup))
204205 process_chrom (region_size, features, bounds->second , sites, levels);
205- const auto n_features = pair_diff (bounds);
206206 if (show_progress)
207- std::cerr << " [sites=" << std::size (sites) << " features= " << n_features
208- << " ]\n " ;
207+ std::cerr << " [sites=" << std::size (sites)
208+ << " features= " << pair_diff (bounds) << " ]\n " ;
209209 }
210210
211211 collapse_bins (bin_size, levels);
0 commit comments