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();
192 x.detected =
output.detected.data();
199 x.subset_proportion[
s] =
output.subset_proportion[
s].data();
234template<
typename Float_,
class Host_,
typename Sum_,
typename Detected_,
typename Proportion_,
typename BlockSource_>
236 constexpr bool unblocked = std::is_same<BlockSource_, bool>::value;
239 return std::vector<Float_>(
n);
250 host.get_sum() = [&]() {
264 host.get_detected() = [&]() {
275 opts.num_mads =
options.subset_proportion_num_mads;
281 auto sub =
res.subset_proportion[
s];
282 host.get_subset_proportion()[
s] = [&]() {
293template<
class Host_,
typename Sum_,
typename Detected_,
typename Proportion_,
typename BlockSource_,
typename Output_>
295 constexpr bool unblocked = std::is_same<BlockSource_, bool>::value;
298 const auto& sum =
host.get_sum();
299 for (
size_t i = 0;
i <
n; ++
i) {
310 const auto& detected =
host.get_detected();
311 for (
size_t i = 0;
i <
n; ++
i) {
316 return detected[
block[
i]];
326 for (
size_t i = 0;
i <
n; ++
i) {
339template<
typename Sum_,
typename Detected_,
typename Proportion_>
344 buffer.subset_proportion.reserve(
metrics.subset_proportion.size());
345 for (
const auto&
s :
metrics.subset_proportion) {
346 buffer.subset_proportion.push_back(
s.data());
360template<
typename Float_ =
double>
382 return my_subset_proportion;
404 return my_subset_proportion;
410 std::vector<Float_> my_subset_proportion;
424 template<
typename Sum_,
typename Detected_,
typename Proportion_,
typename Output_>
439 template<
typename Sum_,
typename Detected_,
typename Proportion_,
typename Output_>
453 template<
typename Output_ = u
int8_t,
typename Sum_ =
double,
typename Detected_ =
int,
typename Proportion_ =
double>
478template<
typename Float_ =
double,
typename Sum_ =
double,
typename Detected_ =
int,
typename Proportion_ =
double>
500template<
typename Float_ =
double,
typename Sum_ =
double,
typename Detected_ =
int,
typename Proportion_ =
double>
509template<
typename Float_ =
double>
534 return my_subset_proportion;
559 return my_subset_proportion;
563 std::vector<Float_> my_sum;
564 std::vector<Float_> my_detected;
565 std::vector<std::vector<Float_> > my_subset_proportion;
583 template<
typename Index_,
typename Sum_,
typename Detected_,
typename Proportion_,
typename Block_,
typename Output_>
602 template<
typename Sum_,
typename Detected_,
typename Proportion_,
typename Block_,
typename Output_>
621 template<
typename Output_ = u
int8_t,
typename Sum_ =
double,
typename Detected_ =
int,
typename Proportion_ =
double,
typename Block_ =
int>
643template<
typename Float_ =
double,
typename Sum_,
typename Detected_,
typename Proportion_,
typename Block_>
668template<
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:510
void filter(Index_ num, const ComputeRnaQcMetricsBuffers< Sum_, Detected_, Proportion_ > &metrics, const Block_ *block, Output_ *output) const
Definition rna_quality_control.hpp:584
std::vector< Float_ > & get_detected()
Definition rna_quality_control.hpp:549
void filter(const ComputeRnaQcMetricsResults< Sum_, Detected_, Proportion_ > &metrics, const Block_ *block, Output_ *output) const
Definition rna_quality_control.hpp:603
std::vector< Output_ > filter(const ComputeRnaQcMetricsResults< Sum_, Detected_, Proportion_ > &metrics, const Block_ *block) const
Definition rna_quality_control.hpp:622
std::vector< std::vector< Float_ > > & get_subset_proportion()
Definition rna_quality_control.hpp:558
std::vector< Float_ > & get_sum()
Definition rna_quality_control.hpp:541
const std::vector< Float_ > & get_detected() const
Definition rna_quality_control.hpp:524
const std::vector< Float_ > & get_sum() const
Definition rna_quality_control.hpp:516
const std::vector< std::vector< Float_ > > & get_subset_proportion() const
Definition rna_quality_control.hpp:533
Filter for high-quality cells using RNA-based metrics.
Definition rna_quality_control.hpp:361
Float_ & get_detected()
Definition rna_quality_control.hpp:395
Float_ get_detected() const
Definition rna_quality_control.hpp:373
const std::vector< Float_ > & get_subset_proportion() const
Definition rna_quality_control.hpp:381
std::vector< Float_ > & get_subset_proportion()
Definition rna_quality_control.hpp:403
void filter(const ComputeRnaQcMetricsResults< Sum_, Detected_, Proportion_ > &metrics, Output_ *output) const
Definition rna_quality_control.hpp:440
Float_ get_sum() const
Definition rna_quality_control.hpp:366
void filter(size_t num, const ComputeRnaQcMetricsBuffers< Sum_, Detected_, Proportion_ > &metrics, Output_ *output) const
Definition rna_quality_control.hpp:425
Float_ & get_sum()
Definition rna_quality_control.hpp:388
std::vector< Output_ > filter(const ComputeRnaQcMetricsResults< Sum_, Detected_, Proportion_ > &metrics) const
Definition rna_quality_control.hpp:454
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:644
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:479
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:209
double detected_num_mads
Definition rna_quality_control.hpp:214
double subset_proportion_num_mads
Definition rna_quality_control.hpp:226
double sum_num_mads
Definition rna_quality_control.hpp:220
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