Mercurial > repos > goeckslab > cell_intensity_processing
changeset 5:afa3cb2110eb draft
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit bc438db690e41823909b32b693f297d942433a43
author | goeckslab |
---|---|
date | Thu, 11 Jul 2024 22:41:26 +0000 |
parents | 5d541df02496 |
children | 676f78636667 |
files | macros.xml process_intensities.xml scale_cell_coordinates.py test-data/pixels.h5ad test-data/rename_channels.csv test-data/rename_test.ome.tiff test-data/rename_test.tiff test-data/test.xml |
diffstat | 8 files changed, 59 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/macros.xml Fri May 10 21:01:41 2024 +0000 +++ b/macros.xml Thu Jul 11 22:41:26 2024 +0000 @@ -2,12 +2,12 @@ <macros> <xml name="requirements"> <requirements> - <container type="docker">quay.io/goeckslab/mti_utils:0.0.1</container> + <container type="docker">quay.io/goeckslab/mti_utils:@TOOL_VERSION@</container> </requirements> </xml> <xml name="version_cmd"> - <version_command>echo @VERSION@</version_command> + <version_command>echo @TOOL_VERSION@</version_command> </xml> <xml name="citations"> <citations> @@ -15,7 +15,7 @@ </citations> </xml> - <token name="@TOOL_VERSION@">0.0.1</token> - <token name="@VERSION_SUFFIX@">5</token> + <token name="@TOOL_VERSION@">0.0.2</token> + <token name="@VERSION_SUFFIX@">0</token> <token name="@PROFILE@">19.01</token> </macros>
--- a/process_intensities.xml Fri May 10 21:01:41 2024 +0000 +++ b/process_intensities.xml Thu Jul 11 22:41:26 2024 +0000 @@ -27,7 +27,7 @@ markers_to_normalize = marker_df['marker_name'].to_list() #if $AF_method.select_method == 'SBR': -AF_markers = [x for x in list(marker_df['${AF_method.AF_col}'].unique()) if x != 'None'] +AF_markers = [x for x in list(marker_df['${AF_method.AF_col}'].unique()) if x not in ['None',np.nan]] print(f'Detected {quant[AF_markers].eq(0.0).any(axis=1).sum()} cells with AF values of zero in the dataset') #if $AF_method.AF_filter == 'filter':
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scale_cell_coordinates.py Thu Jul 11 22:41:26 2024 +0000 @@ -0,0 +1,50 @@ +import argparse +import json +import warnings + +import anndata as ad + + +def main(inputs, output): + + """ + inputs : str + File path to galaxy tool JSON inputs config file + output: str + File path to save the output h5ad file + """ + warnings.simplefilter('ignore') + + # read inputs JSON + with open(inputs, 'r') as param_handler: + params = json.load(param_handler) + + # read input anndata file + adata = ad.read_h5ad(params['anndata']) + + # scale coords + unit = params['unit'] + new_col_names = [] + for c in [params['x_coord'], params['y_coord']]: + scaled_col_name = f'{c}_{unit}' + adata.obs[scaled_col_name] = adata.obs[c] * params['resolution'] + new_col_names.append(scaled_col_name) + + # overwrite adata.obsm['spatial'] with scaled coordinates + adata.obsm['spatial'] = adata.obs[scaled_col_name].values + + # write out anndata to h5ad file + adata.write_h5ad(output) + + +if __name__ == '__main__': + + aparser = argparse.ArgumentParser() + aparser.add_argument( + "-i", "--inputs", dest="inputs", required=True) + aparser.add_argument( + "-o", "--output", dest="output", required=False) + + args = aparser.parse_args() + + main(args.inputs, args.output)
--- a/test-data/rename_channels.csv Fri May 10 21:01:41 2024 +0000 +++ b/test-data/rename_channels.csv Thu Jul 11 22:41:26 2024 +0000 @@ -1,2 +1,3 @@ channel_number,cycle_number,marker_name,Filter,excitation_wavelength,emission_wavelength -0,6,DNA_6,DAPI,395,431 \ No newline at end of file +0,6,DNA_6,DAPI,395,431 +0,6,DNA_7,DAPI,395,431 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/test.xml Thu Jul 11 22:41:26 2024 +0000 @@ -0,0 +1,2 @@ +<?xml version='1.0' encoding='utf-8'?> +<OME xmlns="http://www.openmicroscopy.org/Schemas/OME/2016-06" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" UUID="urn:uuid:be7b96c1-399b-41a1-a9f8-ab50da05159b" xsi:schemaLocation="http://www.openmicroscopy.org/Schemas/OME/2016-06 http://www.openmicroscopy.org/Schemas/OME/2016-06/ome.xsd"><Image ID="Image:0"><Pixels BigEndian="false" DimensionOrder="XYZCT" ID="Pixels:0" PhysicalSizeX="0.6499999761581421" PhysicalSizeXUnit="µm" PhysicalSizeY="0.6499999761581421" PhysicalSizeYUnit="µm" SizeC="32" SizeT="1" SizeX="13720" SizeY="9420" SizeZ="1" Type="uint16"><Channel ID="Channel:0:0" Name="DNA" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:1" Name="Control-488nm" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:2" Name="Control-555nm" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:3" Name="Control-647nm" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:4" Name="DNA (2)" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:5" Name="ERK-1 (pT202; pY204)" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:6" Name="ERK-1 (pT202; pY204) (2)" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:7" Name="hRAD51" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:8" Name="DNA (3)" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:9" Name="G1/S-specific cyclin-D1" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:10" Name="Vimentin" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:11" Name="Aortic smooth muscle actin" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:12" Name="DNA (4)" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:13" Name="E-cadherin" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:14" Name="ER" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:15" Name="PR" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:16" Name="DNA (5)" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:17" Name="Epidermal growth factor receptor" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:18" Name="Rb (pS807; pS811)" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:19" Name="CD45" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:20" Name="DNA (6)" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:21" Name="Antigen Ki67" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:22" Name="CK-19" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:23" Name="p21" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:24" Name="DNA (7)" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:25" Name="CK-14" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:26" Name="Androgen Receptor" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:27" Name="Cleaved PARP-1" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:28" Name="DNA (8)" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:29" Name="CK-17" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:30" Name="CK-7" SamplesPerPixel="1"><LightPath /></Channel><Channel ID="Channel:0:31" Name="HER2" SamplesPerPixel="1"><LightPath /></Channel><TiffData IFD="0" PlaneCount="32" /><Plane TheC="0" TheT="0" TheZ="0" /><Plane TheC="1" TheT="0" TheZ="0" /><Plane TheC="2" TheT="0" TheZ="0" /><Plane TheC="3" TheT="0" TheZ="0" /><Plane TheC="4" TheT="0" TheZ="0" /><Plane TheC="5" TheT="0" TheZ="0" /><Plane TheC="6" TheT="0" TheZ="0" /><Plane TheC="7" TheT="0" TheZ="0" /><Plane TheC="8" TheT="0" TheZ="0" /><Plane TheC="9" TheT="0" TheZ="0" /><Plane TheC="10" TheT="0" TheZ="0" /><Plane TheC="11" TheT="0" TheZ="0" /><Plane TheC="12" TheT="0" TheZ="0" /><Plane TheC="13" TheT="0" TheZ="0" /><Plane TheC="14" TheT="0" TheZ="0" /><Plane TheC="15" TheT="0" TheZ="0" /><Plane TheC="16" TheT="0" TheZ="0" /><Plane TheC="17" TheT="0" TheZ="0" /><Plane TheC="18" TheT="0" TheZ="0" /><Plane TheC="19" TheT="0" TheZ="0" /><Plane TheC="20" TheT="0" TheZ="0" /><Plane TheC="21" TheT="0" TheZ="0" /><Plane TheC="22" TheT="0" TheZ="0" /><Plane TheC="23" TheT="0" TheZ="0" /><Plane TheC="24" TheT="0" TheZ="0" /><Plane TheC="25" TheT="0" TheZ="0" /><Plane TheC="26" TheT="0" TheZ="0" /><Plane TheC="27" TheT="0" TheZ="0" /><Plane TheC="28" TheT="0" TheZ="0" /><Plane TheC="29" TheT="0" TheZ="0" /><Plane TheC="30" TheT="0" TheZ="0" /><Plane TheC="31" TheT="0" TheZ="0" /></Pixels></Image></OME>