scran_qc
Simple quality control on single-cell data
Loading...
Searching...
No Matches
format_filters.hpp
Go to the documentation of this file.
1#ifndef SCRAN_QC_FORMAT_FILTERS_HPP
2#define SCRAN_QC_FORMAT_FILTERS_HPP
3
4#include <vector>
5#include <algorithm>
6#include <cstdint>
7
13namespace scran_qc {
14
28template<typename Index_, typename Keep_>
29void filter_index(Index_ num, const Keep_* filter, std::vector<Index_>& output) {
30 output.clear();
31 for (Index_ i = 0; i < num; ++i) {
32 if (filter[i]) {
33 output.push_back(i);
34 }
35 }
36}
37
49template<typename Index_, typename Keep_>
50std::vector<Index_> filter_index(Index_ num, const Keep_* filter) {
51 std::vector<Index_> output;
52 filter_index(num, filter, output);
53 return output;
54}
55
70template<typename Keep_, typename Output_>
71void combine_filters(size_t num, const std::vector<Keep_*>& filters, Output_* output) {
72 std::copy_n(filters.front(), num, output);
73 for (size_t f = 1, nfilters = filters.size(); f < nfilters; ++f) {
74 auto filt = filters[f];
75 for (size_t i = 0; i < num; ++i) {
76 output[i] = output[i] && filt[i];
77 }
78 }
79}
80
93template<typename Output_ = uint8_t, typename Keep_ = uint8_t>
94std::vector<Output_> combine_filters(size_t num, const std::vector<const Keep_*>& filters) {
95 std::vector<Output_> output(num);
97 return output;
98}
99
111template<typename Index_, typename Keep_>
112void combine_filters_index(Index_ num, const std::vector<const Keep_*>& filters, std::vector<Index_>& output) {
113 output.clear();
114
115 size_t nfilters = filters.size();
116 for (Index_ i = 0; i < num; ++i) {
117 bool keep = true;
118 for (size_t f = 0; f < nfilters; ++f) {
119 if (!filters[f][i]) {
120 keep = false;
121 break;
122 }
123 }
124 if (keep) {
125 output.push_back(i);
126 }
127 }
128}
129
142template<typename Index_, typename Keep_>
143std::vector<Index_> combine_filters_index(Index_ num, const std::vector<const Keep_*>& filters) {
144 std::vector<Index_> output;
146 return output;
147}
148
149}
150
151#endif
Temporary data structures for find_median_mad_blocked().
Definition find_median_mad.hpp:172
Simple quality control for single-cell data.
Definition adt_quality_control.hpp:20
void combine_filters(size_t num, const std::vector< Keep_ * > &filters, Output_ *output)
Definition format_filters.hpp:71
void filter_index(Index_ num, const Keep_ *filter, std::vector< Index_ > &output)
Definition format_filters.hpp:29
void combine_filters_index(Index_ num, const std::vector< const Keep_ * > &filters, std::vector< Index_ > &output)
Definition format_filters.hpp:112