1#ifndef SCRAN_QC_ADT_QUALITY_CONTROL_HPP
2#define SCRAN_QC_ADT_QUALITY_CONTROL_HPP
40template<
typename Sum_ =
double,
typename Detected_ =
int>
93template<
typename Value_,
typename Index_,
typename Subset_,
typename Sum_,
typename Detected_>
96 const std::vector<Subset_>& subsets,
115template<
typename Sum_ =
double,
typename Detected_ =
int>
151template<
typename Sum_ =
double,
typename Detected_ =
int,
typename Value_ =
double,
typename Index_ =
int,
typename Subset_ = const u
int8_t*>
154 const std::vector<Subset_>& subsets,
157 auto NC = mat.
ncol();
162#ifdef SCRAN_QC_TEST_INIT
166 x.
sum = output.
sum.data();
169#ifdef SCRAN_QC_TEST_INIT
175 size_t nsubsets = subsets.size();
178 for (
size_t s = 0; s < nsubsets; ++s) {
180#ifdef SCRAN_QC_TEST_INIT
219template<
typename Float_,
class Host_,
typename Sum_,
typename Detected_,
typename BlockSource_>
221 constexpr bool unblocked = std::is_same<BlockSource_, bool>::value;
222 auto buffer = [&]() {
223 if constexpr(unblocked) {
224 return std::vector<Float_>(n);
235 opts.min_diff = -std::log(1 -
options.detected_min_drop);
236 host.get_detected() = [&]() {
256 host.get_subset_sum()[
s] = [&]() {
267template<
class Host_,
typename Sum_,
typename Detected_,
typename BlockSource_,
typename Output_>
269 constexpr bool unblocked = std::is_same<BlockSource_, bool>::value;
272 const auto& detected =
host.get_detected();
273 for (
size_t i = 0;
i <
n; ++
i) {
278 return detected[
block[
i]];
288 for (
size_t i = 0;
i <
n; ++
i) {
301template<
typename Sum_,
typename Detected_>
307 for (
const auto&
s :
metrics.subset_sum) {
308 buffer.subset_sum.push_back(
s.data());
324template<
typename Float_ =
double>
339 return my_subset_sum;
354 return my_subset_sum;
359 std::vector<Float_> my_subset_sum;
374 template<
typename Sum_,
typename Detected_,
typename Output_>
389 template<
typename Sum_,
typename Detected_,
typename Output_>
404 template<
typename Output_ = u
int8_t,
typename Sum_ =
double,
typename Detected_ =
int>
437template<
typename Float_ =
double,
typename Sum_,
typename Detected_>
454template<
typename Float_ =
double,
typename Sum_,
typename Detected_>
465template<
typename Float_ =
double>
482 return my_subset_sum;
499 return my_subset_sum;
503 std::vector<Float_> my_sum;
504 std::vector<Float_> my_detected;
505 std::vector<std::vector<Float_> > my_subset_sum;
522 template<
typename Index_,
typename Sum_,
typename Detected_,
typename Block_,
typename Output_>
540 template<
typename Sum_,
typename Detected_,
typename Block_,
typename Output_>
558 template<
typename Output_ = u
int8_t,
typename Sum_ =
double,
typename Detected_ =
int,
typename Block_ =
int>
587template<
typename Float_ =
double,
typename Sum_,
typename Detected_,
typename Block_>
611template<
typename Float_ =
double,
typename Sum_,
typename Detected_,
typename Block_>
Define QC filter thresholds using a MAD-based approach.
Filter on ADT-based QC metrics with blocking.
Definition adt_quality_control.hpp:466
std::vector< Output_ > filter(const ComputeAdtQcMetricsResults< Sum_, Detected_ > &metrics, const Block_ *block) const
Definition adt_quality_control.hpp:559
std::vector< std::vector< Float_ > > & get_subset_sum()
Definition adt_quality_control.hpp:498
std::vector< Float_ > & get_detected()
Definition adt_quality_control.hpp:489
void filter(const ComputeAdtQcMetricsResults< Sum_, Detected_ > &metrics, const Block_ *block, Output_ *output) const
Definition adt_quality_control.hpp:541
const std::vector< Float_ > & get_detected() const
Definition adt_quality_control.hpp:472
const std::vector< std::vector< Float_ > > & get_subset_sum() const
Definition adt_quality_control.hpp:481
void filter(Index_ num, const ComputeAdtQcMetricsBuffers< Sum_, Detected_ > &metrics, const Block_ *block, Output_ *output) const
Definition adt_quality_control.hpp:523
Filter for high-quality cells using ADT-based metrics.
Definition adt_quality_control.hpp:325
void filter(const ComputeAdtQcMetricsResults< Sum_, Detected_ > &metrics, Output_ *output) const
Definition adt_quality_control.hpp:390
void filter(size_t num, const ComputeAdtQcMetricsBuffers< Sum_, Detected_ > &metrics, Output_ *output) const
Definition adt_quality_control.hpp:375
Float_ & get_detected()
Definition adt_quality_control.hpp:345
std::vector< Output_ > filter(const ComputeAdtQcMetricsResults< Sum_, Detected_ > &metrics) const
Definition adt_quality_control.hpp:405
Float_ get_detected() const
Definition adt_quality_control.hpp:330
const std::vector< Float_ > & get_subset_sum() const
Definition adt_quality_control.hpp:338
std::vector< Float_ > & get_subset_sum()
Definition adt_quality_control.hpp:353
virtual Index_ ncol() const=0
Simple quality control for single-cell data.
Definition adt_quality_control.hpp:20
AdtQcBlockedFilters< Float_ > compute_adt_qc_filters_blocked(size_t num, const ComputeAdtQcMetricsBuffers< Sum_, Detected_ > &metrics, const Block_ *block, const ComputeAdtQcFiltersOptions &options)
Definition adt_quality_control.hpp:588
AdtQcFilters< Float_ > compute_adt_qc_filters(size_t num, const ComputeAdtQcMetricsBuffers< Sum_, Detected_ > &metrics, const ComputeAdtQcFiltersOptions &options)
Definition adt_quality_control.hpp:438
std::vector< ChooseFilterThresholdsResults< Float_ > > choose_filter_thresholds_blocked(const std::vector< FindMedianMadResults< Float_ > > mms, const ChooseFilterThresholdsOptions &options)
Definition choose_filter_thresholds.hpp:217
void compute_adt_qc_metrics(const tatami::Matrix< Value_, Index_ > &mat, const std::vector< Subset_ > &subsets, const ComputeAdtQcMetricsBuffers< Sum_, Detected_ > &output, const ComputeAdtQcMetricsOptions &options)
Definition adt_quality_control.hpp:94
void per_cell_qc_metrics(const tatami::Matrix< Value_, Index_ > &mat, const std::vector< Subset_ > &subsets, const PerCellQcMetricsBuffers< Sum_, Detected_, Value_, Index_ > &output, const PerCellQcMetricsOptions &options)
Definition per_cell_qc_metrics.hpp:810
ChooseFilterThresholdsResults< Float_ > choose_filter_thresholds(const FindMedianMadResults< Float_ > &mm, const ChooseFilterThresholdsOptions &options)
Definition choose_filter_thresholds.hpp:133
Compute per-cell quality control metrics.
Options for choose_filter_thresholds().
Definition choose_filter_thresholds.hpp:20
Options for compute_adt_qc_filters().
Definition adt_quality_control.hpp:194
double detected_min_drop
Definition adt_quality_control.hpp:205
double detected_num_mads
Definition adt_quality_control.hpp:199
double subset_sum_num_mads
Definition adt_quality_control.hpp:211
Buffers for compute_adt_qc_metrics().
Definition adt_quality_control.hpp:41
Detected_ * detected
Definition adt_quality_control.hpp:52
std::vector< Sum_ * > subset_sum
Definition adt_quality_control.hpp:59
Sum_ * sum
Definition adt_quality_control.hpp:46
Options for compute_adt_qc_metrics().
Definition adt_quality_control.hpp:25
int num_threads
Definition adt_quality_control.hpp:30
Results of compute_adt_qc_metrics().
Definition adt_quality_control.hpp:116
std::vector< Detected_ > detected
Definition adt_quality_control.hpp:125
std::vector< Sum_ > sum
Definition adt_quality_control.hpp:120
std::vector< std::vector< Sum_ > > subset_sum
Definition adt_quality_control.hpp:131
Buffers for per_cell_qc_metrics().
Definition per_cell_qc_metrics.hpp:75
Sum_ * sum
Definition per_cell_qc_metrics.hpp:90
Detected_ * detected
Definition per_cell_qc_metrics.hpp:96
std::vector< Sum_ * > subset_sum
Definition per_cell_qc_metrics.hpp:116
Options for per_cell_qc_metrics().
Definition per_cell_qc_metrics.hpp:22
int num_threads
Definition per_cell_qc_metrics.hpp:63