
Calculate optimal experimental design parameters under cost constraints
obtain_fixed_variable_constraining_cost.RdThis function determines the optimal experimental design parameters (cells per target and reads per cell) given a total cost constraint. It handles two optimization scenarios:
When
reads_per_cellis NULL: Calculates the maximum reads per cell achievable given a fixedcells_per_targetwithin the cost constraintWhen
cells_per_targetis NULL: Calculates the maximum cells per target achievable given a fixedreads_per_cellwithin the cost constraint
Usage
obtain_fixed_variable_constraining_cost(
cost_per_captured_cell = 0.086,
cost_per_million_reads = 0.374,
cost_constraint,
MOI = 10,
num_targets = 100,
non_targeting_gRNAs = 10,
gRNAs_per_target = 4,
reads_per_cell,
cells_per_target,
mapping_efficiency = 0.72
)Arguments
- cost_per_captured_cell
Numeric. Cost per captured cell in dollars (default: 0.086). Used for library preparation cost calculations.
- cost_per_million_reads
Numeric. Cost per million sequencing reads in dollars (default: 0.374). Used for sequencing cost calculations.
- cost_constraint
Numeric. Total budget constraint in dollars. Must be positive.
- MOI
Numeric. Multiplicity of infection parameter (default: 10). Used to compute the number of captured cells from cells per target.
- num_targets
Integer. Number of target genes in the experiment (default: 100).
- non_targeting_gRNAs
Integer. Number of non-targeting gRNAs (default: 10).
- gRNAs_per_target
Integer. Number of gRNAs per target gene (default: 4).
- reads_per_cell
Numeric or NULL. If provided, this parameter is fixed and
cells_per_targetwill be optimized. If NULL, this parameter will be optimized.- cells_per_target
Numeric or NULL. If provided, this parameter is fixed and
reads_per_cellwill be optimized. If NULL, this parameter will be optimized.- mapping_efficiency
Numeric. Mapping efficiency of sequencing platform (default: 0.72). Used to convert between raw reads and mapped reads.
Value
A list containing:
- cells_per_target
Numeric. Optimized or provided cells per target value
- reads_per_cell
Numeric. Optimized or provided reads per cell value
Details
The function uses a cost model with the following components:
Cost Model:
Total experimental cost calculation:
Total Cost = Library Cost + Sequencing Cost
Component Formulas:
Library Cost = cost_per_captured_cell * num_captured_cellsSequencing Cost = cost_per_million_reads * (total_reads / 1,000,000)num_captured_cells = ((gRNAs_per_target * num_targets + non_targeting_gRNAs) * cells_per_target) / (gRNAs_per_target * MOI)total_reads = (num_captured_cells * reads_per_cell) / mapping_efficiency
Optimization Logic:
Scenario 1 (reads_per_cell = NULL): Given fixed cells_per_target, maximizes
reads_per_cell within cost constraint by allocating remaining budget after cell
preparation costs to sequencing.
Scenario 2 (cells_per_target = NULL): Given fixed reads_per_cell, maximizes
cells_per_target (equivalently, captured cells) within cost constraint using
the total cost per captured cell (including both preparation and sequencing costs).
Error Handling
The function validates that the cost constraint is sufficient for meaningful experiments:
Ensures at least 10 reads per cell can be achieved
Ensures at least 10 captured cells can be achieved
Provides clear error messages when constraints are too tight
See also
cost_power_computation for cost-constrained power analysis that uses this function