view correlation_matrix.xml @ 2:f0c8cdd78e28 draft

Uploaded
author sauria
date Thu, 27 Apr 2017 12:37:59 -0400
parents
children
line wrap: on
line source

<tool id="tableToCorrMatrix" name="Table to Correlation Matrix" version="1.0.0">
  <command interpreter="python">correlation_matrix.py ${corr} ${feature} ${row} ${column} ${int} ${input} ${out_file1}</command>
  <requirements>
      <requirement type='package' version="1.12.1">numpy</requirement>
      <requirement type='package' version="0.19.0">scipy</requirement>
      <yield/>
  </requirements>
  <inputs>
    <param format="tabular" name="input" type="data" label="Input Table" help="Dataset missing? See TIP below" />
    <param name="feature" type="select" label="Features are in">
      <option value="">Columns</option>
      <option value="-f">Rows</option>
    </param>    
    <param name="corr" type="select" label="Correlation Statistic">
      <option value="-t pearson">Pearson</option>
      <option value="-t spearman">Spearman</option>
      <option value="-t kendall">Kendall</option>
    </param>   
    <param name="row" type="select" label="Row names">
      <option value="-r">True</option>
      <option value="">False</option>
    </param>    
    <param name="column" type="select" label="Column names">
      <option value="-c">True</option>
      <option value="">False</option>
    </param>    
    <param name="int" type="select" label="Datatype">
      <option value="">Decimal</option>
      <option value="-i">Integer</option>
    </param>    
  </inputs>
  <outputs>
    <data format="input" name="out_file1" metadata_source="input"/>
  </outputs>
  <tests>
    <test>
      <param name="input" value="corr_test_data.txt"/>
      <param name="feature" value=""/>
      <param name="corr" value="pearson"/>
      <param name="row" value="-r"/>
      <param name="column" value="-c"/>
      <param name="int" value=""/>
      <output name="out_file1" file="pearson.txt"/>
    </test>
    <test>
      <param name="input" value="corr_test_data.txt"/>
      <param name="feature" value=""/>
      <param name="corr" value="spearman"/>
      <param name="row" value="-r"/>
      <param name="column" value="-c"/>
      <param name="int" value=""/>
      <output name="out_file1" file="spearman.txt"/>
    </test>
    <test>
      <param name="input" value="corr_test_data.txt"/>
      <param name="feature" value=""/>
      <param name="corr" value="kendall"/>
      <param name="row" value="-r"/>
      <param name="column" value="-c"/>
      <param name="int" value=""/>
      <output name="out_file1" file="kendall.txt"/>
    </test>
  </tests>
  <help>
.. class:: infomark 

**TIP:** If your data is not TAB or SPACE delimited, use *Text Manipulation-&gt;Convert* 

.. class:: warningmark 

This tool will not work with missing data ("nan").

----- 

**Syntax** 

This tool computes the matrix of correlation coefficients between each pairwise combination of samples across all features. 

- **Pearson's Correlation** reflects the degree of linear relationship between two variables. It ranges from +1 to -1. A correlation of +1 means that there is a perfect positive linear relationship between variables. The formula for Pearson's correlation is:

    .. image:: pearson.png 

    where n is the number of items 

- **Kendall's rank correlation** is used to measure the degree of correspondence between two rankings and assessing the significance of this correspondence. The formula for Kendall's rank correlation is:

    .. image:: kendall.png 

    where n is the number of items, and P is the sum. 

- **Spearman's rank correlation** assesses how well an arbitrary monotonic function could describe the relationship between two variables, without making any assumptions about the frequency distribution of the variables. The formula for Spearman's rank correlation is

    .. image:: spearman.png 

    where D is the difference between the ranks of corresponding values of X and Y, and N is the number of pairs of values. 

----- 

**Example** 

- Input file:: 

    Sample Feature1 Feature2 Feature3 Feature4 Feature5 Feature6
    A      -0.3019  1.6868   -2.5340  -4.9926  -2.1455  7.6550
    B      -0.5274  2.0816   -3.4161  -4.5812  -1.8705  6.9659
    C      -3.2619  0.0963   -1.0131  1.9299   -0.2277  -0.7781
    D      -1.9462  0.3685   -1.3830  1.1512   -0.1307  -0.3001
    E      -2.0360  -0.7261  -1.6089  1.0215   -0.1636  -1.6826
    F      -2.7152  0.8035   -1.7544  1.7193   -0.1782  -1.0745

- Computing the correlation coefficients between every pair of rows of the above file (using Pearson's Correlation), the output is:: 

    sample  A        B        C        D        E        F
    A       1.0000   0.9923   -0.3144  -0.1313  -0.5773  -0.2793
    B       0.9923   1.0000   -0.2575  -0.0462  -0.5011  -0.1915
    C       -0.3144  -0.2575  1.0000   0.9443   0.8916   0.9470
    D       -0.1313  -0.0462  0.9443   1.0000   0.8679   0.9793
    E       -0.5773  -0.5011  0.8916   0.8679   1.0000   0.9046
    F       -0.2793  -0.1915  0.9470   0.9793   0.9046   1.0000

  </help>
</tool>