1#ifndef SCRAN_QC_RNA_QUALITY_CONTROL_HPP
2#define SCRAN_QC_RNA_QUALITY_CONTROL_HPP
41template<
typename Sum_ =
double,
typename Detected_ =
int,
typename Proportion_ =
double>
91template<
typename Value_,
typename Index_,
typename Subset_,
typename Sum_,
typename Detected_,
typename Proportion_>
94 const std::vector<Subset_>&
subsets,
105 constexpr bool same_type = std::is_same<Sum_, Proportion_>::value;
106 typename std::conditional<same_type, bool, std::vector<std::vector<Sum_> > >::type
placeholder_subset;
108 if (
output.subset_proportion.size()) {
111 tmp.subset_sum =
output.subset_proportion;
118 tmp.subset_sum[
s] =
b.data();
144template<
typename Sum_ =
double,
typename Detected_ =
int,
typename Proportion_ =
double>
182template<
typename Sum_ =
double,
typename Detected_ =
int,
typename Proportion_ =
double,
typename Value_ =
double,
typename Index_ =
int,
typename Subset_ = const u
int8_t*>
184 auto NC =
mat.ncol();
200 x.detected =
output.detected.data();
211 x.subset_proportion[
s] =
output.subset_proportion[
s].data();
246template<
typename Float_,
class Host_,
typename Sum_,
typename Detected_,
typename Proportion_,
typename BlockSource_>
248 constexpr bool unblocked = std::is_same<BlockSource_, bool>::value;
251 return std::vector<Float_>(
n);
262 host.get_sum() = [&]() {
276 host.get_detected() = [&]() {
287 opts.num_mads =
options.subset_proportion_num_mads;
293 auto sub =
res.subset_proportion[
s];
294 host.get_subset_proportion()[
s] = [&]() {
305template<
class Host_,
typename Sum_,
typename Detected_,
typename Proportion_,
typename BlockSource_,
typename Output_>
307 constexpr bool unblocked = std::is_same<BlockSource_, bool>::value;
310 const auto& sum =
host.get_sum();
311 for (
size_t i = 0;
i <
n; ++
i) {
322 const auto& detected =
host.get_detected();
323 for (
size_t i = 0;
i <
n; ++
i) {
328 return detected[
block[
i]];
338 for (
size_t i = 0;
i <
n; ++
i) {
351template<
typename Sum_,
typename Detected_,
typename Proportion_>
356 buffer.subset_proportion.reserve(
metrics.subset_proportion.size());
357 for (
const auto&
s :
metrics.subset_proportion) {
358 buffer.subset_proportion.push_back(
s.data());
372template<
typename Float_ =
double>
394 return my_subset_proportion;
416 return my_subset_proportion;
422 std::vector<Float_> my_subset_proportion;
436 template<
typename Sum_,
typename Detected_,
typename Proportion_,
typename Output_>
451 template<
typename Sum_,
typename Detected_,
typename Proportion_,
typename Output_>
465 template<
typename Output_ = u
int8_t,
typename Sum_ =
double,
typename Detected_ =
int,
typename Proportion_ =
double>
494template<
typename Float_ =
double,
typename Sum_ =
double,
typename Detected_ =
int,
typename Proportion_ =
double>
516template<
typename Float_ =
double,
typename Sum_ =
double,
typename Detected_ =
int,
typename Proportion_ =
double>
525template<
typename Float_ =
double>
550 return my_subset_proportion;
575 return my_subset_proportion;
579 std::vector<Float_> my_sum;
580 std::vector<Float_> my_detected;
581 std::vector<std::vector<Float_> > my_subset_proportion;
599 template<
typename Index_,
typename Sum_,
typename Detected_,
typename Proportion_,
typename Block_,
typename Output_>
618 template<
typename Sum_,
typename Detected_,
typename Proportion_,
typename Block_,
typename Output_>
637 template<
typename Output_ = u
int8_t,
typename Sum_ =
double,
typename Detected_ =
int,
typename Proportion_ =
double,
typename Block_ =
int>
663template<
typename Float_ =
double,
typename Sum_,
typename Detected_,
typename Proportion_,
typename Block_>
688template<
typename Float_ =
double,
typename Sum_,
typename Detected_,
typename Proportion_,
typename Block_>
Define QC filter thresholds using a MAD-based approach.
Filter for high-quality cells using RNA-based metrics with blocking.
Definition rna_quality_control.hpp:526
void filter(Index_ num, const ComputeRnaQcMetricsBuffers< Sum_, Detected_, Proportion_ > &metrics, const Block_ *block, Output_ *output) const
Definition rna_quality_control.hpp:600
std::vector< Float_ > & get_detected()
Definition rna_quality_control.hpp:565
void filter(const ComputeRnaQcMetricsResults< Sum_, Detected_, Proportion_ > &metrics, const Block_ *block, Output_ *output) const
Definition rna_quality_control.hpp:619
std::vector< Output_ > filter(const ComputeRnaQcMetricsResults< Sum_, Detected_, Proportion_ > &metrics, const Block_ *block) const
Definition rna_quality_control.hpp:638
std::vector< std::vector< Float_ > > & get_subset_proportion()
Definition rna_quality_control.hpp:574
std::vector< Float_ > & get_sum()
Definition rna_quality_control.hpp:557
const std::vector< Float_ > & get_detected() const
Definition rna_quality_control.hpp:540
const std::vector< Float_ > & get_sum() const
Definition rna_quality_control.hpp:532
const std::vector< std::vector< Float_ > > & get_subset_proportion() const
Definition rna_quality_control.hpp:549
Filter for high-quality cells using RNA-based metrics.
Definition rna_quality_control.hpp:373
Float_ & get_detected()
Definition rna_quality_control.hpp:407
Float_ get_detected() const
Definition rna_quality_control.hpp:385
const std::vector< Float_ > & get_subset_proportion() const
Definition rna_quality_control.hpp:393
std::vector< Float_ > & get_subset_proportion()
Definition rna_quality_control.hpp:415
void filter(const ComputeRnaQcMetricsResults< Sum_, Detected_, Proportion_ > &metrics, Output_ *output) const
Definition rna_quality_control.hpp:452
Float_ get_sum() const
Definition rna_quality_control.hpp:378
void filter(size_t num, const ComputeRnaQcMetricsBuffers< Sum_, Detected_, Proportion_ > &metrics, Output_ *output) const
Definition rna_quality_control.hpp:437
Float_ & get_sum()
Definition rna_quality_control.hpp:400
std::vector< Output_ > filter(const ComputeRnaQcMetricsResults< Sum_, Detected_, Proportion_ > &metrics) const
Definition rna_quality_control.hpp:466
Simple quality control for single-cell data.
Definition adt_quality_control.hpp:20
void compute_rna_qc_metrics(const tatami::Matrix< Value_, Index_ > &mat, const std::vector< Subset_ > &subsets, const ComputeRnaQcMetricsBuffers< Sum_, Detected_, Proportion_ > &output, const ComputeRnaQcMetricsOptions &options)
Definition rna_quality_control.hpp:92
std::vector< ChooseFilterThresholdsResults< Float_ > > choose_filter_thresholds_blocked(const std::vector< FindMedianMadResults< Float_ > > mms, const ChooseFilterThresholdsOptions &options)
Definition choose_filter_thresholds.hpp:217
RnaQcBlockedFilters< Float_ > compute_rna_qc_filters_blocked(size_t num, const ComputeRnaQcMetricsBuffers< Sum_, Detected_, Proportion_ > &metrics, const Block_ *block, const ComputeRnaQcFiltersOptions &options)
Definition rna_quality_control.hpp:664
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
RnaQcFilters< Float_ > compute_rna_qc_filters(size_t num, const ComputeRnaQcMetricsBuffers< Sum_, Detected_, Proportion_ > &metrics, const ComputeRnaQcFiltersOptions &options)
Definition rna_quality_control.hpp:495
Compute per-cell quality control metrics.
Options for choose_filter_thresholds().
Definition choose_filter_thresholds.hpp:20
Options for compute_rna_qc_filters().
Definition rna_quality_control.hpp:221
double detected_num_mads
Definition rna_quality_control.hpp:226
double subset_proportion_num_mads
Definition rna_quality_control.hpp:238
double sum_num_mads
Definition rna_quality_control.hpp:232
Buffers for compute_rna_qc_metrics().
Definition rna_quality_control.hpp:42
Detected_ * detected
Definition rna_quality_control.hpp:53
Sum_ * sum
Definition rna_quality_control.hpp:47
std::vector< Proportion_ * > subset_proportion
Definition rna_quality_control.hpp:60
Options for compute_rna_qc_metrics().
Definition rna_quality_control.hpp:25
int num_threads
Definition rna_quality_control.hpp:30
Results of compute_rna_qc_metrics().
Definition rna_quality_control.hpp:145
std::vector< Sum_ > sum
Definition rna_quality_control.hpp:149
std::vector< Detected_ > detected
Definition rna_quality_control.hpp:154
std::vector< std::vector< Proportion_ > > subset_proportion
Definition rna_quality_control.hpp:160
Options for per_cell_qc_metrics().
Definition per_cell_qc_metrics.hpp:22