17
|
1 <tool id="ballgown" name="Ballgown" version="2.2.0" workflow_compatible="true">
|
|
2 <description>Flexible, isoform-level differential expression analysis</description>
|
|
3 <requirements>
|
|
4 <requirement type="package" version="2.2.0">bioconductor-ballgown</requirement>
|
|
5 <requirement type="package" version="0.5.0">r-dplyr</requirement>
|
|
6 <requirement type="package" version="1.3.2">r-optparse</requirement>
|
|
7 </requirements>
|
|
8 <command detect_errors="aggressive"><![CDATA[
|
|
9 ##------------------------------------------------------------------------------------
|
|
10 ## This function reads the input file with the mapping between samples and files
|
|
11 ## E.g. of result:
|
|
12 ## mapping = {
|
|
13 ## "e2t.ctab" : "sample1",
|
|
14 ## "other.ctab" : "sample2",
|
|
15 ## "i2t.ctab" : "sample1",
|
|
16 ## "t_data.ctab": "sample1"
|
|
17 ## ...
|
|
18 ## }
|
|
19 ##------------------------------------------------------------------------------------
|
|
20 #def read_sample_mapping_file(sample_mapping_file):
|
|
21 #try
|
|
22 #set mapping = {}
|
|
23 #set file = open($sample_mapping_file.dataset.dataset.get_file_name(),'r')
|
|
24 #for $line in $file:
|
|
25 #set content= $line.strip().split('\t')
|
|
26 #for $map in $content:
|
|
27 #set mapping[$map]= $content[0]
|
|
28 #end for
|
|
29 #end for
|
|
30 #return $mapping
|
|
31 #except
|
|
32 #return None
|
|
33 #end try
|
|
34 #end def
|
|
35
|
|
36 ##------------------------------------------------------------------------------------
|
|
37 ## This function returns the name of the sample associated to a given file
|
|
38 ##------------------------------------------------------------------------------------
|
|
39 #def get_sample_name($dataset, $sample_mapping):
|
|
40 ##If the file with samples mapping was provided
|
|
41 #if $sample_mapping != None:
|
|
42 #return $sample_mapping.get($dataset.name, None)
|
|
43 ##Otherwise with extract the sample name from the filename
|
|
44 #else:
|
|
45 #return str($dataset.element_identifier)
|
|
46 #end if
|
|
47 #end def
|
|
48
|
|
49 ##------------------------------------------------------------------------------------
|
|
50 ## This function reads a dataset or list of datasets and sets the corresponding value
|
|
51 ## in the $result variable
|
|
52 ## e.g. of result
|
|
53 ##'sample1' : {
|
|
54 ## 'e_data': '/export/galaxy-central/database/files/000/dataset_13.dat'
|
|
55 ## 'i_data': '/export/galaxy-central/database/files/000/dataset_10.dat',
|
|
56 ## 't_data': '/export/galaxy-central/database/files/000/dataset_12.dat',
|
|
57 ## 'e2t': '/export/galaxy-central/database/files/000/dataset_9.dat',
|
|
58 ## 'i2t': '/export/galaxy-central/database/files/000/dataset_11.dat'
|
|
59 ## },
|
|
60 ##------------------------------------------------------------------------------------
|
|
61 #def read_input_files($param_name, $param_value, $result, $sample_mapping, $create_if_empty):
|
|
62 ## If input is a data collection
|
|
63 #if isinstance($param_value, list):
|
|
64 ## For each dataset
|
|
65 #for $dataset in $param_value:
|
|
66 ## Get the sample name
|
|
67 #set sample_name = $get_sample_name($dataset, $sample_mapping)
|
|
68 ## Check if sample is already registered
|
|
69 #if not($result.has_key($sample_name)):
|
|
70 #if ($create_if_empty == True):
|
|
71 #set result[$sample_name] = {}
|
|
72 #else:
|
|
73 #raise ValueError("Error in input. Please check that input contains all the required files for sample " + $sample_name)
|
|
74 #end if
|
|
75 #end if
|
|
76 ## Register the file to the sample
|
|
77 #set result[$sample_name][$param_name] = str($dataset.dataset.dataset.get_file_name())
|
|
78 #end for
|
|
79 #else:
|
|
80 #if not($result.has_key("sample_1")):
|
|
81 #set result["sample_1"] = {}
|
|
82 #end if
|
|
83 #set result["sample_1"][$param_name] = str($param_name.dataset.dataset.get_file_name())
|
|
84 #end if
|
|
85 #return $result
|
|
86 #end def
|
|
87
|
|
88 ##------------------------------------------------------------------------------------
|
|
89 ## Main body of the tool
|
|
90 ##------------------------------------------------------------------------------------
|
|
91 ## Set the params for the next R script
|
|
92 #set result={}
|
|
93 #set sample_mapping=None
|
|
94
|
|
95 ## If the samples mapping file was provided, parse the content
|
|
96 #if $samples_names != None and not(isinstance($samples_names, list) and (None in $samples_names)):
|
|
97 #set sample_mapping = $read_sample_mapping_file($samples_names)
|
|
98 #end if
|
|
99
|
|
100 ## READ THE CONTENT FOR e_data AND STORE THE FILES
|
|
101 ## INDEXED BY THEIR SAMPLE NAME
|
|
102 ## e.g. 'HBR_Rep1' : {
|
|
103 ## 'e_data': '/export/galaxy-central/database/files/000/dataset_13.dat'
|
|
104 ## 'i_data': '/export/galaxy-central/database/files/000/dataset_10.dat',
|
|
105 ## 't_data': '/export/galaxy-central/database/files/000/dataset_12.dat',
|
|
106 ## 'e2t': '/export/galaxy-central/database/files/000/dataset_9.dat',
|
|
107 ## 'i2t': '/export/galaxy-central/database/files/000/dataset_11.dat'
|
|
108 ## },
|
|
109 ## 'HBR_Rep2' : {...}
|
|
110 #set $result = $read_input_files("e_data.ctab", $e_data, $result, $sample_mapping, True)
|
|
111 #set $result = $read_input_files("i_data.ctab", $i_data, $result, $sample_mapping, False)
|
|
112 #set $result = $read_input_files("t_data.ctab", $t_data, $result, $sample_mapping, False)
|
|
113 #set $result = $read_input_files("e2t.ctab", $e2t, $result, $sample_mapping, False)
|
|
114 #set $result = $read_input_files("i2t.ctab", $i2t, $result, $sample_mapping, False)
|
|
115
|
|
116 ## For each input sample, create a directory and link the input files for ballgown
|
|
117 #import os
|
|
118 #set n_sample = 1
|
|
119 #for $key, $value in $result.iteritems():
|
|
120 #if str($file_format.format) == 'tsv':
|
|
121 #set dir_name = str($toutput.files_path) + '/' + $key + '/'
|
|
122 #else:
|
|
123 #set dir_name = str($output.files_path) + '/' + $key + '/'
|
|
124 #end if
|
|
125 $os.makedirs($dir_name)
|
|
126 #for $file_name, $file_path in $value.iteritems():
|
|
127 $os.symlink($file_path, $dir_name + $file_name)
|
|
128 #end for
|
|
129 #set n_sample = $n_sample + 1
|
|
130 #end for
|
|
131
|
|
132 ## Run the R script with the location of the linked files and the name for outpot file
|
|
133
|
|
134 Rscript '$__tool_directory__/ballgown.R' --texpression $trexpression --phendat '$phendata' --bgout '$bgo' -f '$file_format.format'
|
|
135 #if str($file_format.format) == 'tsv':
|
|
136 --tsvoutputtranscript $toutputtranscript
|
|
137 --tsvoutputgenes $toutput
|
|
138 --directory $toutput.files_path
|
|
139 #else:
|
|
140 --outputtranscript $output
|
|
141 --outputgenes $outputgn
|
|
142 --directory $output.files_path
|
|
143 #end if
|
|
144 ]]></command>
|
|
145 <inputs>
|
|
146 <param name="e_data" type="data_collection" collection_type="list" format="tabular" label="Exon-level expression measurements"
|
|
147 help="One row per exon. See below for more details."/>
|
|
148 <param name="i_data" type="data_collection" collection_type="list" format="tabular"
|
|
149 label="Intron- (i.e., junction-) level expression measurements"
|
|
150 help="One row per intron. See below for more details."/>
|
|
151 <param name="t_data" type="data_collection" collection_type="list" format="tabular"
|
|
152 label="Transcript-level expression measurements" help="One row per transcript. See below for more details."/>
|
|
153 <param name="e2t" type="data_collection" collection_type="list" format="tabular"
|
|
154 label="Exons-transcripts mapping"
|
|
155 help="Table with two columns, e_id and t_id, denoting which exons belong to which transcripts. See below for more details."/>
|
|
156 <param name="i2t" type="data_collection" collection_type="list" format="tabular"
|
|
157 label="Introns-transcripts mapping"
|
|
158 help="Table with two columns, i_id and t_id, denoting which introns belong to which transcripts. See below for more details."/>
|
|
159 <param name="samples_names" type="data" optional="true" multiple="false" format="tabular"
|
|
160 label="File names for samples"
|
|
161 help="Optional. Use in case that the names for the analysed samples cannot be extracted from the filenames."/>
|
|
162 <param argument="--phendat" name="phendata" type="data" format="csv" label="phenotype data" />
|
|
163 <param argument="--texpression" name="trexpression" type="float" value="0.5" label="minimal transcript expression to appear in the results"/>
|
|
164 <conditional name="file_format">
|
|
165 <param argument='--format' type="select" label="Output format">
|
|
166 <option value="tsv" selected="true">tsv</option>
|
|
167 <option value="csv">csv</option>
|
|
168 </param>
|
|
169 <when value="tsv"/>
|
|
170 <when value="csv"/>
|
|
171 </conditional>
|
|
172 </inputs>
|
|
173 <outputs>
|
|
174 <data name="bgo" format="rdata" from_work_dir="ballgown_object.rda" label="${tool.name} on ${on_string}: ballgown_object_R_data_file"/>
|
|
175 <data name="output" format="csv" from_work_dir="output_transcript.csv" label="${tool.name} on ${on_string}: transcripts_expression_tabular">
|
|
176 <filter>file_format['format']=="csv"</filter>
|
|
177 </data>
|
|
178 <data name="outputgn" format="csv" from_work_dir="output_genes.csv" label="${tool.name} on ${on_string}: genes_expression_tabular">
|
|
179 <filter>file_format['format']=="csv"</filter>
|
|
180 </data>
|
|
181 <data name="toutputtranscript" format="tabular" from_work_dir="output_transcript.tsv" label="${tool.name} on ${on_string}: transcripts_expression_tabular">
|
|
182 <filter>file_format['format']=="tsv"</filter>
|
|
183 </data>
|
|
184 <data name="toutput" format="tabular" from_work_dir="output_genes.tsv" label="${tool.name} on ${on_string}: genes_expression_tabular">
|
|
185 <filter>file_format['format']=="tsv"</filter>
|
|
186 </data>
|
|
187 </outputs>
|
|
188 <tests>
|
|
189 <test>
|
|
190 <param name="e_data">
|
|
191 <collection type="list">
|
|
192 <element name="HBR_Rep1" value="HBR_Rep1/e_data.ctab"/>
|
|
193 <element name="HBR_Rep2" value="HBR_Rep2/e_data.ctab"/>
|
|
194 <element name="HBR_Rep3" value="HBR_Rep3/e_data.ctab"/>
|
|
195 <element name="UHR_Rep1" value="UHR_Rep1/e_data.ctab"/>
|
|
196 <element name="UHR_Rep2" value="UHR_Rep2/e_data.ctab"/>
|
|
197 <element name="UHR_Rep3" value="UHR_Rep3/e_data.ctab"/>
|
|
198 </collection>
|
|
199 </param>
|
|
200 <param name="i_data">
|
|
201 <collection type="list">
|
|
202 <element name="HBR_Rep1" value="HBR_Rep1/i_data.ctab"/>
|
|
203 <element name="HBR_Rep2" value="HBR_Rep2/i_data.ctab"/>
|
|
204 <element name="HBR_Rep3" value="HBR_Rep3/i_data.ctab"/>
|
|
205 <element name="UHR_Rep1" value="UHR_Rep1/i_data.ctab"/>
|
|
206 <element name="UHR_Rep2" value="UHR_Rep2/i_data.ctab"/>
|
|
207 <element name="UHR_Rep3" value="UHR_Rep3/i_data.ctab"/>
|
|
208 </collection>
|
|
209 </param>
|
|
210 <param name="t_data">
|
|
211 <collection type="list">
|
|
212 <element name="HBR_Rep1" value="HBR_Rep1/t_data.ctab"/>
|
|
213 <element name="HBR_Rep2" value="HBR_Rep2/t_data.ctab"/>
|
|
214 <element name="HBR_Rep3" value="HBR_Rep3/t_data.ctab"/>
|
|
215 <element name="UHR_Rep1" value="UHR_Rep1/t_data.ctab"/>
|
|
216 <element name="UHR_Rep2" value="UHR_Rep2/t_data.ctab"/>
|
|
217 <element name="UHR_Rep3" value="UHR_Rep3/t_data.ctab"/>
|
|
218 </collection>
|
|
219 </param>
|
|
220 <param name="e2t">
|
|
221 <collection type="list">
|
|
222 <element name="HBR_Rep1" value="HBR_Rep1/e2t.ctab"/>
|
|
223 <element name="HBR_Rep2" value="HBR_Rep2/e2t.ctab"/>
|
|
224 <element name="HBR_Rep3" value="HBR_Rep3/e2t.ctab"/>
|
|
225 <element name="UHR_Rep1" value="UHR_Rep1/e2t.ctab"/>
|
|
226 <element name="UHR_Rep2" value="UHR_Rep2/e2t.ctab"/>
|
|
227 <element name="UHR_Rep3" value="UHR_Rep3/e2t.ctab"/>
|
|
228 </collection>
|
|
229 </param>
|
|
230 <param name="i2t">
|
|
231 <collection type="list">
|
|
232 <element name="HBR_Rep1" value="HBR_Rep1/i2t.ctab"/>
|
|
233 <element name="HBR_Rep2" value="HBR_Rep2/i2t.ctab"/>
|
|
234 <element name="HBR_Rep3" value="HBR_Rep3/i2t.ctab"/>
|
|
235 <element name="UHR_Rep1" value="UHR_Rep1/i2t.ctab"/>
|
|
236 <element name="UHR_Rep2" value="UHR_Rep2/i2t.ctab"/>
|
|
237 <element name="UHR_Rep3" value="UHR_Rep3/i2t.ctab"/>
|
|
238 </collection>
|
|
239 </param>
|
|
240 <param name="phendata" value="phendata.csv"/>
|
|
241 <output name="outputgn" file="genes_expression_tabular.csv"/>
|
|
242 <output name="output" file="transcripts_expression_tabular.csv"/>
|
|
243 <output name="bgo" file="ballgown_object_R_data_file.rda"/>
|
|
244 </test>
|
|
245 </tests>
|
|
246 <help><![CDATA[
|
|
247 =======================
|
|
248 Ballgown
|
|
249 =======================
|
|
250 -----------------------
|
|
251 **What it does**
|
|
252 -----------------------
|
|
253
|
|
254 Ballgown is a software package designed to facilitate flexible differential expression analysis of RNA-seq data.
|
|
255 The Ballgown package provides functions to organize, visualize, and analyze the expression measurements for your transcriptome assembly.
|
|
256
|
|
257 ----
|
|
258
|
|
259 -----------------------
|
|
260 **How to use**
|
|
261 -----------------------
|
|
262 The input for this tools consists on 5 files for each sample in your experiment:
|
|
263
|
|
264 - **e_data**: exon-level expression measurements. Tab file or collection of tab files. One row per exon. Columns are e_id (numeric exon id), chr, strand, start, end (genomic location of the exon), and the following expression measurements for each sample:
|
|
265 * rcount: reads overlapping the exon
|
|
266 * ucount: uniquely mapped reads overlapping the exon
|
|
267 * mrcount: multi-map-corrected number of reads overlapping the exon
|
|
268 * cov average per-base read coverage
|
|
269 * cov_sd: standard deviation of per-base read coverage
|
|
270 * mcov: multi-map-corrected average per-base read coverage
|
|
271 * mcov_sd: standard deviation of multi-map-corrected per-base coverage
|
|
272 - **i_data**: intron- (i.e., junction-) level expression measurements. Tab file or collection of tab files. One row per intron. Columns are i_id (numeric intron id), chr, strand, start, end (genomic location of the intron), and the following expression measurements for each sample:
|
|
273 * rcount: number of reads supporting the intron
|
|
274 * ucount: number of uniquely mapped reads supporting the intron
|
|
275 * mrcount: multi-map-corrected number of reads supporting the intron
|
|
276 - **t_data**: transcript-level expression measurements. Tab file or collection of tab files. One row per transcript. Columns are:
|
|
277 * t_id: numeric transcript id
|
|
278 * chr, strand, start, end: genomic location of the transcript
|
|
279 * t_name: Cufflinks-generated transcript id
|
|
280 * num_exons: number of exons comprising the transcript
|
|
281 * length: transcript length, including both exons and introns
|
|
282 * gene_id: gene the transcript belongs to
|
|
283 * gene_name: HUGO gene name for the transcript, if known
|
|
284 * cov: per-base coverage for the transcript (available for each sample)
|
|
285 * FPKM: Cufflinks-estimated FPKM for the transcript (available for each sample)
|
|
286 - **e2t**: Tab file or collection of tab files. Table with two columns, e_id and t_id, denoting which exons belong to which transcripts. These ids match the ids in the e_data and t_data tables.
|
|
287 - **i2t**: Tab file or collection of tab files. Table with two columns, i_id and t_id, denoting which introns belong to which transcripts. These ids match the ids in the i_data and t_data tables.
|
|
288 - samples_names: (optional) Tab file. Table with five columns, one row per sample. Defines which files from the input belong to each sample in the experiment.
|
|
289
|
|
290 .. class:: infomark
|
|
291
|
|
292 '''TIP''' *Note* Here's an example of a good phenotype data file for your experiment.
|
|
293
|
|
294 +--------------+-------------------------+-------------------------+---+
|
|
295 |ids |experimental variable 1 |experimental variable 2 |...|
|
|
296 +==============+=========================+=========================+===+
|
|
297 |sample 1 |value 1 |value 2 |...|
|
|
298 +--------------+-------------------------+-------------------------+---+
|
|
299 |sample 2 |value 2 |value 1 |...|
|
|
300 +--------------+-------------------------+-------------------------+---+
|
|
301 |sample 3 |value 1 |value 2 |...|
|
|
302 +--------------+-------------------------+-------------------------+---+
|
|
303 |sample 4 |value 2 |value 1 |...|
|
|
304 +--------------+-------------------------+-------------------------+---+
|
|
305 |... |value 1 |value 2 |...|
|
|
306 +--------------+-------------------------+-------------------------+---+
|
|
307
|
|
308
|
|
309 .. class:: infomark
|
|
310
|
|
311 *Note* The minimal transcript expression is a number used to filter the transcripts that
|
|
312 are less or not expressed in our samples when compared to the genome
|
|
313
|
|
314 -----------------------
|
|
315 **Outputs**
|
|
316 -----------------------
|
|
317
|
|
318 This tool has 3 outputs:
|
|
319
|
|
320 - **transcripts expression** : this is a csv file containing all the transcripts that are expressed above the transcripts expression value
|
|
321 - **genes expression** : this is a csv file containing all the genes that are expressed above the transcripts expression value
|
|
322 - **Ballgown object** : this is the ballgown object created during the process. This file can be re-used later for further analysis in a R console.
|
|
323
|
|
324 ----
|
|
325
|
|
326 **Authors**: Théo Collard [SLU Global Bioinformatics Centre], Rafael Hernández de Diego [SLU Global Bioinformatics Centre], and Tomas Klingström [SLU Global Bioinformatics Centre]
|
|
327 ]]></help>
|
|
328 <citations>
|
|
329 <citation type="doi">doi:10.1038/nprot.2016.095</citation>
|
|
330 </citations>
|
|
331 </tool>
|