<tool id="expressions" name="TEA" version="1.0.0">
  <description>Tiling Expression Analizer</description>
  <command interpreter="perl">calcolo_p_v4_norm_intron.pl -opt ${ann_choice.type1} -log ${ann_choice.type_data} -ann ${ann_choice.ann} -wt ${ann_choice.wt} -treat ${ann_choice.treat} -out $output -fdr ${ann_choice.fdr} -pv ${ann_choice.pv} -norm ${ann_choice.norm} -rc ${ann_choice.rc} -fc ${ann_choice.summary_choice.fc} -exon ${ann_choice.type} -sum_met ${ann_choice.summary_choice.fc_output}</command>
  <inputs>
  <conditional name="ann_choice">
   	<param name="type1" type="select" label="Analysis type">
   	  <option value="comp">comparison</option>
   	  <option value="expr">expression</option>
  	</param>
  	
    <when value="comp">
   	   	<param format="tabular" name="ann" type="data" label="annotation file"/>
    	<param format="tabular" name="wt" type="data" label="expression chip condition A"/>
    	<param format="tabular" name="treat" type="data" label="expression chip condition B"/>
    	<param name="type_data" type="select" label="Data type">
      		<option value="log">log2 value</option>
   			<option value="no_log">raw value</option>
      	</param>
    	<param name="norm" type="select" label="Normalization">
      		<option value="yes">quantile-normalization</option>
   			<option value="no">no normalization</option>
      	</param>
      	<param name="type" type="select" label="probes selection">
      		<option value="internal_exon">internal exon</option>
      		<option value="all_exon">all exon</option>
      		<option value="last_exon">last exon</option>
     	</param>
     	<conditional name="summary_choice">
     		<param name="fc_output" type="select" label="summary method">
     			<option value="mean">mean</option>
      			<option value="median">median</option>
      			<option value="both">both</option>
      		</param>
      		 <when value="mean">
      		 	<param name="fc" size="3" type="text" value="1.5" label="Fold change cutoff"/>
      		 </when>
      		 <when value="median">
      		 	<param name="fc" size="3" type="text" value="1.5" label="Fold change cutoff"/>
      		 </when>
      		 <when value="both">
      		 	<param name="fc" size="12" type="text" value="NOT-NEEDED" label="Fold change cutoff"/>
      		 </when>
      	</conditional>	 
    	<param name="rc" size="2" type="text" value="7" label="raw value cutoff (log2)"/>
    	<param name="fdr" type="select" label="FDR correction">
      		<option value="yes">yes</option>
      		<option value="no">no</option>
      	</param>	
    	<param name="pv" size="4" type="text" value="0.05" label="p-value cutoff"/>
    	
   		
   		
   	</when>	
   	  	<when value="expr">
   	  			 	<param format="tabular" name="ann" type="data" label="annotation file"/>
    				<param format="tabular" name="wt" type="data" label="expression chip"/>
    				<param format="tabular" name="treat" type="data" label="NOT NEEDED"/>
    				<param name="type_data" type="select" label="Data type">
      					<option value="log">log2 value</option>
   						<option value="no_log">raw value</option>
      				</param>
    				<param name="type" type="select" label="probes selection">
      					<option value="internal_exon">internal exon</option>
      					<option value="all_exon">all exon</option>
      					<option value="last_exon">last exon</option>
     				</param>
     				<conditional name="summary_choice">
     					<param name="fc_output" type="select" label="summary method">
     						<option value="mean">mean</option>
      						<option value="median">median</option>
      						<option value="both">both</option>
      					</param>
      				 	 <when value="mean">
      					 	<param name="fc" size="12" type="text" value="NOT-NEEDED" label="Fold change cutoff"/>
     			 		 </when>
     			 		 <when value="median">
      					 	<param name="fc" size="12" type="text" value="NOT-NEEDED" label="Fold change cutoff"/>
     			 		 </when>
     			 		 <when value="both">
      					 	<param name="fc" size="12" type="text" value="NOT-NEEDED" label="Fold change cutoff"/>
      					 </when>
     			 	</conditional>
     				<param name="norm" size="12" type="text" value="NOT-NEEDED" label="Normalization"/>
    				<param name="pv" size="12" type="text" value="NOT-NEEDED" label="p-value cutoff"/>
    				<param name="fdr" size="12" type="text" value="NOT-NEEDED" label="FDR correction"/>
    				<param name="rc" size="12" type="text" value="NOT-NEEDED" label="raw value cutoff (log2)"/>   
   		</when>
   	</conditional>
      
  
  </inputs>
  <outputs>
    <data format="tabular" name="output" />
  </outputs>

  <help>
 .. class:: infomark

**What it does**

TEA utilizes NimbleGen expression files in gff format and annotated table by ENO as INPUT FILES and generates a table with the expression value. When comparing two different conditions a Fold Change and a p-value are calculated.

PLEASE, for more detailed information refer to the CARPET user Manual:
click to download_ it.

.. _download: /static/example_file/CARPET_userManual.zip

--------

**Parameters:**

- **Analysis type:** 
                     - **expression** analysis calculates an expression value for each transcript coming from the mean or the median of all matching probes
                     - **comparison** analysis calculate an expression value for each transcript in both conditions, then calculates a Fold Change for each transcript and a p-value based on t-Test distribution. 
- **Data type:** 
    - **log2 value:** the data is not converted in log2
    - **raw value:** the data is converted in log2
- **Normalization:** quantile normalization between the two chips (not necessary if analysis type is "expression")
- **probe selection:** 
	- **internal exon:** only probes annotated as exons are used to calculate expression value.
	- **all exon:** also probes annotated at the boundaries of introns/exons are used to calculate the expression value. (probes in intronexon position usually have lower signal)
	- **last exon:** only probes in the last exon are used to calculate expression value. This analysis can be preferred for cDNA generated by oligo-dT RT, since 3' of transcripts are generally better represented.
- **summary method:** 
	- **mean:** fold change for each gene is calculated based on the mean value
	- **median:** fold change for each gene is calculated based on the median value
	- **both:** both are used
- **Fold change cutoff:** only transcripts with FC higher than cutoff are kept 
- **FDR:**
	- **yes:** False Discovery Rate correction is applied (as described in Storie et al. 2002)
	- **no:** No correction --> raw p-value
- **p-value cutoff:** only transcripts with p-value less than cutoff are kept 
- **raw value cutoff (log2):** only transcripts with raw value higher than cutoff at least in one experiment are kept 

--------


**INPUT FILE**

Nimblegen gives you back a GFF file with the coordinates of each probe and the signal raw value.

Click here_ to download a GFF file example.

.. _here: /static/example_file/Expression_analysis_files.zip


Example of Nimblegen Expression GFF format::

    chr19  Nimblegen  tiling_array  100000  1000051  20459	 +   .  probe_name
    chr19  Nimblegen  tiling_array  100100  1000151   1394	 +   .  probe_name

.. class:: warningmark

The sixth column **must** contain the raw signal (**NOT** log2) that Nimblegen gives you back after the experiment

The annotation table **MUST** be created usign ENO tool, before running TEA.

---------

.. class:: infomark

**How does it work?**

For each gene is built the signal distibution of the probes matching Exon.

-In an expression experiment, the mean or the median of the distribution represents the result of Tea.

-In a comparison experiment the distibution of the gene exon signal is compared between the two conditions (1 and 2) and a t-test is performed with the possibility to introduce FDR correction.

.. image:: static/images/CARPET/Tea.png




**OUTPUT**

- **expresion**

.. image:: static/images/CARPET/expression.png

- **comparison**

.. image:: static/images/CARPET/comparison.png

 </help>
  

</tool>
