view ramclustr.xml @ 4:050cfef6ba65 draft

planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/ramclustr commit 981ab05cdced6cbcbb1f13aa492e127365a4e9ed
author recetox
date Thu, 15 Jun 2023 14:01:48 +0000
parents 2ec9253a647e
children 2410de08b55a
line wrap: on
line source

<tool id="ramclustr" name="RAMClustR" version="@TOOL_VERSION@+galaxy0" profile="21.09">
    <description>A feature clustering algorithm for non-targeted mass spectrometric metabolomics data.</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <expand macro="creator"/>

    <requirements>
        <requirement type="package" version="@TOOL_VERSION@">r-ramclustr</requirement>
        <requirement type="package" version="3.20.0">bioconductor-xcms</requirement>
        <requirement type="package" version="9.0.0">r-arrow</requirement>
    </requirements>

    <command detect_errors="exit_code"><![CDATA[
        Rscript
            -e 'source("${__tool_directory__}/ramclustr_wrapper.R")'
            -e 'source("${ramclustr_method}")'
    ]]>
    </command>
    <configfiles>
        <configfile name="ramclustr_method">
            #if $filetype.type_choice == "xcms":
            obj = load("$filetype.xcms.input_xcms")
            ramclustObj = RAMClustR::rc.get.xcms.data(
                xcmsObj = xdata,
                #if $extras.ExpDes:
                    ExpDes = load_experiment_definition("${$extras.ExpDes}"),
                #end if
                mzdec = $msp_output_details.mzdec,
                ensure.no.na = $extras.replace_zeros
            )
            #else if $filetype.type_choice == "csv":
            ramclustObj = RAMClustR::rc.get.csv.data(
                csv = "$filetype.ms_csv.ms",
                #if $filetype.ms_csv.idmsms:
                    idmsms = "$filetype.ms_csv.idmsms",
                #end if
                #if $filetype.ms_csv.csv_phenoData:
                    phenoData = "$filetype.ms_csv.csv_phenoData",
                #end if
                #if $extras.ExpDes:
                    ExpDes = load_experiment_definition("${$extras.ExpDes}"),
                #end if
                st = $filetype.required.st,
                ensure.no.na = $extras.replace_zeros
            )
            #else if $filetype.type_choice == "recetox-aplcms":
            ramclustObj = read_ramclustr_aplcms(
                ms1_featuredefinitions = "$filetype.ms_dataframe.ms1_featureDefinitions",
                ms1_featurevalues = "$filetype.ms_dataframe.ms1_featureValues",
                #if $filetype.ms_dataframe.df_phenoData:
                    df_phenodata = "$filetype.ms_dataframe.df_phenoData",
                    phenodata_ext = "${filetype.ms_dataframe.df_phenoData.ext}",
                #end if
                #if $extras.ExpDes:
                    exp_des = "${$extras.ExpDes}",
                #end if
                st = $filetype.required.st,
                ensure_no_na = $extras.replace_zeros
            )
            #end if

            #if $extras.replace_zeros == "TRUE":
            ramclustObj = RAMClustR::rc.feature.replace.na(ramclustObj = ramclustObj)
            #end if

            #if $normalisation.normalisation_method.normalize != "none":
            ramclustObj = apply_normalisation(
                ramclustr_obj = ramclustObj,
                #if $normalisation.normalisation_method.normalize == "batch.qc":
                    metadata_file = "${$normalisation.normalisation_method.batch_order_qc}",
                    qc_inj_range = $normalisation.normalisation_method.qc_inj_range,
                #end if
                #if $normalisation.normalisation_method.normalize == "qc":
                    metadata_file = "${$normalisation.normalisation_method.batch_order_qc}",
                    p_cut = $normalisation.normalisation_method.p_cut,
                    rsq_cut = $normalisation.normalisation_method.rsq_cut,
                    p_adjust = $normalisation.normalisation_method.p_adjust,
                #end if
                normalize_method = "$normalisation.normalisation_method.normalize"
            )
            #end if

            ramclustObj = RAMClustR::rc.ramclustr(
                ramclustObj = ramclustObj,
                st = $filetype.required.st,
                sr = $filetype.required.sr,
                maxt = $filetype.required.maxt,
                deepSplit = $clustering.deepSplit,
                blocksize = $performance.blocksize,
                mult = $performance.mult,
                hmax = $clustering.hmax,
                minModuleSize = $clustering.minModuleSize,
                linkage = "$clustering.linkage",
                cor.method = "$filetype.required.cor_method",
                rt.only.low.n = $extras.rt_only_low_n,
                fftempdir = NULL,
            )
            
            store_output(
                ramclustr_obj = ramclustObj,
                output_merge_msp = $msp_output_details.merge_msp,
                output_spec_abundance = "$spec_abundance",
                #if $msp_output_details.merge_msp:
                    msp_file = "$mass_spectra_merged"
                #else:
                    msp_file = NULL
                #end if
            )
        </configfile>
    </configfiles>
    <inputs>
        <conditional name="filetype">
            <param name="type_choice" type="select" label="Choose input format:">
                <option value="xcms" selected="true">XCMS</option>
                <option value="csv">CSV</option>
                <option value="recetox-aplcms">RECETOX-APLCMS</option>
            </param>
            <when value="xcms">
                <expand macro="parameters_xcms" />
                <section name="required" title="General parameters" expanded="true">
                    <param label="Sigma t" name="st" type="float" optional="true" help="Retention time similarity (optional).
                           A recommended starting point is half the value of your average chromatographic peak width at half max (seconds))."/>
                    <expand macro="parameters_required" />
                </section>
            </when>
            <when value="csv">
                <expand macro="parameters_csv" />
                <section name="required" title="General parameters" expanded="true">
                    <param label="Sigma t" name="st" type="float" value="1" help="Retention time similarity.
                           A recommended starting point is half the value of your average chromatographic peak width at half max (seconds))."/>
                    <expand macro="parameters_required" />
                </section>
            </when>
            <when value="recetox-aplcms">
                <expand macro="parameters_recetox_aplcms" />
                <section name="required" title="General parameters" expanded="true">
                    <param label="Sigma t" name="st" type="float" value="1" help="Retention time similarity.
                           A recommended starting point is half the value of your average chromatographic peak width at half max (seconds))."/>
                    <expand macro="parameters_required" />
                </section>
            </when>
        </conditional>
        <expand macro="main_parameters" />
    </inputs>

    <outputs>
        <data label="Spec Abundance of ${on_string}" name="spec_abundance" format="csv" />
        <expand macro="output_msp"/>
    </outputs>

    <tests>
        <test><!-- TEST 1 -->
            <section name="filetype">
                <param name="type_choice" value="xcms"/>
                <section name="xcms">
                    <param name="input_xcms" value="test1_xcmsObj_1.rdata.xcms.fillpeaks" ftype="rdata.xcms.fillpeaks"/>
                </section>
                <section name="required">
                    <param name="maxt" value="259.8"/>
                </section>
            </section>
            <section name="msp_output_details">
                <param name="mzdec" value="4"/>
            </section>
            <section name="extras">
                <param name="ExpDes" value="lc-ramclustr-define-experiment.csv" ftype="csv"/>
            </section>
            <output name="mass_spectra_merged" file="test1_fill_xcms_1.msp" ftype="msp"/>
            <output name="spec_abundance" file="test1_spec_abundance_xcms_1.csv" ftype="csv" compare="sim_size" delta="100"/>
        </test>
        <test><!-- TEST 2 -->
            <section name="filetype">
                <param name="type_choice" value="xcms"/>
                <section name="xcms">
                    <param name="input_xcms" value="test2_xcmsObj_2.rdata.xcms.fillpeaks" ftype="rdata.xcms.fillpeaks"/>
                </section>
                <section name="required">
                    <param name="maxt" value="78.4"/>
                </section>
            </section>
            <section name="msp_output_details">
                <param name="mzdec" value="4"/>
            </section>
            <section name="normalisation">
                <section name="normalisation_method">
                    <param name="batch_order_qc" value="test2_sample_metadata_xcms_2.csv" ftype="csv" />
                </section>
            </section>
            <output name="mass_spectra_merged" file="test2_fill_xcms_2.msp" ftype="msp" compare="sim_size" delta="100"/>
            <output name="spec_abundance" file="test2_spec_abundance_xcms_2.csv" ftype="csv" compare="sim_size" delta="100"/>
        </test>
        <test><!-- TEST 3 -->
            <section name="filetype">
                <param name="type_choice" value="csv"/>
                <section name="ms_csv">
                    <param name="ms" value="test3_csv_test-input_1_2.csv" ftype="csv"/>
                </section>
                <section name="required">
                    <param name="st" value="5.0"/>
                    <param name="maxt" value="1"/>
                </section>
            </section>
            <section name="performance">
                <param name="blocksize" value="1000"/>
                <param name="mult" value="1"/>
            </section>
            <output name="mass_spectra_merged" file="test3_spectra_csv_1.msp" ftype="msp"/>
            <output name="spec_abundance" file="test3_spec_abundance_csv_1.csv" ftype="csv"/>
        </test>
        <test><!-- TEST 4 -->
            <section name="filetype">
                <param name="type_choice" value="csv"/>
                <section name="ms_csv">
                    <param name="ms" value="test3_csv_test-input_1_2.csv" ftype="csv"/>
                </section>
            </section>
            <output name="mass_spectra_merged" file="test4_spectra_csv_2.msp" ftype="msp" lines_diff="10"/>
        </test>
        <test><!-- TEST 5 -->
            <section name="filetype">
                <param name="type_choice" value="recetox-aplcms"/>
                <section name="ms_dataframe">
                    <param name="ms1_featureDefinitions" value="test5_df_featureDefinitions_input.parquet" ftype="parquet"/>
                    <param name="ms1_featureValues" value="test5_df_featureValues_input.parquet" ftype="parquet"/>
                </section>
            </section>
            <output name="mass_spectra_merged" file="test5_spectra.msp" ftype="msp" lines_diff="10"/>
        </test>
    </tests>

    <help>
        <![CDATA[
            @HELP@

        .. rubric:: **Footnotes**
        .. [1] Correlation, Variance and Covariance - `stats::cor <https://www.rdocumentation.org/packages/stats/versions/3.6.2/topics/cor>`_
        .. [2] Hierarchical Clustering - `stats::hclust <https://www.rdocumentation.org/packages/stats/versions/3.6.2/topics/hclust>`_
        .. [3] Dynamic Dendrogram Pruning Based on Dendrogram Only - `dynamicTreeCut::cutreeDynamicTree <https://www.rdocumentation.org/packages/dynamicTreeCut/versions/1.63-1/topics/cutreeDynamicTree>`_
        ]]>
    </help>

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