1#ifndef SCRAN_QC_CRISPR_QUALITY_CONTROL_HPP
2#define SCRAN_QC_CRISPR_QUALITY_CONTROL_HPP
42template<
typename Sum_ =
double,
typename Detected_ =
int,
typename Value_ =
double,
typename Index_ =
int>
98template<
typename Value_,
typename Index_,
typename Sum_,
typename Detected_>
122template<
typename Sum_ =
double,
typename Detected_ =
int,
typename Value_ =
double,
typename Index_ =
int>
160template<
typename Sum_ =
double,
typename Detected_ =
int,
typename Value_ =
double,
typename Index_ =
int>
165 auto NC =
mat.ncol();
173 x.detected =
output.detected.data();
176 x.max_value =
output.max_value.data();
179 x.max_index =
output.max_index.data();
201template<
typename Float_,
class Host_,
typename Sum_,
typename Detected_,
typename Value_,
typename Index_,
typename BlockSource_>
203 constexpr bool unblocked = std::is_same<BlockSource_, bool>::value;
206 return std::vector<Float_>(
n);
213 static_assert(std::is_floating_point<Float_>::value);
216 for (
size_t i = 0;
i <
n; ++
i) {
221 fopt.median_only =
true;
230 for (
size_t i = 0;
i <
n; ++
i) {
241 maxprop[
i] = std::numeric_limits<Float_>::quiet_NaN();
250 host.get_max_value() = [&]() {
259template<
class Host_,
typename Sum_,
typename Detected_,
typename Value_,
typename Index_,
typename BlockSource_,
typename Output_>
261 constexpr bool unblocked = std::is_same<BlockSource_, bool>::value;
264 const auto&
mv =
host.get_max_value();
265 for (
size_t i = 0;
i <
n; ++
i) {
277template<
typename Sum_,
typename Detected_,
typename Value_,
typename Index_>
298template<
typename Float_ =
double>
331 template<
typename Sum_,
typename Detected_,
typename Value_,
typename Index_,
typename Output_>
347 template<
typename Sum_,
typename Detected_,
typename Value_,
typename Index_,
typename Output_>
362 template<
typename Output_ = u
int8_t,
typename Sum_ =
double,
typename Detected_ =
int,
typename Value_ =
double,
typename Index_ =
int>
403template<
typename Float_ =
double,
typename Sum_,
typename Detected_,
typename Value_,
typename Index_>
426template<
typename Float_ =
double,
typename Sum_ =
double,
typename Detected_ =
int,
typename Value_ =
double,
typename Index_ =
int>
439template<
typename Float_ =
double>
459 std::vector<Float_> my_sum;
460 std::vector<Float_> my_max_value;
478 template<
typename Sum_,
typename Detected_,
typename Value_,
typename Index_,
typename Block_,
typename Output_>
497 template<
typename Sum_,
typename Detected_,
typename Value_,
typename Index_,
typename Block_,
typename Output_>
516 template<
typename Output_ = u
int8_t,
typename Sum_ =
double,
typename Detected_ =
int,
typename Value_ =
double,
typename Index_ =
int,
typename Block_ =
int>
543template<
typename Float_ =
double,
typename Sum_,
typename Detected_,
typename Value_,
typename Index_,
typename Block_>
569template<
typename Float_ =
double,
typename Sum_,
typename Detected_,
typename Value_,
typename Index_,
typename Block_>
Define QC filter thresholds using a MAD-based approach.
Filter on using CRISPR-based QC metrics with blocking.
Definition crispr_quality_control.hpp:440
std::vector< Output_ > filter(const ComputeCrisprQcMetricsResults< Sum_, Detected_, Value_, Index_ > &metrics, const Block_ *block) const
Definition crispr_quality_control.hpp:517
void filter(size_t num, const ComputeCrisprQcMetricsBuffers< Sum_, Detected_, Value_, Index_ > &metrics, const Block_ *block, Output_ *output) const
Definition crispr_quality_control.hpp:479
std::vector< Float_ > & get_max_value()
Definition crispr_quality_control.hpp:454
void filter(const ComputeCrisprQcMetricsResults< Sum_, Detected_, Value_, Index_ > &metrics, const Block_ *block, Output_ *output) const
Definition crispr_quality_control.hpp:498
const std::vector< Float_ > & get_max_value() const
Definition crispr_quality_control.hpp:446
Filter for high-quality cells using CRISPR-based metrics.
Definition crispr_quality_control.hpp:299
std::vector< Output_ > filter(const ComputeCrisprQcMetricsResults< Sum_, Detected_, Value_, Index_ > &metrics) const
Definition crispr_quality_control.hpp:363
void filter(const ComputeCrisprQcMetricsResults< Sum_, Detected_, Value_, Index_ > &metrics, Output_ *output) const
Definition crispr_quality_control.hpp:348
Float_ get_max_value() const
Definition crispr_quality_control.hpp:304
Float_ & get_max_value()
Definition crispr_quality_control.hpp:311
void filter(size_t num, const ComputeCrisprQcMetricsBuffers< Sum_, Detected_, Value_, Index_ > &metrics, Output_ *output) const
Definition crispr_quality_control.hpp:332
Simple quality control for single-cell data.
Definition adt_quality_control.hpp:20
CrisprQcBlockedFilters< Float_ > compute_crispr_qc_filters_blocked(size_t num, const ComputeCrisprQcMetricsBuffers< Sum_, Detected_, Value_, Index_ > &metrics, const Block_ *block, const ComputeCrisprQcFiltersOptions &options)
Definition crispr_quality_control.hpp:544
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_crispr_qc_metrics(const tatami::Matrix< Value_, Index_ > &mat, const ComputeCrisprQcMetricsBuffers< Sum_, Detected_, Value_, Index_ > &output, const ComputeCrisprQcMetricsOptions &options)
Definition crispr_quality_control.hpp:99
FindMedianMadResults< Float_ > find_median_mad(Index_ num, Float_ *metrics, const FindMedianMadOptions &options)
Definition find_median_mad.hpp:79
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
CrisprQcFilters< Float_ > compute_crispr_qc_filters(size_t num, const ComputeCrisprQcMetricsBuffers< Sum_, Detected_, Value_, Index_ > &metrics, const ComputeCrisprQcFiltersOptions &options)
Definition crispr_quality_control.hpp:404
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:261
Compute per-cell quality control metrics.
Options for choose_filter_thresholds().
Definition choose_filter_thresholds.hpp:20
Options for compute_crispr_qc_filters().
Definition crispr_quality_control.hpp:188
double max_value_num_mads
Definition crispr_quality_control.hpp:193
Buffers for compute_crispr_qc_metrics().
Definition crispr_quality_control.hpp:43
Sum_ * sum
Definition crispr_quality_control.hpp:48
Detected_ * detected
Definition crispr_quality_control.hpp:54
Index_ * max_index
Definition crispr_quality_control.hpp:66
Value_ * max_value
Definition crispr_quality_control.hpp:60
Options for compute_crispr_qc_metrics().
Definition crispr_quality_control.hpp:25
int num_threads
Definition crispr_quality_control.hpp:30
Results of compute_crispr_qc_metrics().
Definition crispr_quality_control.hpp:123
std::vector< Index_ > max_index
Definition crispr_quality_control.hpp:142
std::vector< Value_ > max_value
Definition crispr_quality_control.hpp:137
std::vector< Detected_ > detected
Definition crispr_quality_control.hpp:132
std::vector< Sum_ > sum
Definition crispr_quality_control.hpp:127
Options for per_cell_qc_metrics().
Definition per_cell_qc_metrics.hpp:22