view deconvolve.xml @ 2:8139addbe3c3 draft default tip

planemo upload for repository https://github.com/goeckslab/tools-st/tree/main/tools/bayesTME commit 9f02aac27bf6c59325790d90fa12434128213bb0
author goeckslab
date Wed, 10 Dec 2025 21:15:14 +0000
parents 4f6d716e5da2
children
line wrap: on
line source

<tool id="bayestme_deconvolve" name="BayesTME: Deconvolve" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
    <description>Reference-free and Reference-based Spot Deconvolution for Spatial Transcriptomics with BayesTME</description>
    <macros>
        <import>macros.xml</import>
    </macros>
	<expand macro="bayestme_requirements"/>
	<command detect_errors="aggressive"><![CDATA[
		
		## Filtering Step (optional)
		#if str($filter_genes.pre_filter) == 'filter_genes':
		
	        filter_genes
	            --adata '${adata}'
	            --output 'dataset_filtered.h5ad'
	            --n-top-by-standard-deviation '${n_top_by_standard_deviation}'
	            #if str($spot_threshold)
	                --spot-threshold '${spot_threshold}'
	            #end if
			    #if $filter_ribosomal_genes
	                --filter-ribosomal-genes
	            #end if
				#if $mode.deconv_mode == 'reference_based'
				    --expression-truth '${mode.expression_truth}'
			    #end if
			    #if $verbose
	                -v
	            #end if
				&&
        #else
		
		    ## Just use unfiltered
	        ln -s '${adata}' 'dataset_filtered.h5ad' &&
			
		#end if
		
		## Deconvolve Step
		deconvolve
	        --adata 'dataset_filtered.h5ad'
			--adata-output 'dataset_deconvolved.h5ad'
			--output 'deconvolution_samples.h5'
			#if $mode.deconv_mode == 'reference_free'
			    --n-components '${mode.n_components}'
		    #end if
			#if $mode.deconv_mode == 'reference_based'
			    --expression-truth '${mode.expression_truth}'
				--reference-scrna-celltype-column '${mode.reference_scrna_celltype_column}'
				--reference-scrna-sample-column '${mode.reference_scrna_sample_column}'
			#end if
			--spatial-smoothing-parameter '${deconv_params.spatial_smoothing_parameter}'
			--n-samples '${deconv_params.n_samples}'
			--n-svi-steps '${deconv_params.n_svi_steps}'
	        #if $deconv_params.use_spatial_guide
	            --use-spatial-guide
	        #else
	            --no-use-spatial-guide
	        #end if
			#if $additional_cli.verbose
	            -v
	        #end if
	        #if str($additional_cli.seed)
	            --seed '${additional_cli.seed}'
	        #end if
			
	]]></command>
    
	<inputs>
		
	    <!-- Required Input ST Data -->
	    <param argument="--adata" type="data" format="h5ad" label="Input AnnData in h5 format, expected to be already bleed corrected"/>
	    
		<!-- Filter Genes Options (from macros) -->
		<conditional name="filter_genes">
	        <param name="pre_filter" type="select" label="Optional: Filter Genes By Spatial Variance Prior To Deconvolution" >
	            <option value="no_filtering" selected="true">No Filtering</option>
				<option value="filter_genes">Filter Genes Prior To Deconvolution</option>
	        </param>
			<when value="no_filtering">
	        </when>
	        <when value="filter_genes">				
				<expand macro="filter_genes_options" />			
	        </when>
	    </conditional>
		
		<!-- Deconvolution Strategy -->
		<conditional name="mode">
			
		    <param name="deconv_mode" type="select" label="Deconvolution Strategy">
		        <option value="reference_free" selected="true">Reference-free (unsupervised)</option>
		        <option value="reference_based">Reference-based (with scRNA reference)</option>
		    </param>

		    <!-- Reference-free: Specify Number of Cell Types -->
		    <when value="reference_free">
		        <param argument="--n-components" type="integer" value="5" optional="false" label="Number of cell types to deconvolve into"/>
		    </when>

		    <!-- Reference-based: Provide scRNA Ref -->
		    <when value="reference_based">
				<param argument="--expression-truth" type="data" format="h5ad" optional="true" label="Matched scRNA data in h5ad format, will be used to enforce a prior on celltypes and expression"/>
		        <param argument="--reference-scrna-celltype-column" type="text" label="The name of the column with celltype id in the matched scRNA anndata"/>
		        <param argument="--reference-scrna-sample-column" type="text" label="The name of the column with sample id in the matched scRNA anndata"/>
		    </when>
			
		</conditional>
		
		<!-- Deconvolution Parameters -->
		<section name="deconv_params" title="Deconvolution Parameters" expanded="false"> 
			<param argument="--spatial-smoothing-parameter" type="float" value="0.5" label="Spatial smoothing parameter (referred to as lambda in paper)"/>
		   	<param argument="--n-samples" type="integer" value="100" label="Number of samples from the posterior distribution or variational family"/>
		   	<param argument="--n-svi-steps" type="integer" value="20000" label="Number of steps for fitting variational family"/>
			<param name="use_spatial_guide" argument="--use-spatial-guide, --no-use-spatial-guide" type="boolean" checked="true" label="Use spatial guide (variational family with spatial priors) for SVI"/>
		</section>
		
	    <!-- Additional CLI Options -->
		<section name="additional_cli" title="Additional Arguments" expanded="false"> 
	        <param argument="--seed" type="integer" optional="true" label="Seed value for random number generator"/>
	   	    <param argument="--verbose" type="boolean" checked="false" label="Enable verbose logging"/>
		</section>	   		
		
	</inputs>
	
    <outputs>
        <data name="adata_output" format="h5ad" label="BayesTME Deconvolve on ${on_string}: dataset_deconvolved.h5ad" from_work_dir="dataset_deconvolved.h5ad"/>
		<data name="output" format="h5" label="BayesTME Deconvolve on ${on_string}: deconvolution_samples.h5" from_work_dir="deconvolution_samples.h5"/>
		<data name="deconvolution_loss" format="pdf" label="BayesTME Deconvolve on ${on_string}: deconvolution_loss.pdf" from_work_dir="deconvolution_loss.pdf"/>
    </outputs>
	
    <tests>
		
		<!-- Reference-free Deconvolution Test -->
		<test>
			<param name="adata" value="visium_test_dataset.h5ad"/>
			<conditional name="mode" >
				<param name="deconv_mode" value="reference_free"/>
				<param name="n_components" value="3"/>
			</conditional>
		    <section name="deconv_params" >
			    <param name="spatial_smoothing_parameter" value="0.5"/>
			   	<param name="n_samples" value="10"/>
			   	<param name="n_svi_steps" value="10"/>
			</section>
			<section name="additional_cli" >
				<param name="seed" value="93"/>
			</section>
			<conditional name="filter_genes" >
				<param name="pre_filter" value="filter_genes"/>
			    <param name="n_top_by_standard_deviation" value="40"/>
				<section name="additional_filtering_options" >
				    <param name="filter_ribosomal_genes" value="true"/>
				</section>
			</conditional>
			<output name="adata_output" file="refFree_test_data/dataset_deconvolved.h5ad" compare="sim_size" delta="20000">
				<assert_contents>
					<has_h5_keys keys="obsm/bayestme_cell_type_counts,obsm/bayestme_cell_type_probabilities,varm/bayestme_omega,varm/bayestme_omega_difference,varm/bayestme_relative_expression,varm/bayestme_relative_mean_expression,uns/bayestme_n_cell_types"/>
				</assert_contents>
			</output>
			<output name="output" file="refFree_test_data/deconvolution_samples.h5" compare="sim_size" delta="500000">
				<assert_contents>
					<has_h5_keys keys="beta_trace,cell_num_total_trace,cell_prob_trace,expression_trace,losses,reads_trace"/>
				</assert_contents>
			</output>	
			<output name="deconvolution_loss" file="refFree_test_data/deconvolution_loss.pdf" compare="sim_size" delta="20000" ftype="pdf"/>			
		</test>
		
        <!-- Reference-based Deconvolution Test -->
        <test>
            <param name="adata" value="visium_test_dataset.h5ad"/>
			<conditional name="mode" >
				<param name="deconv_mode" value="reference_based"/>
	            <param name="expression_truth" value="refBased_test_data/scRef_test_dataset.h5ad"/>
	            <param name="reference_scrna_celltype_column" value="cell_type"/>
	            <param name="reference_scrna_sample_column" value="donor_id"/>
			</conditional>
            <section name="deconv_params" >
	            <param name="spatial_smoothing_parameter" value="0.5"/>
	            <param name="n_samples" value="10"/>
	            <param name="n_svi_steps" value="10"/>
			</section>
			<section name="additional_cli" >
				<param name="seed" value="93"/>
			</section>
			<conditional name="filter_genes" >
				<param name="pre_filter" value="filter_genes"/>
			    <param name="n_top_by_standard_deviation" value="40"/>
				<section name="additional_filtering_options" >
				    <param name="filter_ribosomal_genes" value="true"/>
				</section>
			</conditional>
			<output name="adata_output" file="refBased_test_data/dataset_deconvolved.h5ad" compare="sim_size" delta="20000">
                <assert_contents>
                    <has_h5_keys keys="obsm/bayestme_cell_type_counts,obsm/bayestme_cell_type_probabilities,varm/bayestme_omega,varm/bayestme_omega_difference,varm/bayestme_relative_expression,varm/bayestme_relative_mean_expression,uns/bayestme_n_cell_types"/>
                </assert_contents>
            </output>
            <output name="output" file="refBased_test_data/deconvolution_samples.h5" compare="sim_size" delta="500000">
                <assert_contents>
                    <has_h5_keys keys="beta_trace,cell_num_total_trace,cell_prob_trace,expression_trace,losses,reads_trace"/>
                </assert_contents>
            </output>
			<output name="deconvolution_loss" file="refBased_test_data/deconvolution_loss.pdf" compare="sim_size" delta="20000" ftype="pdf"/>
        </test>
    
	</tests>
    <help>
<![CDATA[

usage: deconvolve [-h] [--adata ADATA] [--adata-output ADATA_OUTPUT] [-i] [--output OUTPUT] [--seed SEED] [--n-components N_COMPONENTS]
					[--spatial-smoothing-parameter SPATIAL_SMOOTHING_PARAMETER] [--n-samples N_SAMPLES] [--expression-truth EXPRESSION_TRUTH]
					[--reference-scrna-celltype-column REFERENCE_SCRNA_CELLTYPE_COLUMN] [--reference-scrna-sample-column REFERENCE_SCRNA_SAMPLE_COLUMN]
					[--n-svi-steps N_SVI_STEPS] [--use-spatial-guide | --no-use-spatial-guide] [-v]

Deconvolve data

options:
	-h, --help            show this help message and exit
	--adata ADATA         Input AnnData in h5 format, expected to be already bleed corrected
	--adata-output ADATA_OUTPUT
						A new AnnData in h5 format created with the deconvolution summary results appended.
	-i, --inplace         If provided, append deconvolution summary results to the --adata archive in place
	--output OUTPUT       Path where DeconvolutionResult will be written h5 format
	--seed SEED           Seed value for random number generator.
	--n-components N_COMPONENTS
						Number of cell types to deconvolve into.
	--spatial-smoothing-parameter SPATIAL_SMOOTHING_PARAMETER
						Spatial smoothing parameter (referred to as lambda in paper)
	--n-samples N_SAMPLES
						Number of samples from the posterior distribution or variational family.
	--expression-truth EXPRESSION_TRUTH
						Matched scRNA data in h5ad format, will be used to enforce a prior on celltypes and expression.
	--reference-scrna-celltype-column REFERENCE_SCRNA_CELLTYPE_COLUMN
						The name of the column with celltype id in the matched scRNA anndata.
	--reference-scrna-sample-column REFERENCE_SCRNA_SAMPLE_COLUMN
						The name of the column with sample id in the matched scRNA anndata.
	--n-svi-steps N_SVI_STEPS
						Number of steps for fitting variational family
	--use-spatial-guide, --no-use-spatial-guide
						Use spatial guide (variational family with spatial priors) for SVI
	-v, --verbose         Enable verbose logging

]]>
    </help>
    <expand macro="citations"/>
</tool>