view tools/stats/cor.xml @ 1:cdcb0ce84a1b

Uploaded
author xuebing
date Fri, 09 Mar 2012 19:45:15 -0500
parents 9071e359b9a3
children
line wrap: on
line source

<tool id="cor2" name="Correlation">
  <description>for numeric columns</description>
  <command interpreter="python">cor.py $input1 $out_file1 $numeric_columns $method</command>
  <inputs>
    <param format="tabular" name="input1" type="data" label="Dataset" help="Dataset missing? See TIP below"/>
    <param name="numeric_columns" label="Numerical columns" type="data_column" numerical="True" multiple="True" data_ref="input1" help="Multi-select list - hold the appropriate key while clicking to select multiple columns" />
    <param name="method" type="select" label="Method">
      <option value="pearson">Pearson</option>
      <option value="kendall">Kendall rank</option>
      <option value="spearman">Spearman rank</option>
    </param>
  </inputs>
  <outputs>
    <data format="txt" name="out_file1" />
  </outputs>
  <requirements>
    <requirement type="python-module">rpy</requirement>
  </requirements>
  <tests>
    <!--
    Test a tabular input with the first line being a comment without a # character to start
    -->
    <test>
      <param name="input1" value="cor.tabular" />
      <param name="numeric_columns" value="2,3" />
      <param name="method" value="pearson" />
      <output name="out_file1" file="cor_out.txt" />
    </test>
  </tests>
  <help>

.. class:: infomark

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

.. class:: warningmark

Missing data ("nan") removed from each pairwise comparison

-----

**Syntax**

This tool computes the matrix of correlation coefficients between numeric columns.

- All invalid, blank and comment lines are skipped when performing computations.  The number of skipped lines is displayed in the resulting history item.

- **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:: ./static/images/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:: ./static/images/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:: ./static/images/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::

    #Person	Height	Self Esteem
    1		68		4.1
    2 		71 		4.6
    3 		62 		3.8
    4 		75 		4.4
    5 		58 		3.2
    6 		60 		3.1
    7 		67 		3.8
    8 		68 		4.1
    9 		71 		4.3
    10 		69 		3.7
    11 		68 		3.5
    12 		67 		3.2
    13 		63 		3.7
    14 		62 		3.3
    15 		60 		3.4
    16 		63 		4.0
    17 		65 		4.1
    18 		67 		3.8
    19 		63 		3.4
    20 		61 		3.6

- Computing the correlation coefficients between columns 2 and 3 of the above file (using Pearson's Correlation), the output is::

    1.0	0.730635686279
    0.730635686279	1.0

  So the correlation for our twenty cases is .73, which is a fairly strong positive relationship.
  </help>
</tool>