Module: Submission::ScrnaCoreCdnaPrepFeasibilityCalculator

Included in:
ScrnaCoreCdnaPrepFeasibilityValidator
Defined in:
app/models/submission/scrna_core_cdna_prep_feasibility_calculator.rb

Overview

This module provides methods for calculating the full allowance volume and the final resuspension volume for scRNA core cDNA prep feasibility validations.

Constant Summary collapse

SCRNA_CORE_CDNA_PREP_GEM_X_5P =
'Limber-Htp - scRNA Core cDNA Prep GEM-X 5p'
HEADER_BARCODE =

Constants for the headers in the bulk submission for scRNA core cDNA prep.

'barcode'
HEADER_PLATE_WELL =
'plate well'
HEADER_NUMBER_OF_POOLS =
'scrna core number of pools'
HEADER_CELLS_PER_CHIP_WELL =
'scrna core cells per chip well'
ALLOWANCE_BANDS =
{
  two_pools_two_counts: '2 pool attempts, 2 counts',
  two_pools_one_count: '2 pool attempts, 1 count',
  one_pool_two_counts: '1 pool attempt, 2 counts',
  one_pool_one_count: '1 pool attempt, 1 count'
}.freeze

Instance Method Summary collapse

Instance Method Details

#calculate_allowance_bandsHash

Calculates the allowance band for each study and project combination. This method evaluates the final resuspension volume for each study-project group and assigns an appropriate allowance band based on predefined thresholds. Example output: { { study: “Study A”, project: “Project X” } => “2 pool attempts, 2 counts”, { study: “Study B”, project: “Project Y” } => “1 pool attempt, 2 counts” }

Returns:

  • (Hash)

    A hash where the keys are hashes containing :study and :project, and the values are the corresponding allowance bands as strings.



60
61
62
63
64
65
66
67
68
69
# File 'app/models/submission/scrna_core_cdna_prep_feasibility_calculator.rb', line 60

def calculate_allowance_bands
  # Only calculate if the submission template name is SCRNA_CORE_CDNA_PREP_GEM_X_5P
  # and all required headers are present
  return {} unless submission_template_name == SCRNA_CORE_CDNA_PREP_GEM_X_5P && validate_required_headers
  allowance_map = {}
  group_rows_by_study_and_project.each do |(study_name, project_name), rows|
    allowance_map[{ study: study_name, project: project_name }] = determine_allowance(rows)
  end
  allowance_map
end

#calculate_chip_loading_volume(number_of_cells_per_chip_well) ⇒ Float

This method calculates the chip loading volume (in microlitres) for the specified number of cells per chip well, which is typically specified in in a bulk submission per study and project. It uses the pooling settings from the scRNA config.

Parameters:

  • number_of_cells_per_chip_well (Integer)

    the number of cells per chip well from the bulk submission

Returns:

  • (Float)

    the chip loading volume



78
79
80
81
# File 'app/models/submission/scrna_core_cdna_prep_feasibility_calculator.rb', line 78

def calculate_chip_loading_volume(number_of_cells_per_chip_well)
  # "Chip loading volume" = "Number of cells per chip well" / "Chip loading concentration"
  number_of_cells_per_chip_well / scrna_config[:desired_chip_loading_concentration]
end

#calculate_resuspension_volume(count_of_samples_in_pool) ⇒ Float

This method calculates the resuspension volume (in microlitres) for the specified number of samples in a pool, which is typically taken as the number of samples in the smallest pool for a study and project. It uses the pooling settings from the scRNA config. It first calculates the total cells in 300ul for the given number of samples in the pool, and then the resuspension volume for that total cell count.

Parameters:

  • count_of_samples_in_pool (Integer)

    the number of samples in the pool

Returns:

  • (Float)

    the resuspension volume



92
93
94
95
# File 'app/models/submission/scrna_core_cdna_prep_feasibility_calculator.rb', line 92

def calculate_resuspension_volume(count_of_samples_in_pool)
  total_cells_in_300ul = calculate_total_cells_in_300ul(count_of_samples_in_pool)
  total_cells_in_300ul / scrna_config[:desired_chip_loading_concentration]
end

#calculate_total_cells_in_300ul(count_of_samples_in_pool) ⇒ Integer

This method calculates the total cells in 300ul for the specified number of samples in a pool, which is typically taken as the number of samples in the smallest pool for a study and project. It uses the pooling settings from the scRNA config.

Parameters:

  • count_of_samples_in_pool (Integer)

    the number of samples in the pool

Returns:

  • (Integer)

    the total cells in 300ul



104
105
106
107
# File 'app/models/submission/scrna_core_cdna_prep_feasibility_calculator.rb', line 104

def calculate_total_cells_in_300ul(count_of_samples_in_pool)
  (count_of_samples_in_pool * scrna_config[:required_number_of_cells_per_sample_in_pool]) *
    scrna_config[:wastage_factor]
end

#calculate_volume_needed(number_of_cells_per_chip_well, number_runs, number_cell_counts) ⇒ Float

Calculates the total volume needed (in microliters) for a given number of cells per chip well.

This method is used in bulk submissions per study and project, leveraging pooling settings from the scRNA configuration. It first calculates the chip loading volume for the specified number of cells per chip well and then determines the total volume required, including allowances for cell counting and wastage.

The total volume needed is calculated as: - The volume required for loading chips, based on the number of pool attempts (number_runs). - The volume taken for cell counting, based on the number of cell counts (number_cell_counts). - An additional wastage volume (scrna_config[:wastage_volume]).

Band Allowance Calculations: - If number_runs = 2 and number_cell_counts = 2, it calculates 2 pool attempts, 2 counts (Full allowance). - If number_runs = 2 and number_cell_counts = 1, it calculates 2 pool attempts, 1 count. - If number_runs = 1 and number_cell_counts = 2, it calculates 1 pool attempt, 2 counts. - If number_runs = 1 and number_cell_counts = 1, it calculates 1 pool attempt, 1 count.

Parameters:

  • number_of_cells_per_chip_well (Integer)

    The number of cells per chip well.

  • number_runs (Integer)

    The number of pool attempts (runs) to be performed.

  • number_cell_counts (Integer)

    The number of times cell counting is performed.

Returns:

  • (Float)

    The total volume required for the experiment.



43
44
45
46
47
# File 'app/models/submission/scrna_core_cdna_prep_feasibility_calculator.rb', line 43

def calculate_volume_needed(number_of_cells_per_chip_well, number_runs, number_cell_counts)
  chip_loading_volume = calculate_chip_loading_volume(number_of_cells_per_chip_well)
  (number_runs * chip_loading_volume) + (number_cell_counts * scrna_config[:volume_taken_for_cell_counting]) +
    scrna_config[:wastage_volume]
end