1#ifndef SCRAN_QC_CHOOSE_FILTER_THRESHOLDS_HPP
2#define SCRAN_QC_CHOOSE_FILTER_THRESHOLDS_HPP
63template<
typename Float_>
85template<
typename Float_>
86Float_ unlog_threshold(Float_ val,
bool was_logged) {
88 if (std::isinf(val)) {
99template<
bool lower_,
typename Float_>
100std::vector<Float_> strip_threshold(
const std::vector<ChooseFilterThresholdsResults<Float_> >& res) {
101 std::vector<Float_> output;
102 output.reserve(res.size());
103 for (
const auto& r : res) {
104 if constexpr(lower_) {
105 output.push_back(r.lower);
107 output.push_back(r.upper);
132template<
typename Float_>
134 static_assert(std::is_floating_point<Float_>::value);
136 Float_& lthresh = output.
lower;
137 Float_& uthresh = output.
upper;
138 lthresh = -std::numeric_limits<Float_>::infinity();
139 uthresh = std::numeric_limits<double>::infinity();
143 if (!std::isnan(median) && !std::isnan(mad)) {
144 auto delta = std::max(
static_cast<Float_
>(options.
min_diff), options.
num_mads * mad);
146 lthresh = internal::unlog_threshold(median - delta, options.
log);
149 uthresh = internal::unlog_threshold(median + delta, options.
log);
169template<
typename Index_,
typename Float_>
192template<
typename Index_,
typename Value_,
typename Float_>
216template<
typename Float_>
221 std::vector<ChooseFilterThresholdsResults<Float_> > output;
222 output.reserve(mms.size());
223 for (
auto& mm : mms) {
245template<
typename Index_,
typename Value_,
typename Block_,
typename Float_>
248 const Value_* metrics,
Simple quality control for single-cell data.
Definition adt_quality_control.hpp:20
std::vector< ChooseFilterThresholdsResults< Float_ > > choose_filter_thresholds_blocked(const std::vector< FindMedianMadResults< Float_ > > mms, const ChooseFilterThresholdsOptions &options)
Definition choose_filter_thresholds.hpp:217
FindMedianMadResults< Float_ > find_median_mad(Index_ num, Float_ *metrics, const FindMedianMadOptions &options)
Definition find_median_mad.hpp:79
ChooseFilterThresholdsResults< Float_ > choose_filter_thresholds(const FindMedianMadResults< Float_ > &mm, const ChooseFilterThresholdsOptions &options)
Definition choose_filter_thresholds.hpp:133
std::vector< FindMedianMadResults< Output_ > > find_median_mad_blocked(Index_ num, const Value_ *metrics, const Block_ *block, FindMedianMadWorkspace< Output_, Index_ > *workspace, const FindMedianMadOptions &options)
Definition find_median_mad.hpp:269
Options for choose_filter_thresholds().
Definition choose_filter_thresholds.hpp:20
bool upper
Definition choose_filter_thresholds.hpp:31
bool log
Definition choose_filter_thresholds.hpp:56
double num_mads
Definition choose_filter_thresholds.hpp:38
double min_diff
Definition choose_filter_thresholds.hpp:45
bool lower
Definition choose_filter_thresholds.hpp:25
Results of compute_adt_qc_metrics().
Definition choose_filter_thresholds.hpp:64
Float_ upper
Definition choose_filter_thresholds.hpp:77
Float_ lower
Definition choose_filter_thresholds.hpp:70