Mercurial > repos > goeckslab > cell_intensity_processing
view process_intensities.xml @ 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 |
line wrap: on
line source
<tool id="cell_intensity_processing" name="Process single-cell intensities" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@"> <description></description> <macros> <import>macros.xml</import> </macros> <edam_operations> <edam_operation>operation_3443</edam_operation> </edam_operations> <expand macro="requirements" /> <command detect_errors="aggressive"><![CDATA[ ln -s '$quant_table' ./quant.csv && python '$script' ]]></command> <configfiles> <configfile name = "script"> import os import numpy as np import pandas as pd cwd = os.getcwd() quant = pd.read_csv(os.path.join(cwd, 'quant.csv'), index_col = 0) marker_df = pd.read_csv('$channel_csv') 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 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': pre_filter_count = len(quant) quant = quant.loc[quant[AF_markers].ne(0.0).any(axis=1),:] print(f'Filtered out {pre_filter_count - len(quant)} cells that had AF values of 0.0') #elif $AF_method.AF_filter == 'clip': print('Clipping all AF values equal to 0.0 to the minimum non-zero AF value') for af in AF_markers: quant[af] = quant[af].clip(lower = quant[af][quant[af].ne(0.0)].min()) #end if #end if for marker in markers_to_normalize: #if $exp.exposure == 'correct_exposure': exp_time = marker_df.loc[marker_df['marker_name'] == marker, '${exp.exp_col}'].values[0] quant[marker] = quant[marker] / exp_time #end if #if $AF_method.select_method == 'dont_adjust': pass #elif $AF_method.select_method == 'subtract': current_AF_channel = marker_df.loc[marker_df['marker_name'] == marker, '${AF_method.AF_col}'].values[0] if current_AF_channel in markers_to_normalize: quant[marker] = quant[marker] - quant[current_AF_channel] quant[marker] = np.where(quant[marker] < 0, 0, quant[marker]) #elif $AF_method.select_method == 'SBR': current_AF_channel = marker_df.loc[marker_df['marker_name'] == marker, '${AF_method.AF_col}'].values[0] if current_AF_channel in markers_to_normalize: quant[marker] = quant[marker] / quant[current_AF_channel] #end if quant.to_csv(os.path.join(cwd, 'processed_quant.csv')) </configfile> </configfiles> <inputs> <param name="quant_table" type="data" format="csv" label="Input quantification table (csv)" /> <param name="channel_csv" type="data" format="csv" label="Channel Metadata (csv)" /> <conditional name="exp"> <param name="exposure" type="select" label="Select whether to divide intensities by exposure times"> <option value="dont_correct_exposure">No exposure correction</option> <option value="correct_exposure">Exposure correction</option> </param> <when value="dont_correct_exposure" /> <when value="correct_exposure"> <param name="exp_col" type="text" value="exposure_time" label="Name of column in markers file containing exposure times" /> </when> </conditional> <conditional name="AF_method"> <param name="select_method" type="select" label="Select method of autofluorescence/background adjustment"> <option value="dont_adjust">No AF/background adjustment</option> <option value="subtract">Autofluorescence subtraction</option> <option value="SBR">Signal-to-background ratio</option> </param> <when value="dont_adjust" /> <when value="subtract"> <param name="AF_col" type="text" value="AF_channel" label="Name of column in markers file containing respective AF channel for each marker" /> </when> <when value="SBR"> <param name="AF_col" type="text" value="AF_channel" label="Name of column in markers file containing respective AF channel for each marker" /> <param name="AF_filter" type="select" label="Select whether to clip or filter out AF values equal to 0"> <option value="clip">Clip autofluorescence values of 0.0 to the minimum non-zero autofluorescence value</option> <option value="filter">Filter out cells with autofluorescence values equal to 0.0</option> </param> </when> </conditional> </inputs> <outputs> <data name="processed_quant" from_work_dir="processed_quant.csv" format="csv"/> </outputs> <tests> <test> <param name="quant_table" value="intensities.csv" /> <param name="channel_csv" value="intensity_channels.csv" /> <conditional name="exp"> <param name="exposure" value="correct_exposure" /> </conditional> <conditional name="AF_method"> <param name="select_method" value="SBR" /> <param name="AF_filter" value="clip" /> </conditional> <output name="processed_quant" ftype="csv"> <assert_contents> <has_n_columns n="15" sep="," /> <has_n_lines n="15" /> </assert_contents> </output> </test> </tests> <help><![CDATA[ This tool can be used to perform several different common signal processing operations for single-cell mean marker intensities from multiplex tissue imaging data. **Inputs** 1. Comma-separated feature observation matrix that is generated by **MCQuant** 2. Comma-separated channel metadata file that maps marker names to exposure times (optional) and respective AF/bg channels (optional) **Options** 1. Exposure correction - Divide single-cell intensities by respective exposure time in channel metadata 2. Background subtraction - Subtract single-cell mmean marker intensities by respective AF/bg channel mean intensity specified in channel metadata 3. Signal-to-background ratio - Divide single-cell mmean marker intensities by respective AF/bg channel mean intensity specified in channel metadata **Outputs** 1. Feature observation matrix with processed intensities for all markers in channel metadata file. CellIDs, centroids, and morphological data remain unchanged. ]]></help> <expand macro="citations" /> </tool>