view tableviewer.xml @ 13:c4bde687c846 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 0cfd88d16b0b20a66d4b21b037ddee6a8c440d88
author iuc
date Wed, 12 Apr 2023 15:09:05 +0000
parents 290a11559985
children
line wrap: on
line source

<?xml version="1.0"?>
<tool id="circos_tableviewer" name="Circos: Table viewer" version="@WRAPPER_VERSION@">
    <description>easily creates circos plots from tabular data</description>
    <macros>
        <import>macros.xml</import>
    </macros>
    <edam_topics>
        <edam_topic>topic_0797</edam_topic>
        <edam_topic>topic_0092</edam_topic>
    </edam_topics>
    <edam_operations>
        <edam_operation>operation_0337</edam_operation>
    </edam_operations>
    <expand macro="requirements" />
    <command detect_errors="exit_code"><![CDATA[
mkdir -p circos/data/ &&
mkdir -p circos/etc/ &&
cp '$circos_conf' circos/etc/circos.conf &&

parse-table -file '$table' -conf '$parse_table_conf' > tmp &&

make-conf -dir circos/data < tmp &&

tar -czf circos.tar.gz circos &&
cd circos &&
circos -conf etc/circos.conf &&
mv circos.png ../ &&
mv circos.svg ../
    ]]></command>
    <configfiles>
        <configfile name="parse_table_conf"><![CDATA[
################################################################
#
# This is a fairly complicated configuration file. Take your time in
# experimenting and adjust one thing at a time :)
#
################################################################

max_col_num = 200
max_row_num = 200

# skip this many rows before reading in header and data
skip_rows        = 0

# is there a header line that identifies the columns?
header           = yes

# is there a row that specifies the order of columns in the image?
# - if so, this must be the first line of the header
# - if the line exists (col_order_row=yes), employ the use_col_order_row to toggle whether it is used
col_order_row     = no
use_col_order_row = no

# is there a row that specifies the size of columns in the image?
# - if so, this must be the next line of the header
# - if the line exists (col_size_row=yes), employ the use_col_size_row to toggle whether it is used
col_size_row     = no
use_col_size_row = no

# is there a row that specifies the color of each column segment in the image?
# - if so, this must be the next line of the header
# - if the line exists (col_color_row=yes), employ the use_col_color_row to toggle whether it is used
col_color_row     = no
use_col_color_row = no

# is there a column that specifies the order of rows in the image?
# - if so, this must be the first column
# - if the line exists (row_order_col=yes), employ the use_row_order_col to toggle whether it is used
row_order_col     = no
use_row_order_col = no

row_size_col     = no
use_row_size_col = no

# is there a column that specifies the color of each row segment in the image?
# - if so, this must be the second column
# - if the line exists (row_color_col=yes), employ the use_row_color_col to toggle whether it is used
row_color_col     = no
use_row_color_col = no

# if you do not have a column/row that explicitly defines order
# of segments in the image, you can set this here. Use one (or more) of
# these values to specify how segments should be ordered.
# - row_major (row segments first, then column)
# - col_major (col segments first, then row)
# - ascii     (asciibetic order)
# - row_size  (total of rows for the segment - useful if the segment has both row and column contributions)
# - col_size  (total of colums for the segment - useful if the segment has both row and column contributions)
# - row_to_col_ratio (ratio of total of rows to columns for the segment)
# - col_to_row_ratio (ratio of total of rows to columns for the segment)
# - size_asc  (size, in ascending order)
# - size_desc (size, in descending order)

#segment_order = row_to_col_ratio,size_desc # col_major,size_desc
segment_order  = size_desc
#segment_order = ascii
#segment_order = file:etc/order-by-table-remapped.txt
#segment_order  = size_desc,row_to_col_ratio
segment_color_order = ascii

# values for segments can be normalized if the use_segment_normalization is set to yes
use_segment_normalization = no

# the normalization function can be one of the following, and is applied to
# all values that correspond to the segment's label
# total - sum of cell values for the segment label (row and col)
# average - average of cell values for the segment label (row and col)
# row_total, row_average - sum or average for cell values for the segment row
# col_total, col_average - sum or average for cell values for the segment col
# row_size, col_size, total_size - based on the optional size column (see col_size_row and row_size_col above)
# VALUE - segments are scaled to a constant VALUE (e.g. 1000)
segment_normalization_function = 1000

# normalization can be performed by either altering the actual data values or
# by applying a visual scaling of the segments. When 'value' is used, the data
# is changed. When 'visual' is used, then a chromosomes_scale line is reported
# by this script which you must include in circos.conf for the scaling to be applied
segment_normalization_scheme   = value

################################################################
# placement of cell ribbons on row/column segments
#
# for segments that share both column and row ribbons, the
# order of ribbon position can be adjusted with placement_order

placement_order = row,col # col,row or row,col

# within the row/column ribbon bundle for each segment,
# ribbon_bundle_order determines how the ribbons will be
# ordered
# - size_asc  - by value of the cell, ascending
# - size_desc - by value of the cell, descending
# - ascii     - sorted by destination label, ascending
# - native    - sorted by order of destination segment

ribbon_bundle_order = size_desc # size, ascii, native

# reverse the position of links in table/row segments?

reverse_rows    = no
reverse_columns = no

# values for cells with the same row/column name can be treated
# independently. You can
# show - show these cells and not filter them at all
# hide - hide these cells from the image, but not resize the row/columns
# remove - entirely remove these cells from the data set (equivalent to setting cells to missing value)
intra_cell_handling = show

# ribbon layering - order in which the ribbons are drawn on the image
# size_asc  - ascending by ribbon size (small ribbons drawn first, therefore large ribbons will be at front)
# size_desc - descending by ribbon size (large ribbons drawn first, therefore small ribbons will be at front)

ribbon_layer_order = size_asc

# if both (A,B)=x and (B,A)=y cells exist, you can choose to have the ribbon
# ends sized variably so that ribbon at A has width x and at B has width y

ribbon_variable = no
ribbon_variable_intra_collapse = yes

################################################################
# cell value mapping allows you to remap the cell values using
# any Perl expression that uses X as the cell value. For example,
#
# cell_remap_formula = log(X)
#                    = sqrt(X)
#                    = X/10
#                    = X ? log(X) : 0
#
# This remapping takes place before any filters or scaling is applied. Its effect
# is the same as remapping the cell values in the input file.

use_cell_remap     = no
cell_remap_formula = round(10*X)

################################################################
# scale your values with a power rule (useful if the range of values
# is very large) to
# - atten_large: attenuate large values and maintain visibility
#   of ribbons corresponding to small values, or
# - atten_small: attenuate small values to increase visibility
#   of ribbons corresponding to large values
#
# given a value, v, and a maximum, m
#
# atten_small:
#
# v_new = m * ( exp(scale_factor * v / m) - 1 ) / ( exp(scale_factor) - 1 )
#
# atten_large:
#
# v_new = m * ( log(scale_factor * v ) ) / ( log(scale_factor * m ) )
#
# essentially the values are remapped to a log-type scale
# with the range 0..m

use_scaling    = no
scaling_type   = atten_large
scale_factor   = 1

blank_means_missing = no
missing_cell_value = -

################################################################
# Value cutoffs for cell values and ribbon formatting.
#
# You can toggle the visibility of ribbons for cells outside
# a min/max range. You can define one or more of these cutoffs.
# The cutoffs are applied to unscaled cell values.

#cell_min_value      = 10
#cell_min_percentile = 10
#cell_max_value      = 100
#cell_max_percentile = 100

# For cell values that do not pass the min/max filters above,
# you can specify whether they are hidden or removed. If the
# parameter is not defined, "hide" will be assumed.
# hide - cell values won't be shown, but row/col will not be resized
# remove - entirely remove these cells from the data set (equivalent to setting cells to missing value)

cutoff_cell_handling = hide

# The color of ribbons is by default the color of the row segment from
# which they originate. The block below allows you to remap the color
# of the ribbons based on cell percentile values. There are two ways
# to remap colors
#
# - color_remap=yes, color_autoremap=no
#   Uses <percentile> blocks to define the percentile values and associated
#   color/stroke_color characteristics for ribbons. Percentile value defined
#   in the block (e.g. <percentile 55>) is the max percentile value for
#   cells associated with this block.
# - color_remap=yes, color_autoremap=yes
#   Uses colors associated with each percentile window of size
#   percentile_sampling for each cell

<linkcolor>
color_source       = row
percentile_source  = larger
color_transparency = 1
color_remap        = no
color_autoremap    = no

<percentile 50>
color = dgrey
transparency = 5
</percentile>

<percentile 60>
transparency = 5
</percentile>

<percentile 70>
transparency = 4
</percentile>

<percentile 80>
transparency = 3
</percentile>

<percentile 90>
transparency = 2
stroke_color = black
stroke_thickness = 1p
</percentile>

<percentile 100>
transparency = 1
stroke_color = black
stroke_thickness = 3p
</percentile>

</linkcolor>

<linkparam>
color = vdgrey
#stroke_color = black
#stroke_thickness = 1p
</linkparam>

# If you are using color_autoremap=yes above, then
# define the percentile sampling window and
# the start/end HSV color values. Percentile window
# colors are interpolated between this HSV pair.
#
# HSV = (hue saturation value)
# hue=(0..360) saturation=(0..1) value=(0..1)

percentile_sampling = 5

# count - percentile based on counts
# value - percentile based on value

percentile_method = count

# use all values or only unique values when
# calculating percentiles
percentile_unique_only = yes

# use a function, f(X), to remap cell values when calculating percentiles
# for the purpose of color mapping. This allows you to apply a remapping to how
# colors are calculated, without actually changing the values. The remap
# applies only if percentile_method=value

# percentile_remap = sqrt(X)

# Which cell value set to use for percentile color mapping
# raw - original values
# filtered - values that pass min/max filters
# scaled - filtered values that have been scaled if use_scaling is set
percentile_data_domain = raw

<colors>
h0 = 0
s0 = 1
v0 = 1
h1 = 300
s1 = 1
v1 = 1
</colors>

# You can control the color and stroke of ribbons for each
# quartile (q1, q2, q3, q4). Any values defined here will
# overwrite colors determined by remapping.
#
# For example, if you have a lot of cells and wish to attenuate
# the visibility of ribbons associated with small values, you can
# set cell_q1_color=vvlgrey,cell_q1_nostroke=yes to fade the
# ribbons into the background.

#cell_q1_color    = vvlgrey
#cell_q2_color    = vlgrey
#cell_q3_color    = lgrey
#cell_q4_color    = red
#cell_q1_nostroke = yes
#cell_q2_nostroke = yes
#cell_q3_nostroke = yes
#cell_q4_nostroke = yes

# cell value multiplier, required when all data is small (e.g. <1), in which
# case set the multiplier to something like 1000 because Circos
# works only with integer scales

data_mult = 1

################################################################
# Segment labels can be optionally set to a size that is
# proportional to the size of the segment. Set min/max size
# values here. If this line is commented out, then the label
# size is determined by the circos.conf file used to draw the image

#segment_label_size_range       = 60,60

# progression controls how fast the label size changes from
# min to max (larger value of progression means values close to max
# are achieved for smaller segments)

segment_label_size_progression = 4

segment_label_uppercase = no

################################################################
# Segment colors can be specified in the data file (in this
# case use row_color_col and col_color_row), otherwise colors
# are interpolated within an HSV range. Color interpolation can be
# done in two ways: based on segment index (interpolation steps through
# colors uniformly for each segment) and total size (interpolation
# steps through colors in proportion to segment size).

<segment_colors>
interpolate_type = size # size or count
h0 = 0
s0 = 0.8
v0 = 0.9
h1 = 300
s1 = 0.8
v1 = 0.9
</segment_colors>

################################################################
# Shorten the labels of segments. Specify whether to do this
# with shorten_text=yes|no parameter and provide regular
# expressions in string_replace which define the text to
# replace.

shorten_text = no

<string_replace>
chromosome = chr
</string_replace>

# exit on any error
strict_sanity = yes

################################################################
# if the segment_prefix is set, then rows and columns will be
# renamed to internal fields segment_prefix + DIGIT

#segment_prefix  = id
color_prefix = color

# field delimiter regular expression
# if this is not defined, any whitespace will be considered a delimiter
field_delim = \s

# collapse adjacent delimiters?
field_delim_collapse = yes

# remove any leading space in the input file
# by default, this is on - if you set this to "no", make sure that you don't have any leading spaces in your table!
strip_leading_space = yes

# remove quotes and thousand separators - concatenate characters to remove
#
# e.g. to remove characters a b c set remove_cell_rx=abc
# e.g. to remove characters " ' , set remove_cell_rx="',
remove_cell_rx = "',

]]></configfile>
        <configfile name="circos_conf"><![CDATA[
#def circosColor($value)
    #set $value = str($value)
    #set $r = int($value[1:3], 16)
    #set $g = int($value[3:5], 16)
    #set $b = int($value[5:], 16)
    $r, $g, $b
#end def

# This is the main configuration file for the Circos tableviewer. This
# file also depends on colors.conf (definition on basic colors),
# ideogram.conf (size and spacing of row/cell segments), and
# ticks.conf (tick spacing and label definitions - these are turned
# off by default).
#
# In addition to these configuration files, the bin/make-conf script
# creates colors.conf (colors of row/col segments) and
# colors_percentile.conf (colors based on cell percentile
# values). These configuration files are also included via the
# <<include>> directive.
#
# Some elements of the output image are toggled off by default
# (e.g. row and column highlights, anchor links to segment labels,
# tick marks).

<colors>
<<include data/colors.conf>>
<<include data/colors_percentile.conf>>
</colors>

<ideogram>
    <spacing>
    default = 0.010r
    </spacing>

    thickness        = 25p
    stroke_thickness = 2
    stroke_color     = vdgrey
    fill             = yes
    fill_color       = $circosColor($labels.segment.color)

    # fractional radius position of chromosome ideogram within image
    radius         = 0.70r
    show_label     = $labels.segment.show
    label_font     = $labels.segment.font
    label_radius   = dims(image,radius) - 50p
    label_size     = $labels.segment.size
    label_parallel = $labels.segment.parallel

    show_bands     = no
</ideogram>

show_ticks          = yes
show_tick_labels    = $labels.ticks.show

<ticks>
    skip_first_label = no
    skip_last_label  = no
    radius           = dims(ideogram,radius_outer)
    size             = 12p
    label_font       = $labels.ticks.font
    label_size       = $labels.ticks.size
    label_offset     = 5p
    format           = %d
    color            = $circosColor($labels.ticks.color)
    thickness        = 2p

    <tick>
    spacing_type   = relative
    rspacing       = 0.1
    show_label     = yes
    label_relative = yes
    label_size     = 20p
    suffix         = %
    rmultiplier    = 100
    offset         = 100p
    </tick>

    <tick>
    spacing_type   = relative
    rspacing       = 0.02
    show_label     = no
    offset         = 100p
    </tick>

    <tick>
    spacing        = 10u
    show_label     = yes
    </tick>

    <tick>
    spacing        = 1u
    show_label     = no
    </tick>
</ticks>

karyotype = data/karyotype.txt

<image>
    <<include etc/image.conf>>
</image>

chromosomes_units              = 10
chromosomes_display_default    = yes
chromosomes_order_by_karyotype = yes

<highlights>
    stroke_color     = vdgrey
    stroke_thickness = 1

    <highlight>
    show = yes
    file = data/row.txt
    r0   = 1r+300p
    r1   = 1r+310p
    </highlight>

    <highlight>
    show = yes
    file = data/col.txt
    r1   = 1r+330p
    r0   = 1r+320p
    </highlight>

    <highlight>
    show = yes
    file = data/all.txt
    r1   = 1r+280p
    r0   = 1r+260p
    </highlight>

    <highlight>
    file = data/cap.col.txt
    r1   = 0.999r-10p
    r0   = 0.999r-30p
    </highlight>

    <highlight>
    file = data/cap.row.txt
    r1   = 0.999r
    r0   = 0.999r-20p
    </highlight>
</highlights>

<links>
    <link>
        ribbon           = yes
        flat             = yes
        file             = data/cells.txt
        bezier_radius    = 0.0r
        radius           = 0.999r-30p
        thickness        = 1
        color            = grey
        stroke_color     = dgrey
        stroke_thickness = 1

        <rules>
            <rule>
                condition  = 1
                radius1    = 0.999r-20p
            </rule>
        </rules>
    </link>
</links>

<<include etc/colors_fonts_patterns.conf>>
<<include etc/housekeeping.conf>>
max_ticks*            = ${limits.max_ticks}
max_ideograms*        = ${limits.max_ideograms}
max_links*            = ${limits.max_links}
max_points_per_track* = ${limits.max_points_per_track}
]]></configfile>
    </configfiles>
    <inputs>
        <param name="table" type="data" format="tabular" label="Input table"/>
        <section name="outputs" title="Outputs" expanded="true">
            <param name="png" type="boolean" truevalue="yes" falsevalue="no" label="Output PNG" checked="true"/>
            <param name="svg" type="boolean" truevalue="yes" falsevalue="no" label="Output SVG" checked="false"/>
            <param name="tar" type="boolean" truevalue="yes" falsevalue="no" label="Output Configuration Archive" checked="false"/>
        </section>

        <section name="labels" title="Ticks &amp; Labels" expanded="false">
            <section name="segment" title="Segment Labels" expanded="true">
                <param name="show" type="boolean" truevalue="yes" falsevalue="no" label="Show label" checked="true" />
                <param name="parallel" type="boolean" truevalue="yes" falsevalue="no" label="Show parallel to rack" />
                <param type="integer" value="50" label="Font Size" name="size" />
                <expand macro="font_select" normal="false" bold="true" />
                <expand macro="circos_color" label="Color" name="color" value="#000000" />
            </section>
            <section name="ticks" title="Tick Labels" expanded="true">
                <param name="show" type="boolean" truevalue="yes" falsevalue="no" label="Show label" checked="true" />
                <param name="parallel" type="boolean" truevalue="yes" falsevalue="no" label="Show parallel to rack" />
                <param type="integer" value="24" label="Font Size" name="size" />
                <expand macro="font_select" normal="true"/>
                <expand macro="circos_color" label="Color" name="color" value="#000000" />
            </section>
        </section>

        <expand macro="limits" />
    </inputs>
    <outputs>
        <data name="output_png" format="png" from_work_dir="circos.png" label="Circos TableViewer Plot (PNG)">
            <filter>outputs['png']</filter>
        </data>
        <data name="output_svg" format="svg" from_work_dir="circos.svg" label="Circos TableViewer Plot (SVG)">
            <filter>outputs['svg']</filter>
        </data>
        <data name="output_tar" format="tar.gz" from_work_dir="circos.tar.gz" label="Circos TableViewer Conf Files">
            <filter>outputs['tar']</filter>
        </data>
    </outputs>
    <tests>
        <test>
            <param name="table" value="tableviewer/1.tab" ftype="tabular" />
            <output name="output_png" file="tableviewer/1.png" ftype="png" compare="sim_size" delta="90000" />
        </test>
        <test expect_failure="true">
            <param name="table" value="tableviewer/1.tab" ftype="tabular" />
            <section name="limits">
                <param name="max_ticks" value="1" />
                <param name="max_ideograms" value="1" />
                <param name="max_links" value="1" />
                <param name="max_points_per_track" value="1" />
            </section>
        </test>
    </tests>
    <help><![CDATA[
The `official documentation <http://mkweb.bcgsc.ca/tableviewer/docs/>`__ has a lot of useful information.

You should provide a table that looks like:

::

    labels	A	B	C
    A	10	15	20
    D	15	20	25
    E	20	30	50

The header column and row are strictly required.
    ]]></help>
    <expand macro="citations" />
</tool>