# HG changeset patch
# User goeckslab
# Date 1720737670 0
# Node ID 61fd94c7ce42bcd70f2296d07ef7fce77bd78d0f
# Parent 55bc102d770963052eee50a80783795effbbfa0f
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit bc438db690e41823909b32b693f297d942433a43
diff -r 55bc102d7709 -r 61fd94c7ce42 macros.xml
--- a/macros.xml Fri May 10 21:01:32 2024 +0000
+++ b/macros.xml Thu Jul 11 22:41:10 2024 +0000
@@ -2,12 +2,12 @@
- quay.io/goeckslab/mti_utils:0.0.1
+ quay.io/goeckslab/mti_utils:@TOOL_VERSION@
- echo @VERSION@
+ echo @TOOL_VERSION@
@@ -15,7 +15,7 @@
- 0.0.1
- 5
+ 0.0.2
+ 0
19.01
diff -r 55bc102d7709 -r 61fd94c7ce42 rename_tiff_channels.xml
--- a/rename_tiff_channels.xml Fri May 10 21:01:32 2024 +0000
+++ b/rename_tiff_channels.xml Thu Jul 11 22:41:10 2024 +0000
@@ -33,11 +33,27 @@
import os
import sys
import argparse
+from itertools import cycle
import pandas as pd
import ome_types
-from ome_types.model import channel
+from ome_types.model import channel, Color
from tifffile import tiffcomment
+# setting default colors to match avivator
+colors = [
+ (0,0,255,1.0), # blue
+ (0,255,0,1.0), # green
+ (255,0,255,1.0), # magenta
+ (255,255,0,1.0), # yellow
+ (255,127,0,1.0), # orange
+ (0,255,255,1.0), # cyan
+ (255,255,255,1.0), # white
+ (255,0,0,1.0) # red
+]
+
+# convert to repeatable object of primitive int colors
+color_cycle = cycle([Color(c).as_int32() for c in colors])
+
cwd = os.getcwd()
channels_df = pd.read_csv(os.path.join(cwd, 'channels.csv'))
@@ -51,6 +67,7 @@
new_name = channels_df.loc[c_idx, 'marker_name']
channel.name = new_name
+ channel.color = next(color_cycle)
if l_idx == 0:
@@ -72,11 +89,11 @@
-
+
diff -r 55bc102d7709 -r 61fd94c7ce42 scale_cell_coordinates.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/scale_cell_coordinates.py Thu Jul 11 22:41:10 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)
diff -r 55bc102d7709 -r 61fd94c7ce42 test-data/pixels.h5ad
Binary file test-data/pixels.h5ad has changed
diff -r 55bc102d7709 -r 61fd94c7ce42 test-data/rename_channels.csv
--- a/test-data/rename_channels.csv Fri May 10 21:01:32 2024 +0000
+++ b/test-data/rename_channels.csv Thu Jul 11 22:41:10 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
diff -r 55bc102d7709 -r 61fd94c7ce42 test-data/rename_test.ome.tiff
Binary file test-data/rename_test.ome.tiff has changed
diff -r 55bc102d7709 -r 61fd94c7ce42 test-data/rename_test.tiff
Binary file test-data/rename_test.tiff has changed
diff -r 55bc102d7709 -r 61fd94c7ce42 test-data/test.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/test.xml Thu Jul 11 22:41:10 2024 +0000
@@ -0,0 +1,2 @@
+
+