Skip to content

Commit

Permalink
Adjust inputs and outputs for building the proper workflow graph and …
Browse files Browse the repository at this point in the history
…add assertions for method specific required inputs
  • Loading branch information
LouisK92 committed Sep 18, 2024
1 parent e12acb8 commit 2b2f15a
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 89 deletions.
13 changes: 12 additions & 1 deletion src/api/comp_assignment_method.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ info:
description: An assignment method assigns transcripts to cells based on the spatial data and the cell segmentation.
arguments:
- name: "--input"
required: true
direction: input
__merge__: file_spatialdata.yaml
- name: "--segmentation_input"
required: false
direction: input
__merge__: file_spatialdata_segmented.yaml
- name: "--input_sc"
required: false
direction: input
required: true
__merge__: file_singlecell.yaml
- name: "--output"
__merge__: file_spatialdata_assigned.yaml
direction: output
Expand All @@ -18,3 +26,6 @@ arguments:
# dest: resources_test/common/pancreas
# - type: python_script
# path: /common/component_tests/run_and_check_output.py



12 changes: 10 additions & 2 deletions src/api/comp_celltype_annotation_method.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ arguments:
- name: --input
required: true
direction: input
__merge__: /src/api/file_spatial_norm_counts.yaml
__merge__: file_spatial_norm_counts.yaml
- name: --input_transcripts
__merge__: file_spatialdata_assigned.yaml
direction: input
required: false
- name: --input_sc
required: false
direction: input
__merge__: file_singlecell.yaml
- name: --celltype_key
required: false
direction: input
Expand All @@ -17,7 +25,7 @@ arguments:
- name: --output
required: true
direction: output
__merge__: /src/api/file_spatial_with_celltypes.yaml
__merge__: file_spatial_with_celltypes.yaml
# test_resources:
# - path: /resources_test/common/pancreas
# dest: resources_test/common/pancreas
Expand Down
4 changes: 4 additions & 0 deletions src/api/comp_expr_correction_method.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ arguments:
required: true
direction: input
__merge__: /src/api/file_spatial_with_celltypes.yaml
- name: --input_sc
required: false
direction: input
__merge__: /src/api/file_singlecell.yaml
- name: --output
required: true
direction: output
Expand Down
9 changes: 7 additions & 2 deletions src/api/comp_normalisation_method.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ arguments:
- name: --input
required: true
direction: input
__merge__: /src/api/file_spatial_raw_counts.yaml
__merge__: file_spatial_raw_counts.yaml
- name: --input_volume
type: file
description: H5ad with an obs column of cell volumes calculated from spatial transcriptomics data.
required: false
__merge__: file_cell_volumes.yaml
- name: --output
required: true
direction: output
__merge__: /src/api/file_spatial_norm_counts.yaml
__merge__: file_spatial_norm_counts.yaml

# test_resources:
# - path: /resources_test/common/pancreas
Expand Down
14 changes: 2 additions & 12 deletions src/assignment_methods/basic/config.vsh.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
name: basic
namespace: assignment_methods

__merge__: /src/api/comp_assignment_method.yaml

arguments:
- name: --input
required: true
direction: input
__merge__: /src/api/file_spatialdata.yaml
- name: --transcripts_key
type: string
description: The key of the transcripts within the points of the spatial data
required: true
- name: --segmentation_input
required: true
direction: input
__merge__: /src/api/file_spatialdata_segmented.yaml
- name: --coordinate_system
type: string
description: The key of the pixel space coordinate system within the spatial data
required: true
- name: --output
required: true
direction: output
__merge__: /src/api/file_spatialdata_assigned.yaml

resources:
- type: python_script
Expand Down
4 changes: 4 additions & 0 deletions src/assignment_methods/basic/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
# if par['coordinate_system'] == None:
# par['coordinate_system'] = 'global'

# Optional parameter check: For this specific assignment method the par['segmentation_input'] is required
assert par['segmentation_input'] is not None, 'Segmentation input is required for this assignment method.'


# Read input
print('Reading input files', flush=True)
sdata = sd.read_zarr(par['input'])
Expand Down
10 changes: 2 additions & 8 deletions src/cell_volume_methods/alpha_shapes/config.vsh.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
name: alpha_shapes
namespace: cell_volume_methods

__merge__: /src/api/comp_cell_volume_method.yaml

arguments:
- name: --input
required: true
direction: input
__merge__: /src/api/file_spatialdata_assigned.yaml
- name: --alpha
type: double
description: Alpha parameter for calculating the alpha shape (0.0 refers to the convex hull)
required: false
default: 0.0
- name: --output
required: true
direction: output
__merge__: /src/api/file_cell_volumes.yaml

resources:
- type: python_script
Expand Down
23 changes: 2 additions & 21 deletions src/celltype_annotation_methods/ssam/config.vsh.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,14 @@
name: ssam
namespace: celltype_annotation_methods

__merge__: /src/api/comp_celltype_annotation_method.yaml

arguments:
- name: --input
required: true
direction: input
__merge__: /src/api/file_spatial_norm_counts.yaml
- name: --input_transcripts
required: true
direction: input
__merge__: /src/api/file_spatialdata_assigned.yaml
- name: --input_sc
required: true
direction: input
__merge__: /src/api/file_singlecell.yaml
- name: --um_per_pixel # TODO: Should be able to infer this from transcripts
required: false
direction: input
type: double
default: 0.5
- name: --celltype_key
required: false
direction: input
type: string
default: cell_type
- name: --output
required: true
direction: output
__merge__: /src/api/file_spatial_with_celltypes.yaml

resources:
- type: python_script
Expand Down
3 changes: 3 additions & 0 deletions src/celltype_annotation_methods/ssam/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
}
## VIASH END

# Optional parameter check: For this specific annotation method the par['input_transcripts'] and par['input_sc'] are required
assert par['input_transcripts'] is not None, 'Transcripts input is required for this annotation method.'
assert par['input_sc'] is not None, 'Single cell input is required for this annotation method.'

# Read input
print('Reading input files', flush=True)
Expand Down
10 changes: 1 addition & 9 deletions src/count_aggregation/basic/config.vsh.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
name: basic
namespace: count_aggregation

arguments:
- name: --input
required: true
direction: input
__merge__: /src/api/file_spatialdata_assigned.yaml
- name: --output
required: true
direction: output
__merge__: /src/api/file_spatial_raw_counts.yaml
__merge__: /src/api/comp_count_aggregation.yaml

resources:
- type: python_script
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
name: gene_efficiency_correction
namespace: expr_correction_methods

__merge__: /src/api/comp_expr_correction_method.yaml

arguments:
- name: --input
required: true
direction: input
__merge__: /src/api/file_spatial_with_celltypes.yaml
- name: --input_sc
required: true
direction: input
__merge__: /src/api/file_singlecell.yaml
- name: --celltype_key
required: false
direction: input
type: string
default: cell_type
- name: --output
required: true
direction: output
__merge__: /src/api/file_spatial_corrected.yaml

resources:
- type: python_script
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
}
## VIASH END

# Optional parameter check: For this specific correction method the par['input_sc'] is required
assert par['input_sc'] is not None, 'Single cell input is required for this expr correction method.'

# Read input
print('Reading input files', flush=True)
Expand Down
15 changes: 1 addition & 14 deletions src/normalisation_methods/normalise_by_volume/config.vsh.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
name: normalise_by_volume
namespace: normalisation_methods

arguments:
- name: --input
required: true
direction: input
__merge__: /src/api/file_spatial_raw_counts.yaml
- name: --input_volume
type: file
description: H5ad with an obs column of cell volumes calculated from spatial transcriptomics data.
required: true
__merge__: /src/api/file_cell_volumes.yaml
- name: --output
required: true
direction: output
__merge__: /src/api/file_spatial_norm_counts.yaml
__merge__: /src/api/comp_normalisation_method.yaml

resources:
- type: python_script
Expand Down
2 changes: 2 additions & 0 deletions src/normalisation_methods/normalise_by_volume/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
}
## VIASH END

# Optional parameter check: For this specific normalisation method the par['input_volume'] is required
assert par['input_volume'] is not None, 'Volume input is required for this normalisation method.'

# Read input
print('Reading input files', flush=True)
Expand Down
10 changes: 2 additions & 8 deletions src/segmentation_methods/custom/config.vsh.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
name: custom
namespace: segmentation_methods

__merge__: /src/api/comp_segmentation_method.yaml

arguments:
- name: --input
required: true
direction: input
__merge__: /src/api/file_spatialdata.yaml
- name: --labels_key
type: string
description: The key of the segmentation within the labels of the spatial data
required: true
- name: --output
required: true
direction: output
__merge__: /src/api/file_spatialdata_segmented.yaml

resources:
- type: python_script
Expand Down

0 comments on commit 2b2f15a

Please sign in to comment.