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();
181 x.detected =
output.detected.data();
188 x.max_value =
output.max_value.data();
195 x.max_index =
output.max_index.data();
217template<
typename Float_,
class Host_,
typename Sum_,
typename Detected_,
typename Value_,
typename Index_,
typename BlockSource_>
219 constexpr bool unblocked = std::is_same<BlockSource_, bool>::value;
222 return std::vector<Float_>(
n);
229 static_assert(std::is_floating_point<Float_>::value);
232 for (
size_t i = 0;
i <
n; ++
i) {
237 fopt.median_only =
true;
246 for (
size_t i = 0;
i <
n; ++
i) {
257 maxprop[
i] = std::numeric_limits<Float_>::quiet_NaN();
266 host.get_max_value() = [&]() {
275template<
class Host_,
typename Sum_,
typename Detected_,
typename Value_,
typename Index_,
typename BlockSource_,
typename Output_>
277 constexpr bool unblocked = std::is_same<BlockSource_, bool>::value;
280 const auto&
mv =
host.get_max_value();
281 for (
size_t i = 0;
i <
n; ++
i) {
293template<
typename Sum_,
typename Detected_,
typename Value_,
typename Index_>
314template<
typename Float_ =
double>
347 template<
typename Sum_,
typename Detected_,
typename Value_,
typename Index_,
typename Output_>
363 template<
typename Sum_,
typename Detected_,
typename Value_,
typename Index_,
typename Output_>
378 template<
typename Output_ = u
int8_t,
typename Sum_ =
double,
typename Detected_ =
int,
typename Value_ =
double,
typename Index_ =
int>
423template<
typename Float_ =
double,
typename Sum_,
typename Detected_,
typename Value_,
typename Index_>
446template<
typename Float_ =
double,
typename Sum_ =
double,
typename Detected_ =
int,
typename Value_ =
double,
typename Index_ =
int>
459template<
typename Float_ =
double>
479 std::vector<Float_> my_sum;
480 std::vector<Float_> my_max_value;
498 template<
typename Sum_,
typename Detected_,
typename Value_,
typename Index_,
typename Block_,
typename Output_>
517 template<
typename Sum_,
typename Detected_,
typename Value_,
typename Index_,
typename Block_,
typename Output_>
536 template<
typename Output_ = u
int8_t,
typename Sum_ =
double,
typename Detected_ =
int,
typename Value_ =
double,
typename Index_ =
int,
typename Block_ =
int>
567template<
typename Float_ =
double,
typename Sum_,
typename Detected_,
typename Value_,
typename Index_,
typename Block_>
593template<
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:460
std::vector< Output_ > filter(const ComputeCrisprQcMetricsResults< Sum_, Detected_, Value_, Index_ > &metrics, const Block_ *block) const
Definition crispr_quality_control.hpp:537
void filter(size_t num, const ComputeCrisprQcMetricsBuffers< Sum_, Detected_, Value_, Index_ > &metrics, const Block_ *block, Output_ *output) const
Definition crispr_quality_control.hpp:499
std::vector< Float_ > & get_max_value()
Definition crispr_quality_control.hpp:474
void filter(const ComputeCrisprQcMetricsResults< Sum_, Detected_, Value_, Index_ > &metrics, const Block_ *block, Output_ *output) const
Definition crispr_quality_control.hpp:518
const std::vector< Float_ > & get_max_value() const
Definition crispr_quality_control.hpp:466
Filter for high-quality cells using CRISPR-based metrics.
Definition crispr_quality_control.hpp:315
std::vector< Output_ > filter(const ComputeCrisprQcMetricsResults< Sum_, Detected_, Value_, Index_ > &metrics) const
Definition crispr_quality_control.hpp:379
void filter(const ComputeCrisprQcMetricsResults< Sum_, Detected_, Value_, Index_ > &metrics, Output_ *output) const
Definition crispr_quality_control.hpp:364
Float_ get_max_value() const
Definition crispr_quality_control.hpp:320
Float_ & get_max_value()
Definition crispr_quality_control.hpp:327
void filter(size_t num, const ComputeCrisprQcMetricsBuffers< Sum_, Detected_, Value_, Index_ > &metrics, Output_ *output) const
Definition crispr_quality_control.hpp:348
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:568
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:424
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
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:204
double max_value_num_mads
Definition crispr_quality_control.hpp:209
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