Skip to contents

This 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_cell is NULL: Calculates the maximum reads per cell achievable given a fixed cells_per_target within the cost constraint

  • When cells_per_target is NULL: Calculates the maximum cells per target achievable given a fixed reads_per_cell within 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_target will be optimized. If NULL, this parameter will be optimized.

cells_per_target

Numeric or NULL. If provided, this parameter is fixed and reads_per_cell will 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_cells

  • Sequencing 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