# HG changeset patch
# User goeckslab
# Date 1748466892 0
# Node ID e860ca30cd0b76964ce46d423e879963cf8cb286
# Parent 5f4a4dd06bc9fece8220d177bbc6389b720723f9
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit 90f081e58b5ee41bba3a7e6f01d97b5bd9392759
diff -r 5f4a4dd06bc9 -r e860ca30cd0b gate_finder.py
--- a/gate_finder.py Thu Feb 20 19:47:28 2025 +0000
+++ b/gate_finder.py Wed May 28 21:14:52 2025 +0000
@@ -53,7 +53,7 @@
return get_gate_phenotype(gate, np.ravel(data_norm))
-def main(inputs, output, image, anndata, offsets=None, masks=None):
+def main(inputs, output, image, anndata, offsets=None, masks=None, config_path=None):
"""
Parameter
---------
@@ -67,12 +67,17 @@
File path to anndata containing phenotyping info.
masks : str
File path to the image masks.
+ config_path : str
+ File path to the config containing galaxy_url and dataset_id.
"""
warnings.simplefilter('ignore')
with open(inputs, 'r') as param_handler:
params = json.load(param_handler)
+ with open(config_path) as conf_fh:
+ config = json.load(conf_fh)
+
marker = params['marker'].strip()
from_gate = params['from_gate']
to_gate = params['to_gate']
@@ -80,6 +85,12 @@
x_coordinate = params['x_coordinate'].strip() or 'X_centroid'
y_coordinate = params['y_coordinate'].strip() or 'Y_centroid'
+ galaxy_url = config["galaxy_url"]
+ dataset_id = config["dataset_id"]
+
+ # Build the prefix that Vitessce should use
+ display_prefix = (f"{galaxy_url}/api/datasets/{dataset_id}/display?filename=")
+
adata = read_h5ad(anndata)
# If no raw data is available make a copy
@@ -191,7 +202,7 @@
)
# export config file
- config_dict = vc.export(to='files', base_url='http://localhost', out_dir=output)
+ config_dict = vc.export(to='files', base_url=display_prefix, out_dir=output)
with open(Path(output).joinpath('config.json'), 'w') as f:
json.dump(config_dict, f, indent=4)
@@ -205,7 +216,8 @@
aparser.add_argument("-a", "--anndata", dest="anndata", required=True)
aparser.add_argument("-f", "--offsets", dest="offsets", required=False)
aparser.add_argument("-m", "--masks", dest="masks", required=False)
+ aparser.add_argument("--galaxy_config", dest="config_path", required=True)
args = aparser.parse_args()
- main(args.inputs, args.output, args.image, args.anndata, args.offsets, args.masks)
+ main(args.inputs, args.output, args.image, args.anndata, args.offsets, args.masks, args.config_path)
diff -r 5f4a4dd06bc9 -r e860ca30cd0b gate_finder.xml
--- a/gate_finder.xml Thu Feb 20 19:47:28 2025 +0000
+++ b/gate_finder.xml Wed May 28 21:14:52 2025 +0000
@@ -12,6 +12,14 @@
+
+
+
diff -r 5f4a4dd06bc9 -r e860ca30cd0b index.html
--- a/index.html Thu Feb 20 19:47:28 2025 +0000
+++ b/index.html Wed May 28 21:14:52 2025 +0000
@@ -27,31 +27,13 @@
import { Vitessce } from 'vitessce';
import { config } from './config.js';
- console.log('here be url: '+window.location.href);
- var current_url = window.location.href.replace(new RegExp('\/[^\/]*$'), '');
- console.log(current_url);
- function rewriteURL(input) {
- for (let k in input) {
- if (typeof input[k] === 'string' || input[k] instanceof String) {
- input[k] = input[k].replace('http://localhost', current_url)
- }
- else {
- input[k] = rewriteURL(input[k])
- }
- }
- return input;
- };
- var fixed_conf = {...config};
- fixed_conf = rewriteURL(fixed_conf);
- console.log('conf fixed:');
- console.log(fixed_conf);
function MyApp() {
return React.createElement(
Vitessce,
{
height: 1000,
theme: 'dark',
- config: fixed_conf,
+ config: config,
}
);
}
diff -r 5f4a4dd06bc9 -r e860ca30cd0b main_macros.xml
--- a/main_macros.xml Thu Feb 20 19:47:28 2025 +0000
+++ b/main_macros.xml Wed May 28 21:14:52 2025 +0000
@@ -1,6 +1,6 @@
3.5.1
- 0
+ 1
22.01
@@ -68,6 +68,7 @@
--inputs '$inputs'
--output '${output.files_path}'
--image '${output.files_path}/A/0/image01.ome.tiff'
+ --galaxy_config '${galaxy_config}'
--offsets '$image.metadata.offsets'
#if $masks
--masks '${output.files_path}/A/0/masks01.ome.tiff'
@@ -76,8 +77,9 @@
--anndata '$anndata'
#end if
&&
- cp '$__tool_directory__/index.html' '$output';
- echo "export var config = \$(cat ${output.files_path}/config.json)" >> '${output.files_path}/config.js';
+ cp '$__tool_directory__/index.html' '$output' &&
+ sed -i 's|display?filename=/|display?filename=|g' ${output.files_path}/config.json &&
+ echo "export var config = \$(cat ${output.files_path}/config.json)" >> '${output.files_path}/config.js' &&
cat '${output.files_path}/config.json' >> '$vitessce_config';
]]>
diff -r 5f4a4dd06bc9 -r e860ca30cd0b vitessce_spatial.py
--- a/vitessce_spatial.py Thu Feb 20 19:47:28 2025 +0000
+++ b/vitessce_spatial.py Wed May 28 21:14:52 2025 +0000
@@ -2,6 +2,7 @@
import json
import warnings
from os.path import isdir, join
+# import urllib.parse
from pathlib import Path
import scanpy as sc
@@ -19,7 +20,7 @@
)
-def main(inputs, output, image, offsets=None, anndata=None, masks=None):
+def main(inputs, output, image, offsets=None, anndata=None, masks=None, config_path=None):
"""
Parameter
---------
@@ -33,12 +34,20 @@
File path to anndata containing phenotyping info.
masks : str
File path to the image masks.
+ config_path : str
+ File path to the config file containing galaxy_url and dataset_id.
"""
warnings.simplefilter('ignore')
with open(inputs, 'r') as param_handler:
params = json.load(param_handler)
+ with open(config_path) as conf_fh:
+ config = json.load(conf_fh)
+
+ galaxy_url = config["galaxy_url"]
+ dataset_id = config["dataset_id"]
+
# initialize vitessce config and add OME-TIFF image, and masks if specified
vc = VitessceConfig(schema_version="1.0.17", name=None, description=None)
dataset = vc.add_dataset()
@@ -73,12 +82,15 @@
w=lc_dims[0],
h=lc_dims[1])
+ # Build the prefix that Vitessce should use
+ display_prefix = (f"{galaxy_url}/api/datasets/{dataset_id}/display?filename=")
+
# if no anndata file, export the config with these minimal components
if not anndata:
vc.layout(lc | spatial)
config_dict = vc.export(
to='files',
- base_url='http://localhost',
+ base_url=display_prefix,
out_dir=output)
with open(Path(output).joinpath('config.json'), 'w') as f:
json.dump(config_dict, f, indent=4)
@@ -191,7 +203,7 @@
# export the config file
config_dict = vc.export(
to='files',
- base_url='http://localhost',
+ base_url=display_prefix,
out_dir=output)
with open(Path(output).joinpath('config.json'), 'w') as f:
@@ -206,7 +218,8 @@
aparser.add_argument("-f", "--offsets", dest="offsets", required=False)
aparser.add_argument("-a", "--anndata", dest="anndata", required=False)
aparser.add_argument("-m", "--masks", dest="masks", required=False)
+ aparser.add_argument("--galaxy_config", dest="config_path", required=True)
args = aparser.parse_args()
- main(args.inputs, args.output, args.image, args.offsets, args.anndata, args.masks)
+ main(args.inputs, args.output, args.image, args.offsets, args.anndata, args.masks, args.config_path)