Source code

Download source archive ↓

upstream-extended/devteam/tools/weightedaverage/WeightedAverage.xml

1<tool id="wtavg" name="Assign weighted-average" version="1.0.1">
2  <description> of the values of features overlapping an interval </description>
3  <requirements>
4    <requirement type="package" version="1.0.0">galaxy-ops</requirement>
5    <requirement type="package" version="0.7.1">bx-python</requirement>
6  </requirements>
7  <command interpreter="python">WeightedAverage.py  $genomic_interval $genomic_feature $out_file1 -1 ${genomic_interval.metadata.chromCol},${genomic_interval.metadata.startCol},${genomic_interval.metadata.endCol},${genomic_interval.metadata.strandCol} -2 ${genomic_feature.metadata.chromCol},${genomic_feature.metadata.startCol},${genomic_feature.metadata.endCol},${genomic_feature.metadata.strandCol},${genomic_feature.metadata.nameCol} ${allow_zeros}</command>
8
9  <inputs>
10    <param format="interval" name="genomic_interval" type="data" label="Genomic intervals (first dataset)" help="Dataset missing? See Note below."/>
11    <param format="interval" name="genomic_feature" label="Genomic features (second dataset)" type="data" help="Make sure the value column is specified. See Note below." />
12    <param name="allow_zeros" label="Include zeros in calculations" type="boolean" help="Otherwise, skip them as bad values" truevalue="--allow_zeros" falsevalue="" checked="True" />
13  </inputs>
14  <outputs>
15    <data format="input" name="out_file1" metadata_source="genomic_interval" />
16  </outputs>
17  <tests>
18    <!-- Test data with valid values -->
19    <test>
20      <param name="genomic_interval" value="interval_interpolate.bed"/>
21      <param name="genomic_feature" value="value_interpolate.bed"/>
22      <param name="allow_zeros" value="False" />
23      <output name="out_file1" file="interpolate_result.bed"/>
24    </test>
25    <test>
26      <param name="genomic_interval" value="interval_interpolate.bed"/>
27      <param name="genomic_feature" value="value_interpolate.bed"/>
28      <param name="allow_zeros" value="True" />
29      <output name="out_file1" file="interpolate_result_zeros.bed"/>
30    </test>
31  </tests>
32  <help>
33
34
35.. class:: infomark
36
37**What it does**
38
39For each interval in your first dataset, this tool calculates the weighted average value of the overlapping features in your second dataset.
40
41- When a genomic interval partially or totally overlaps a single genomic feature, the value of that genomic feature is assigned to the genomic interval.
42- When a genomic interval partially or totally overlaps with more than one genomic features, the average of the values of the overlapping genomic features weighted by the corresponding number of overlapping bases is assigned to the genomic interval.
43- When a genomic interval does not overlap with any genomic feature, 'NA' will be assigned as it's value.
44
45-----
46
47.. class:: warningmark
48
49**Note**
50
51The input datasets should be in **bed** or **interval** format. Please use "edit attributes"/pencil icon to specify the column containing the values for the features in the second dataset as **name/identifier** column.
52
53The output will contain all the columns in the first input plus a new column containing the assigned value for each interval.
54
55-----
56
57**Example**
58
59- Suppose our first dataset contains the following **genomic intervals**::
60    
61    chr  start stop
62    chr1 1000  2000
63    chr1 3000  5000
64    chr1 8000  9000
65  
66- and our second dataset contains the following **genomic features** each having an associated value (in fourth column) ::
67
68    chr  start stop name
69    chr1 900   1200 0.5
70    chr1 2900  3100 0.2
71    chr1 4800  5100 0.8
72  
73- For each **genomic interval** in our first dataset, this tool calculates the weighted average value of the overlapping **genomic features** in our second dataset ::
74
75    chr1 1000  2000 0.5
76    chr1 3000  5000 0.6
77    chr1 8000  9000 NA
78  
79
80
81</help>
82</tool>