|
1 | | -# frozen_string_literal: true |
2 | | - |
3 | 1 | # service that handles preprocessing expression/annotation data to speed up dot plot rendering |
4 | 2 | class DotPlotService |
5 | 3 | # main handler for launching ingest job to process expression data into DotPlotGene objects |
6 | | - # since the study can have only one processed matrix, this will only run if the study is eligible |
7 | | - # and we do not need to specify which matrix/metadata file to process |
| 4 | + # since the study can have only one processed matrix/metadata file, this will only run if the study is eligible |
8 | 5 | # |
9 | 6 | # * *params* |
10 | 7 | # - +study+ (Study) => the study that owns the data |
@@ -40,35 +37,37 @@ def self.run_process_dot_plot_genes(study, cluster_group, user) |
40 | 37 | # * *returns* |
41 | 38 | # - (DotPlotGeneIngestParameters) => a parameters object with the necessary file paths and metadata |
42 | 39 | def self.create_params_object(cluster_group, expression_file, metadata_file) |
43 | | - params = DotPlotGeneIngestParameters.new( |
| 40 | + params = { |
44 | 41 | cluster_group_id: cluster_group.id, |
45 | | - cluster_file: RequestUtils.cluster_file_url(cluster_group), |
46 | | - matrix_file_type: expression_file.file_type == 'Expression Matrix' ? 'dense' : 'mtx' |
47 | | - ) |
| 42 | + cluster_file: RequestUtils.cluster_file_url(cluster_group) |
| 43 | + } |
48 | 44 | case expression_file.file_type |
49 | 45 | when 'Expression Matrix' |
50 | | - params.matrix_file_path = expression_file.gs_url |
51 | | - params.cell_metadata_file = metadata_file.gs_url |
| 46 | + params[:matrix_file_type] = 'dense' |
| 47 | + params[:matrix_file_path] = expression_file.gs_url |
| 48 | + params[:cell_metadata_file] = metadata_file.gs_url |
52 | 49 | when 'MM Coordinate Matrix' |
| 50 | + params[:matrix_file_type] = 'mtx' |
53 | 51 | genes_file = expression_file.bundled_files.detect { |f| f.file_type == '10X Genes File' } |
54 | 52 | barcodes_file = expression_file.bundled_files.detect { |f| f.file_type == '10X Barcodes File' } |
55 | | - params.matrix_file_path = expression_file.gs_url |
56 | | - params.cell_metadata_file = metadata_file.gs_url |
57 | | - params.gene_file = genes_file.gs_url |
58 | | - params.barcode_file = barcodes_file.gs_url |
| 53 | + params[:matrix_file_path] = expression_file.gs_url |
| 54 | + params[:cell_metadata_file] = metadata_file.gs_url |
| 55 | + params[:gene_file] = genes_file.gs_url |
| 56 | + params[:barcode_file] = barcodes_file.gs_url |
59 | 57 | when 'AnnData' |
60 | | - params.cell_metadata_file = RequestUtils.data_fragment_url(metadata_file, 'metadata') |
61 | | - params.matrix_file_path = RequestUtils.data_fragment_url( |
| 58 | + params[:matrix_file_type] = 'mtx' # extracted expression for AnnData is in MTX format |
| 59 | + params[:cell_metadata_file] = RequestUtils.data_fragment_url(metadata_file, 'metadata') |
| 60 | + params[:matrix_file_path] = RequestUtils.data_fragment_url( |
62 | 61 | expression_file, 'matrix', file_type_detail: 'processed' |
63 | 62 | ) |
64 | | - params.gene_file = RequestUtils.data_fragment_url( |
| 63 | + params[:gene_file] = RequestUtils.data_fragment_url( |
65 | 64 | expression_file, 'features', file_type_detail: 'processed' |
66 | 65 | ) |
67 | | - params.barcode_file = RequestUtils.data_fragment_url( |
| 66 | + params[:barcode_file] = RequestUtils.data_fragment_url( |
68 | 67 | expression_file, 'barcodes', file_type_detail: 'processed' |
69 | 68 | ) |
70 | 69 | end |
71 | | - params |
| 70 | + DotPlotGeneIngestParameters.new(**params) |
72 | 71 | end |
73 | 72 |
|
74 | 73 | # determine study eligibility - can only have one processed matrix and be able to visualize clusters |
|
0 commit comments