Mercurial > repos > fubar > toolfactory
annotate old.xml @ 34:c6fdf2c6d0f4 draft
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
author | fubar |
---|---|
date | Thu, 28 Aug 2014 02:33:05 -0400 |
parents | |
children |
rev | line source |
---|---|
34
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
1 <tool id="rgedgeRpaired" name="edgeR" version="0.20"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
2 <description>1 or 2 level models for count data</description> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
3 <requirements> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
4 <requirement type="package" version="2.12">biocbasics</requirement> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
5 <requirement type="package" version="3.0.1">package_r3</requirement> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
6 </requirements> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
7 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
8 <command interpreter="python"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
9 rgToolFactory.py --script_path "$runme" --interpreter "Rscript" --tool_name "edgeR" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
10 --output_dir "$html_file.files_path" --output_html "$html_file" --output_tab "$outtab" --make_HTML "yes" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
11 </command> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
12 <inputs> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
13 <param name="input1" type="data" format="tabular" label="Select an input matrix - rows are contigs, columns are counts for each sample" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
14 help="Use the HTSeq based count matrix preparation tool to create these matrices from BAM/SAM files and a GTF file of genomic features"/> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
15 <param name="title" type="text" value="edgeR" size="80" label="Title for job outputs" help="Supply a meaningful name here to remind you what the outputs contain"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
16 <sanitizer invalid_char=""> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
17 <valid initial="string.letters,string.digits"><add value="_" /> </valid> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
18 </sanitizer> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
19 </param> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
20 <param name="treatment_name" type="text" value="Treatment" size="50" label="Treatment Name"/> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
21 <param name="Treat_cols" label="Select columns containing treatment." type="data_column" data_ref="input1" numerical="True" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
22 multiple="true" use_header_names="true" size="120" display="checkboxes"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
23 <validator type="no_options" message="Please select at least one column."/> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
24 </param> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
25 <param name="control_name" type="text" value="Control" size="50" label="Control Name"/> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
26 <param name="Control_cols" label="Select columns containing control." type="data_column" data_ref="input1" numerical="True" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
27 multiple="true" use_header_names="true" size="120" display="checkboxes" optional="true"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
28 </param> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
29 <param name="subjectids" type="text" optional="true" size="120" value = "" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
30 label="IF SUBJECTS NOT ALL INDEPENDENT! Enter integers to indicate sample pairing for every column in input" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
31 help="Leave blank if no pairing, but eg if data from sample id A99 is in columns 2,4 and id C21 is in 3,5 then enter '1,2,1,2'"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
32 <sanitizer> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
33 <valid initial="string.digits"><add value="," /> </valid> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
34 </sanitizer> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
35 </param> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
36 <param name="fQ" type="float" value="0.3" size="5" label="Non-differential contig count quantile threshold - zero to analyze all non-zero read count contigs" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
37 help="May be a good or a bad idea depending on the biology and the question. EG 0.3 = sparsest 30% of contigs with at least one read are removed before analysis"/> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
38 <param name="useNDF" type="boolean" truevalue="T" falsevalue="F" checked="false" size="1" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
39 label="Non differential filter - remove contigs below a threshold (1 per million) for half or more samples" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
40 help="May be a good or a bad idea depending on the biology and the question. This was the old default. Quantile based is available as an alternative"/> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
41 <conditional name="DESeq"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
42 <param name="doDESeq" type="select" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
43 label="Run the same model with DESeq2 and compare findings" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
44 help="DESeq2 is an update to the DESeq package. It uses different assumptions and methods to edgeR"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
45 <option value="F" selected="true">Do not run DESeq2</option> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
46 <option value="T">Run DESeq2 (only works if NO second GLM factor supplied at present)</option> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
47 </param> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
48 <when value="T"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
49 <param name="DESeq_fitType" type="select"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
50 <option value="parametric" selected="true">Parametric (default) fit for dispersions</option> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
51 <option value="local">Local fit - use this if parametric fails</option> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
52 <option value="mean">Mean dispersion fit- use this if you really understand what you're doing - read the fine manual</option> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
53 </param> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
54 </when> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
55 <when value="F"> </when> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
56 </conditional> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
57 <param name="doVoom" type="boolean" truevalue="T" checked='false' falsevalue="F" size="1" label="Run the same model with VOOM transformation and limma."/> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
58 <conditional name="camera"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
59 <param name="doCamera" type="select" label="Run the edgeR implementation of Camera GSEA for up/down gene sets" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
60 help="If yes, you can choose a set of genesets to test and/or supply a gmt format geneset collection from your history"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
61 <option value="F" selected="true">Do not run GSEA tests with the Camera algorithm</option> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
62 <option value="T">Run GSEA tests with the Camera algorithm</option> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
63 </param> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
64 <when value="T"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
65 <conditional name="gmtSource"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
66 <param name="refgmtSource" type="select" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
67 label="Use a gene set (.gmt) from your history and/or use a built-in (MSigDB etc) gene set"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
68 <option value="indexed" selected="true">Use a built-in gene set</option> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
69 <option value="history">Use a gene set from my history</option> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
70 <option value="both">Add a gene set from my history to a built in gene set</option> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
71 </param> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
72 <when value="indexed"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
73 <param name="builtinGMT" type="select" label="Select a gene set matrix (.gmt) file to use for the analysis"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
74 <options from_data_table="gseaGMT_3.1"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
75 <filter type="sort_by" column="2" /> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
76 <validator type="no_options" message="No GMT v3.1 files are available - please install them"/> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
77 </options> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
78 </param> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
79 </when> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
80 <when value="history"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
81 <param name="ownGMT" type="data" format="gmt" label="Select a Gene Set from your history" /> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
82 </when> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
83 <when value="both"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
84 <param name="ownGMT" type="data" format="gseagmt" label="Select a Gene Set from your history" /> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
85 <param name="builtinGMT" type="select" label="Select a gene set matrix (.gmt) file to use for the analysis"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
86 <options from_data_table="gseaGMT_3.1"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
87 <filter type="sort_by" column="2" /> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
88 <validator type="no_options" message="No GMT v3.1 files are available - please fix tool_data_table and loc files"/> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
89 </options> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
90 </param> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
91 </when> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
92 </conditional> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
93 </when> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
94 <when value="F"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
95 </when> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
96 </conditional> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
97 <param name="priordf" type="integer" value="20" size="3" label="prior.df for tagwise dispersion - lower value = more emphasis on each tag's variance. Replaces prior.n and prior.df = prior.n * residual.df" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
98 help="0 = Use edgeR default. Use a small value to 'smooth' small samples. See edgeR docs and note below"/> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
99 <param name="fdrthresh" type="float" value="0.05" size="5" label="P value threshold for FDR filtering for amily wise error rate control" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
100 help="Conventional default value of 0.05 recommended"/> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
101 <param name="fdrtype" type="select" label="FDR (Type II error) control method" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
102 help="Use fdr or bh typically to control for the number of tests in a reliable way"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
103 <option value="fdr" selected="true">fdr</option> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
104 <option value="BH">Benjamini Hochberg</option> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
105 <option value="BY">Benjamini Yukateli</option> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
106 <option value="bonferroni">Bonferroni</option> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
107 <option value="hochberg">Hochberg</option> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
108 <option value="holm">Holm</option> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
109 <option value="hommel">Hommel</option> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
110 <option value="none">no control for multiple tests</option> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
111 </param> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
112 </inputs> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
113 <outputs> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
114 <data format="tabular" name="outtab" label="${title}.xls"/> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
115 <data format="html" name="html_file" label="${title}.html"/> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
116 </outputs> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
117 <stdio> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
118 <exit_code range="4" level="fatal" description="Number of subject ids must match total number of samples in the input matrix" /> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
119 </stdio> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
120 <tests> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
121 <test> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
122 <param name='input1' value='test_bams2mx.xls' ftype='tabular' /> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
123 <param name='treatment_name' value='case' /> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
124 <param name='title' value='edgeRtest' /> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
125 <param name='useNDF' value='' /> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
126 <param name='fdrtype' value='fdr' /> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
127 <param name='priordf' value="0" /> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
128 <param name='fdrthresh' value="0.05" /> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
129 <param name='control_name' value='control' /> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
130 <param name='subjectids' value='' /> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
131 <param name='Treat_cols' value='3,4,5,9' /> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
132 <param name='Control_cols' value='2,6,7,8' /> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
133 <output name='outtab' file='edgeRtest1out.xls' compare='diff' /> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
134 <output name='html_file' file='edgeRtest1out.html' compare='diff' lines_diff='20' /> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
135 </test> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
136 </tests> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
137 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
138 <configfiles> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
139 <configfile name="runme"> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
140 <![CDATA[ |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
141 ## |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
142 ## edgeR.Rscript |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
143 ## updated npv 2011 for R 2.14.0 and edgeR 2.4.0 by ross |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
144 ## Performs DGE on a count table containing n replicates of two conditions |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
145 ## |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
146 ### Original edgeR code by: S.Lunke and A.Kaspi |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
147 reallybig = log10(.Machine\$double.xmax) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
148 reallysmall = log10(.Machine\$double.xmin) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
149 library('stringr') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
150 library('gplots') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
151 library('edgeR') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
152 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
153 hmap2 = function(cmat,nsamp=100,outpdfname='heatmap2.pdf', TName='Treatment',group=NA,myTitle='title goes here') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
154 { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
155 ### Perform clustering for significant pvalues after controlling FWER |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
156 samples = colnames(cmat) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
157 gu = unique(group) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
158 if (length(gu) == 2) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
159 col.map = function(g) {if (g==gu[1]) "#FF0000" else "#0000FF"} |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
160 pcols = unlist(lapply(group,col.map)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
161 } else { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
162 colours = rainbow(length(gu),start=0,end=4/6) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
163 pcols = colours[match(group,gu)] |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
164 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
165 gn = rownames(cmat) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
166 dm = cmat[(! is.na(gn)),] |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
167 ### remove unlabelled hm rows |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
168 nprobes = nrow(dm) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
169 if (nprobes > nsamp) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
170 dm =dm[1:nsamp,] |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
171 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
172 newcolnames = substr(colnames(dm),1,20) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
173 colnames(dm) = newcolnames |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
174 pdf(outpdfname) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
175 heatmap.2(dm,main=myTitle,ColSideColors=pcols,col=topo.colors(100),dendrogram="col",key=T,density.info='none', |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
176 Rowv=F,scale='row',trace='none',margins=c(8,8),cexRow=0.4,cexCol=0.5) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
177 dev.off() |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
178 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
179 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
180 hmap = function(cmat,nmeans=4,outpdfname="heatMap.pdf",nsamp=250,TName='Treatment',group=NA,myTitle="Title goes here") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
181 { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
182 ## for 2 groups only was |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
183 ## col.map = function(g) {if (g==TName) "#FF0000" else "#0000FF"} |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
184 ## pcols = unlist(lapply(group,col.map)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
185 gu = unique(group) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
186 colours = rainbow(length(gu),start=0.3,end=0.6) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
187 pcols = colours[match(group,gu)] |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
188 nrows = nrow(cmat) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
189 mtitle = paste(myTitle,'Heatmap: n contigs =',nrows) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
190 if (nrows > nsamp) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
191 cmat = cmat[c(1:nsamp),] |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
192 mtitle = paste('Heatmap: Top ',nsamp,' DE contigs (of ',nrows,')',sep='') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
193 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
194 newcolnames = substr(colnames(cmat),1,20) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
195 colnames(cmat) = newcolnames |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
196 pdf(outpdfname) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
197 heatmap(cmat,scale='row',main=mtitle,cexRow=0.3,cexCol=0.4,Rowv=NA,ColSideColors=pcols) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
198 dev.off() |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
199 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
200 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
201 qqPlot = function(descr='Title',pvector, ...) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
202 ## stolen from https://gist.github.com/703512 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
203 { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
204 o = -log10(sort(pvector,decreasing=F)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
205 e = -log10( 1:length(o)/length(o) ) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
206 o[o==-Inf] = reallysmall |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
207 o[o==Inf] = reallybig |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
208 pdfname = paste(gsub(" ","", descr , fixed=TRUE),'pval_qq.pdf',sep='_') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
209 maint = paste(descr,'QQ Plot') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
210 pdf(pdfname) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
211 plot(e,o,pch=19,cex=1, main=maint, ..., |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
212 xlab=expression(Expected~~-log[10](italic(p))), |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
213 ylab=expression(Observed~~-log[10](italic(p))), |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
214 xlim=c(0,max(e)), ylim=c(0,max(o))) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
215 lines(e,e,col="red") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
216 grid(col = "lightgray", lty = "dotted") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
217 dev.off() |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
218 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
219 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
220 smearPlot = function(DGEList,deTags, outSmear, outMain) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
221 { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
222 pdf(outSmear) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
223 plotSmear(DGEList,de.tags=deTags,main=outMain) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
224 grid(col="blue") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
225 dev.off() |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
226 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
227 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
228 boxPlot = function(rawrs,cleanrs,maint,myTitle) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
229 { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
230 nc = ncol(rawrs) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
231 for (i in c(1:nc)) {rawrs[(rawrs[,i] < 0),i] = NA} |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
232 fullnames = colnames(rawrs) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
233 newcolnames = substr(colnames(rawrs),1,20) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
234 colnames(rawrs) = newcolnames |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
235 newcolnames = substr(colnames(cleanrs),1,20) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
236 colnames(cleanrs) = newcolnames |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
237 pdfname = paste(gsub(" ","", myTitle , fixed=TRUE),"sampleBoxplot.pdf",sep='_') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
238 defpar = par(no.readonly=T) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
239 pdf(pdfname) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
240 l = layout(matrix(c(1,2),1,2,byrow=T)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
241 print.noquote('raw contig counts by sample:') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
242 print.noquote(summary(rawrs)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
243 print.noquote('normalised contig counts by sample:') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
244 print.noquote(summary(cleanrs)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
245 boxplot(rawrs,varwidth=T,notch=T,ylab='log contig count',col="maroon",las=3,cex.axis=0.35,main=paste('Raw:',maint)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
246 grid(col="blue") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
247 boxplot(cleanrs,varwidth=T,notch=T,ylab='log contig count',col="maroon",las=3,cex.axis=0.35,main=paste('After ',maint)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
248 grid(col="blue") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
249 dev.off() |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
250 pdfname = paste(gsub(" ","", myTitle , fixed=TRUE),"samplehistplot.pdf",sep='_') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
251 nc = ncol(rawrs) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
252 print.noquote(paste('Using ncol rawrs=',nc)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
253 ncroot = round(sqrt(nc)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
254 if (ncroot*ncroot < nc) { ncroot = ncroot + 1 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
255 m = c() |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
256 for (i in c(1:nc)) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
257 rhist = hist(rawrs[,i],breaks=100,plot=F) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
258 m = append(m,max(rhist\$counts)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
259 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
260 ymax = max(m) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
261 pdf(pdfname) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
262 par(mfrow=c(ncroot,ncroot)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
263 for (i in c(1:nc)) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
264 hist(rawrs[,i], main=paste("Contig logcount",i), xlab='log raw count', col="maroon", |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
265 breaks=100,sub=fullnames[i],cex=0.8,ylim=c(0,ymax)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
266 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
267 dev.off() |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
268 par(defpar) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
269 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
270 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
271 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
272 cumPlot = function(rawrs,cleanrs,maint,myTitle) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
273 { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
274 pdfname = paste(gsub(" ","", myTitle , fixed=TRUE),"RowsumCum.pdf",sep='_') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
275 defpar = par(no.readonly=T) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
276 pdf(pdfname) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
277 par(mfrow=c(2,1)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
278 lrs = log(rawrs,10) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
279 lim = max(lrs) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
280 hist(lrs,breaks=100,main=paste('Before:',maint),xlab="Reads (log)", |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
281 ylab="Count",col="maroon",sub=myTitle, xlim=c(0,lim),las=1) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
282 grid(col="blue") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
283 lrs = log(cleanrs,10) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
284 hist(lrs,breaks=100,main=paste('After:',maint),xlab="Reads (log)", |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
285 ylab="Count",col="maroon",sub=myTitle,xlim=c(0,lim),las=1) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
286 grid(col="blue") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
287 dev.off() |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
288 par(defpar) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
289 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
290 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
291 cumPlot1 = function(rawrs,cleanrs,maint,myTitle) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
292 { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
293 pdfname = paste(gsub(" ","", myTitle , fixed=TRUE),"RowsumCum.pdf",sep='_') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
294 pdf(pdfname) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
295 par(mfrow=c(2,1)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
296 lastx = max(rawrs) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
297 rawe = knots(ecdf(rawrs)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
298 cleane = knots(ecdf(cleanrs)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
299 cy = 1:length(cleane)/length(cleane) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
300 ry = 1:length(rawe)/length(rawe) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
301 plot(rawe,ry,type='l',main=paste('Before',maint),xlab="Log Contig Total Reads", |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
302 ylab="Cumulative proportion",col="maroon",log='x',xlim=c(1,lastx),sub=myTitle) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
303 grid(col="blue") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
304 plot(cleane,cy,type='l',main=paste('After',maint),xlab="Log Contig Total Reads", |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
305 ylab="Cumulative proportion",col="maroon",log='x',xlim=c(1,lastx),sub=myTitle) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
306 grid(col="blue") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
307 dev.off() |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
308 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
309 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
310 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
311 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
312 doGSEA = function(y=NULL,design=NULL,histgmt="", |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
313 bigmt="/data/genomes/gsea/3.1/Abetterchoice_nocgp_c2_c3_c5_symbols_all.gmt", |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
314 ntest=0, myTitle="myTitle", outfname="GSEA.xls", minnin=5, maxnin=2000,fdrthresh=0.05,fdrtype="BH") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
315 { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
316 genesets = c() |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
317 if (bigmt > "") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
318 { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
319 bigenesets = readLines(bigmt) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
320 genesets = bigenesets |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
321 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
322 if (histgmt > "") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
323 { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
324 hgenesets = readLines(histgmt) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
325 if (bigmt > "") { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
326 genesets = rbind(genesets,hgenesets) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
327 } else { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
328 genesets = hgenesets |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
329 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
330 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
331 print.noquote(paste("@@@read",length(genesets), 'genesets from',histgmt,bigmt)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
332 genesets = strsplit(genesets,'\t') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
333 ##### tabular. genesetid\tURLorwhatever\tgene_1\t..\tgene_n |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
334 outf = outfname |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
335 head=paste(myTitle,'edgeR GSEA') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
336 write(head,file=outfname,append=F) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
337 ntest=length(genesets) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
338 urownames = toupper(rownames(y)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
339 upcam = c() |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
340 downcam = c() |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
341 for (i in 1:ntest) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
342 gs = unlist(genesets[i]) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
343 g = gs[1] #### geneset_id |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
344 u = gs[2] |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
345 if (u > "") { u = paste("<a href=\'",u,"\'>",u,"</a>",sep="") } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
346 glist = gs[3:length(gs)] #### member gene symbols |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
347 glist = toupper(glist) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
348 inglist = urownames %in% glist |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
349 nin = sum(inglist) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
350 if ((nin > minnin) && (nin < maxnin)) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
351 ### print(paste('@@found',sum(inglist),'genes in glist')) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
352 camres = camera(y=y,index=inglist,design=design) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
353 if (camres) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
354 rownames(camres) = g |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
355 ##### gene set name |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
356 camres = cbind(GeneSet=g,URL=u,camres) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
357 if (camres\$Direction == "Up") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
358 { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
359 upcam = rbind(upcam,camres) } else { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
360 downcam = rbind(downcam,camres) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
361 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
362 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
363 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
364 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
365 uscam = upcam[order(upcam\$PValue),] |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
366 unadjp = uscam\$PValue |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
367 uscam\$adjPValue = p.adjust(unadjp,method=fdrtype) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
368 nup = max(10,sum((uscam\$adjPValue < fdrthresh))) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
369 dscam = downcam[order(downcam\$PValue),] |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
370 unadjp = dscam\$PValue |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
371 dscam\$adjPValue = p.adjust(unadjp,method=fdrtype) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
372 ndown = max(10,sum((dscam\$adjPValue < fdrthresh))) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
373 write.table(uscam,file=paste('upCamera',outfname,sep='_'),quote=F,sep='\t',row.names=F) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
374 write.table(dscam,file=paste('downCamera',outfname,sep='_'),quote=F,sep='\t',row.names=F) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
375 print.noquote(paste('@@@@@ Camera up top',nup,'gene sets:')) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
376 write.table(head(uscam,nup),file="",quote=F,sep='\t',row.names=F) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
377 print.noquote(paste('@@@@@ Camera down top',ndown,'gene sets:')) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
378 write.table(head(dscam,ndown),file="",quote=F,sep='\t',row.names=F) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
379 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
380 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
381 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
382 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
383 edgeIt = function (Count_Matrix,group,outputfilename,fdrtype='fdr',priordf=5, |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
384 fdrthresh=0.05,outputdir='.', myTitle='edgeR',libSize=c(),useNDF=F, |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
385 filterquantile=0.2, subjects=c(),mydesign=NULL, |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
386 doDESeq=T,doVoom=T,doCamera=T,org='hg19', |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
387 histgmt="", bigmt="/data/genomes/gsea/3.1/Abetterchoice_nocgp_c2_c3_c5_symbols_all.gmt", |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
388 doCook=F,DESeq_fittype="parameteric") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
389 { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
390 if (length(unique(group))!=2){ |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
391 print("Number of conditions identified in experiment does not equal 2") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
392 q() |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
393 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
394 require(edgeR) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
395 options(width = 512) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
396 mt = paste(unlist(strsplit(myTitle,'_')),collapse=" ") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
397 allN = nrow(Count_Matrix) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
398 nscut = round(ncol(Count_Matrix)/2) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
399 colTotmillionreads = colSums(Count_Matrix)/1e6 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
400 rawrs = rowSums(Count_Matrix) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
401 nonzerod = Count_Matrix[(rawrs > 0),] |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
402 nzN = nrow(nonzerod) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
403 nzrs = rowSums(nonzerod) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
404 zN = allN - nzN |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
405 print('**** Quantiles for non-zero row counts:',quote=F) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
406 print(quantile(nzrs,probs=seq(0,1,0.1)),quote=F) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
407 if (useNDF == "T") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
408 { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
409 gt1rpin3 = rowSums(Count_Matrix/expandAsMatrix(colTotmillionreads,dim(Count_Matrix)) >= 1) >= nscut |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
410 lo = colSums(Count_Matrix[!gt1rpin3,]) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
411 workCM = Count_Matrix[gt1rpin3,] |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
412 cleanrs = rowSums(workCM) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
413 cleanN = length(cleanrs) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
414 meth = paste( "After removing",length(lo),"contigs with fewer than ",nscut," sample read counts >= 1 per million, there are",sep="") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
415 print(paste("Read",allN,"contigs. Removed",zN,"contigs with no reads.",meth,cleanN,"contigs"),quote=F) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
416 maint = paste('Filter >= 1/million reads in >=',nscut,'samples') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
417 } else { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
418 useme = (nzrs > quantile(nzrs,filterquantile)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
419 workCM = nonzerod[useme,] |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
420 lo = colSums(nonzerod[!useme,]) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
421 cleanrs = rowSums(workCM) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
422 cleanN = length(cleanrs) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
423 meth = paste("After filtering at count quantile =",filterquantile,", there are",sep="") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
424 print(paste('Read',allN,"contigs. Removed",zN,"with no reads.",meth,cleanN,"contigs"),quote=F) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
425 maint = paste('Filter below',filterquantile,'quantile') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
426 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
427 cumPlot(rawrs=rawrs,cleanrs=cleanrs,maint=maint,myTitle=myTitle) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
428 allgenes <- rownames(workCM) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
429 print(paste("*** Total low count contigs per sample = ",paste(lo,collapse=',')),quote=F) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
430 rsums = rowSums(workCM) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
431 TName=unique(group)[1] |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
432 CName=unique(group)[2] |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
433 DGEList = DGEList(counts=workCM, group = group) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
434 DGEList = calcNormFactors(DGEList) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
435 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
436 if (is.null(mydesign)) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
437 if (length(subjects) == 0) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
438 { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
439 mydesign = model.matrix(~group) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
440 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
441 else { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
442 subjf = factor(subjects) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
443 mydesign = model.matrix(~subjf+group) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
444 ### we block on subject so make group last to simplify finding it |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
445 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
446 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
447 print.noquote(paste('Using samples:',paste(colnames(workCM),collapse=','))) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
448 print.noquote('Using design matrix:') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
449 print.noquote(mydesign) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
450 DGEList = estimateGLMCommonDisp(DGEList,mydesign) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
451 comdisp = DGEList\$common.dispersion |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
452 DGEList = estimateGLMTrendedDisp(DGEList,mydesign) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
453 if (priordf > 0) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
454 print.noquote(paste("prior.df =",priordf)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
455 DGEList = estimateGLMTagwiseDisp(DGEList,mydesign,prior.df = priordf) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
456 } else { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
457 DGEList = estimateGLMTagwiseDisp(DGEList,mydesign) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
458 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
459 lastcoef=ncol(mydesign) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
460 print.noquote(paste('*** lastcoef = ',lastcoef)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
461 estpriorn = getPriorN(DGEList) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
462 predLFC1 = predFC(DGEList,prior.count=1,design=mydesign,dispersion=DGEList\$tagwise.dispersion,offset=getOffset(DGEList)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
463 predLFC3 = predFC(DGEList,prior.count=3,design=mydesign,dispersion=DGEList\$tagwise.dispersion,offset=getOffset(DGEList)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
464 predLFC5 = predFC(DGEList,prior.count=5,design=mydesign,dispersion=DGEList\$tagwise.dispersion,offset=getOffset(DGEList)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
465 DGLM = glmFit(DGEList,design=mydesign) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
466 DE = glmLRT(DGLM) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
467 #### always last one - subject is first if needed |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
468 logCPMnorm = cpm(DGEList,log=T,normalized.lib.sizes=T) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
469 logCPMraw = cpm(DGEList,log=T,normalized.lib.sizes=F) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
470 uoutput = cbind( |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
471 Name=as.character(rownames(DGEList\$counts)), |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
472 DE\$table, |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
473 adj.p.value=p.adjust(DE\$table\$PValue, method=fdrtype), |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
474 Dispersion=DGEList\$tagwise.dispersion,totreads=rsums, |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
475 predLFC1=predLFC1[,lastcoef], |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
476 predLFC3=predLFC3[,lastcoef], |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
477 predLFC5=predLFC5[,lastcoef], |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
478 logCPMnorm, |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
479 DGEList\$counts |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
480 ) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
481 soutput = uoutput[order(DE\$table\$PValue),] |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
482 heatlogcpmnorm = logCPMnorm[order(DE\$table\$PValue),] |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
483 goodness = gof(DGLM, pcutoff=fdrthresh) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
484 noutl = (sum(goodness\$outlier) > 0) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
485 if (noutl > 0) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
486 print.noquote(paste('***',noutl,'GLM outliers found')) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
487 print(paste(rownames(DGLM)[(goodness\$outlier)],collapse=','),quote=F) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
488 } else { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
489 print('*** No GLM fit outlier genes found') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
490 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
491 z = limma::zscoreGamma(goodness\$gof.statistic, shape=goodness\$df/2, scale=2) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
492 pdf(paste(mt,"GoodnessofFit.pdf",sep='_')) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
493 qq = qqnorm(z, panel.first=grid(), main="tagwise dispersion") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
494 abline(0,1,lwd=3) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
495 points(qq\$x[goodness\$outlier],qq\$y[goodness\$outlier], pch=16, col="maroon") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
496 dev.off() |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
497 print(paste("Common Dispersion =",comdisp,"CV = ",sqrt(comdisp),"getPriorN = ",estpriorn),quote=F) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
498 uniqueg = unique(group) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
499 sample_colors = match(group,levels(group)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
500 pdf(paste(mt,"MDSplot.pdf",sep='_')) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
501 sampleTypes = levels(factor(group)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
502 print.noquote(sampleTypes) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
503 plotMDS.DGEList(DGEList,main=paste("MDS Plot for",myTitle),cex=0.5,col=sample_colors,pch=sample_colors) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
504 legend(x="topleft", legend = sampleTypes,col=c(1:length(sampleTypes)), pch=19) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
505 grid(col="blue") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
506 dev.off() |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
507 colnames(logCPMnorm) = paste( colnames(logCPMnorm),'N',sep="_") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
508 print(paste('Raw sample CPM',paste(colSums(logCPMraw,na.rm=T),collapse=','))) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
509 try(boxPlot(rawrs=logCPMraw,cleanrs=logCPMnorm,maint='TMM Normalisation',myTitle=myTitle)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
510 nreads = soutput\$totreads |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
511 print('*** writing output',quote=F) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
512 write.table(soutput,outputfilename, quote=FALSE, sep="\t",row.names=F) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
513 rn = row.names(workCM) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
514 print.noquote('@@ rn') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
515 print.noquote(head(rn)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
516 reg = "^chr([0-9]+):([0-9]+)-([0-9]+)" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
517 genecards="<a href=\'http://www.genecards.org/index.php?path=/Search/keyword/" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
518 ucsc = paste("<a href=\'http://genome.ucsc.edu/cgi-bin/hgTracks?db=",org,sep='') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
519 testreg = str_match(rn,reg) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
520 nreads = uoutput\$totreads |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
521 if (sum(!is.na(testreg[,1]))/length(testreg[,1]) > 0.8) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
522 { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
523 print("@@ using ucsc substitution for urls") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
524 urls = paste0(ucsc,"&position=chr",testreg[,2],":",testreg[,3],"-",testreg[,4],"\'>",rn,"</a>") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
525 } else { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
526 print("@@ using genecards substitution for urls") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
527 urls = paste0(genecards,rn,"\'>",rn,"</a>") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
528 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
529 tt = uoutput |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
530 print.noquote("*** edgeR Top tags\n") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
531 tt = cbind(tt,ntotreads=nreads,URL=urls) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
532 tt = tt[order(DE\$table\$PValue),] |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
533 print.noquote(tt[1:50,]) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
534 ### Plot MAplot |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
535 deTags = rownames(uoutput[uoutput\$adj.p.value < fdrthresh,]) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
536 nsig = length(deTags) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
537 print(paste('***',nsig,'tags significant at adj p=',fdrthresh),quote=F) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
538 if (nsig > 0) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
539 print('*** deTags',quote=F) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
540 print(head(deTags)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
541 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
542 deColours = ifelse(deTags,'red','black') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
543 pdf(paste(mt,"BCV_vs_abundance.pdf",sep='_')) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
544 plotBCV(DGEList, cex=0.3, main="Biological CV vs abundance") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
545 dev.off() |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
546 dg = DGEList[order(DE\$table\$PValue),] |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
547 outpdfname=paste(mt,"heatmap.pdf",sep='_') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
548 hmap2(heatlogcpmnorm,nsamp=100,TName=TName,group=group,outpdfname=outpdfname,myTitle=myTitle) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
549 outSmear = paste(mt,"Smearplot.pdf",sep='_') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
550 outMain = paste("Smear Plot for ",TName,' Vs ',CName,' (FDR@',fdrthresh,' N = ',nsig,')',sep='') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
551 smearPlot(DGEList=DGEList,deTags=deTags, outSmear=outSmear, outMain = outMain) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
552 qqPlot(descr=myTitle,pvector=DE\$table\$PValue) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
553 if (doDESeq == T) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
554 { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
555 ### DESeq2 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
556 require('DESeq2') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
557 print.noquote(paste('****subjects=',subjects,'length=',length(subjects))) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
558 if (length(subjects) == 0) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
559 { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
560 pdata = data.frame(Name=colnames(workCM),Rx=group,row.names=colnames(workCM)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
561 deSEQds = DESeqDataSetFromMatrix(countData = workCM, colData = pdata, design = formula(~ Rx)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
562 } else { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
563 pdata = data.frame(Name=colnames(workCM),Rx=group,subjects=subjects,row.names=colnames(workCM)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
564 deSEQds = DESeqDataSetFromMatrix(countData = workCM, colData = pdata, design = formula(~ subjects + Rx)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
565 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
566 deSeqDatsizefac <- estimateSizeFactors(deSEQds) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
567 deSeqDatdisp <- estimateDispersions(deSeqDatsizefac,fitType=DESeq_fittype) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
568 resDESeq <- nbinomWaldTest(deSeqDatdisp, pAdjustMethod=fdrtype) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
569 rDESeq = as.data.frame(results(resDESeq)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
570 srDESeq = rDESeq[order(rDESeq\$pvalue),] |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
571 write.table(srDESeq,paste(mt,'DESeq2_TopTable.xls',sep='_'), quote=FALSE, sep="\t",row.names=F) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
572 topresults.DESeq <- rDESeq[which(rDESeq\$padj < fdrthresh), ] |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
573 DESeqcountsindex <- which(allgenes %in% rownames(topresults.DESeq)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
574 DESeqcounts <- rep(0, length(allgenes)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
575 DESeqcounts[DESeqcountsindex] <- 1 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
576 pdf(paste(mt,"DESeq2_dispersion_estimates.pdf",sep='_')) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
577 plotDispEsts(resDESeq) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
578 dev.off() |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
579 if (doCook) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
580 pdf(paste(mt,"DESeq2_cooks_distance.pdf",sep='_')) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
581 W <- mcols(resDESeq)\$WaldStatistic_condition_treated_vs_untreated |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
582 maxCooks <- mcols(resDESeq)\$maxCooks |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
583 idx <- !is.na(W) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
584 plot(rank(W[idx]), maxCooks[idx], xlab="rank of Wald statistic", ylab="maximum Cook's distance per gene", |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
585 ylim=c(0,5), cex=.4, col="maroon") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
586 m <- ncol(dds) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
587 p <- 3 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
588 abline(h=qf(.75, p, m - p),col="darkblue") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
589 grid(col="lightgray",lty="dotted") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
590 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
591 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
592 counts.dataframe = as.data.frame(c()) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
593 norm.factor = DGEList\$samples\$norm.factors |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
594 topresults.edgeR <- soutput[which(soutput\$adj.p.value < fdrthresh), ] |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
595 edgeRcountsindex <- which(allgenes %in% rownames(topresults.edgeR)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
596 edgeRcounts <- rep(0, length(allgenes)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
597 edgeRcounts[edgeRcountsindex] <- 1 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
598 if (doVoom == T) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
599 pdf(paste(mt,"voomplot.pdf",sep='_')) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
600 dat.voomed <- voom(DGEList, mydesign, plot = TRUE, normalize.method="quantil", lib.size = NULL) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
601 dev.off() |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
602 fit <- lmFit(dat.voomed, mydesign) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
603 fit <- eBayes(fit) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
604 rvoom <- topTable(fit, coef = length(colnames(mydesign)), adj = "BH", n = Inf) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
605 write.table(rvoom,paste(mt,'VOOM_topTable.xls',sep='_'), quote=FALSE, sep="\t",row.names=F) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
606 topresults.voom <- rvoom[which(rvoom\$adj.P.Val < fdrthresh), ] |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
607 voomcountsindex <- which(allgenes %in% rownames(topresults.voom)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
608 voomcounts <- rep(0, length(allgenes)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
609 voomcounts[voomcountsindex] <- 1 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
610 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
611 if ((doDESeq==T) || (doVoom==T)) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
612 if ((doVoom==T) && (doDESeq==T)) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
613 vennmain = paste(mt,'Voom,edgeR and DESeq2 overlap at FDR=',fdrthresh) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
614 counts.dataframe <- data.frame(edgeR = edgeRcounts, DESeq2 = DESeqcounts, |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
615 VOOM_limma = voomcounts, row.names = allgenes) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
616 } else if (doDESeq==T) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
617 vennmain = paste(mt,'DESeq2 and edgeR overlap at FDR=',fdrthresh) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
618 counts.dataframe <- data.frame(edgeR = edgeRcounts, DESeq2 = DESeqcounts, row.names = allgenes) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
619 } else if (doVoom==T) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
620 vennmain = paste(mt,'Voom and edgeR overlap at FDR=',fdrthresh) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
621 counts.dataframe <- data.frame(edgeR = edgeRcounts, VOOM_limma = voomcounts, row.names = allgenes) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
622 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
623 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
624 if (nrow(counts.dataframe > 1)) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
625 counts.venn <- vennCounts(counts.dataframe) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
626 vennf = paste(mt,'venn.pdf',sep='_') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
627 pdf(vennf) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
628 vennDiagram(counts.venn,main=vennmain,col="maroon") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
629 dev.off() |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
630 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
631 } ### doDESeq or doVoom |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
632 if (doDESeq==T) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
633 cat("*** DESeq top 50\n") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
634 print(srDESeq[1:50,]) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
635 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
636 if (doVoom==T) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
637 cat("*** VOOM top 50\n") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
638 print(rvoom[1:50,]) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
639 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
640 if (doCamera) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
641 doGSEA(y=DGEList,design=mydesign,histgmt=histgmt,bigmt=bigmt,ntest=20,myTitle=myTitle, |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
642 outfname=paste(mt,"GSEA.xls",sep="_"),fdrthresh=fdrthresh,fdrtype=fdrtype) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
643 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
644 uoutput |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
645 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
646 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
647 #### Done |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
648 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
649 #### sink(stdout(),append=T,type="message") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
650 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
651 doDESeq = $DESeq.doDESeq |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
652 ### make these 'T' or 'F' |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
653 doVoom = $doVoom |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
654 doCamera = $camera.doCamera |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
655 Out_Dir = "$html_file.files_path" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
656 Input = "$input1" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
657 TreatmentName = "$treatment_name" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
658 TreatmentCols = "$Treat_cols" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
659 ControlName = "$control_name" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
660 ControlCols= "$Control_cols" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
661 outputfilename = "$outtab" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
662 org = "$input1.dbkey" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
663 if (org == "") { org = "hg19"} |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
664 fdrtype = "$fdrtype" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
665 priordf = $priordf |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
666 fdrthresh = $fdrthresh |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
667 useNDF = "$useNDF" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
668 fQ = $fQ |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
669 myTitle = "$title" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
670 sids = strsplit("$subjectids",',') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
671 subjects = unlist(sids) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
672 nsubj = length(subjects) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
673 builtin_gmt="" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
674 history_gmt="" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
675 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
676 builtin_gmt = "" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
677 history_gmt = "" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
678 DESeq_fittype="" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
679 #if $DESeq.doDESeq == "T" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
680 DESeq_fittype = "$DESeq.DESeq_fitType" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
681 #end if |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
682 #if $camera.doCamera == 'T' |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
683 #if $camera.gmtSource.refgmtSource == "indexed" or $camera.gmtSource.refgmtSource == "both": |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
684 builtin_gmt = "${camera.gmtSource.builtinGMT.fields.path}" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
685 #end if |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
686 #if $camera.gmtSource.refgmtSource == "history" or $camera.gmtSource.refgmtSource == "both": |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
687 history_gmt = "${camera.gmtSource.ownGMT}" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
688 history_gmt_name = "${camera.gmtSource.ownGMT.name}" |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
689 #end if |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
690 #end if |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
691 if (nsubj > 0) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
692 if (doDESeq) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
693 print('WARNING - cannot yet use DESeq2 for 2 way anova - see the docs') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
694 doDESeq = F |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
695 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
696 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
697 TCols = as.numeric(strsplit(TreatmentCols,",")[[1]])-1 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
698 CCols = as.numeric(strsplit(ControlCols,",")[[1]])-1 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
699 cat('Got TCols=') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
700 cat(TCols) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
701 cat('; CCols=') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
702 cat(CCols) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
703 cat('\n') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
704 useCols = c(TCols,CCols) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
705 if (file.exists(Out_Dir) == F) dir.create(Out_Dir) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
706 Count_Matrix = read.table(Input,header=T,row.names=1,sep='\t') #Load tab file assume header |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
707 snames = colnames(Count_Matrix) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
708 nsamples = length(snames) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
709 if (nsubj > 0 & nsubj != nsamples) { |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
710 options("show.error.messages"=T) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
711 mess = paste('Fatal error: Supplied subject id list',paste(subjects,collapse=','), |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
712 'has length',nsubj,'but there are',nsamples,'samples',paste(snames,collapse=',')) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
713 write(mess, stderr()) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
714 quit(save="no",status=4) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
715 } |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
716 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
717 Count_Matrix = Count_Matrix[,useCols] ### reorder columns |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
718 if (length(subjects) != 0) {subjects = subjects[useCols]} |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
719 rn = rownames(Count_Matrix) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
720 islib = rn %in% c('librarySize','NotInBedRegions') |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
721 LibSizes = Count_Matrix[subset(rn,islib),][1] # take first |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
722 Count_Matrix = Count_Matrix[subset(rn,! islib),] |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
723 group = c(rep(TreatmentName,length(TCols)), rep(ControlName,length(CCols)) ) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
724 group = factor(group, levels=c(ControlName,TreatmentName)) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
725 colnames(Count_Matrix) = paste(group,colnames(Count_Matrix),sep="_") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
726 results = edgeIt(Count_Matrix=Count_Matrix,group=group,outputfilename=outputfilename, |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
727 fdrtype='BH',priordf=priordf,fdrthresh=fdrthresh,outputdir='.', |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
728 myTitle='edgeR',useNDF=F,libSize=c(),filterquantile=fQ,subjects=subjects, |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
729 doDESeq=doDESeq,doVoom=doVoom,doCamera=doCamera,org=org, |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
730 histgmt=history_gmt,bigmt=builtin_gmt,DESeq_fittype=DESeq_fittype) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
731 sessionInfo() |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
732 ]]> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
733 </configfile> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
734 </configfiles> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
735 <help> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
736 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
737 **What it does** |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
738 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
739 Performs digital gene expression analysis between a treatment and control on a count matrix. |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
740 Optionally adds a term for subject if not all samples are independent or if some other factor needs to be blocked in the design. |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
741 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
742 **Input** |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
743 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
744 A matrix consisting of non-negative integers. The matrix must have a unique header row identifiying the samples, and a unique set of row names |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
745 as the first column. Typically the row names are gene symbols or probe id's for downstream use in GSEA and other methods. |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
746 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
747 If you have (eg) paired samples and wish to include a term in the GLM to account for some other factor (subject in the case of paired samples), |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
748 put a comma separated list of indicators for every sample (whether modelled or not!) indicating (eg) the subject number or |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
749 A list of integers, one for each subject or an empty string if samples are all independent. |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
750 If not empty, there must be exactly as many integers in the supplied integer list as there are columns (samples) in the count matrix. |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
751 Integers for samples that are not in the analysis *must* be present in the string as filler even if not used. |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
752 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
753 So if you have 2 pairs out of 6 samples, you need to put in unique integers for the unpaired ones |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
754 eg if you had 6 samples with the first two independent but the second and third pairs each being from independent subjects. you might use |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
755 8,9,1,1,2,2 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
756 as subject IDs to indicate two paired samples from the same subject in columns 3/4 and 5/6 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
757 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
758 **Output** |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
759 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
760 A summary html page with links to the R source code and all the outputs, nice grids of helpful plot thumbnails, and lots |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
761 of logging and the top 50 rows of the topTable. |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
762 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
763 The main topTables of results are provided as separate excelish tabular files. |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
764 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
765 They include adjusted p values and dispersions for each region, raw and cpm sample data counts and shrunken (predicted) log fold change estimates. |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
766 These are provided for downstream analyses such as GSEA and are predictions of the logFC you might expect to see |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
767 in an independent replication of your original experiment. Higher number means more shrinkage. Shrinkage is more extreme for low coverage features |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
768 so downstream analyses are more robust against strong effect size estimates based on relatively little experimental information. |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
769 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
770 **Note on prior.N** |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
771 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
772 http://seqanswers.com/forums/showthread.php?t=5591 says: |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
773 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
774 *prior.n* |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
775 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
776 The value for prior.n determines the amount of smoothing of tagwise dispersions towards the common dispersion. |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
777 You can think of it as like a "weight" for the common value. (It is actually the weight for the common likelihood |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
778 in the weighted likelihood equation). The larger the value for prior.n, the more smoothing, i.e. the closer your |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
779 tagwise dispersion estimates will be to the common dispersion. If you use a prior.n of 1, then that gives the |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
780 common likelihood the weight of one observation. |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
781 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
782 In answer to your question, it is a good thing to squeeze the tagwise dispersions towards a common value, |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
783 or else you will be using very unreliable estimates of the dispersion. I would not recommend using the value that |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
784 you obtained from estimateSmoothing()---this is far too small and would result in virtually no moderation |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
785 (squeezing) of the tagwise dispersions. How many samples do you have in your experiment? |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
786 What is the experimental design? If you have few samples (less than 6) then I would suggest a prior.n of at least 10. |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
787 If you have more samples, then the tagwise dispersion estimates will be more reliable, |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
788 so you could consider using a smaller prior.n, although I would hesitate to use a prior.n less than 5. |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
789 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
790 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
791 From Bioconductor Digest, Vol 118, Issue 5, Gordon writes: |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
792 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
793 Dear Dorota, |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
794 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
795 The important settings are prior.df and trend. |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
796 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
797 prior.n and prior.df are related through prior.df = prior.n * residual.df, |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
798 and your experiment has residual.df = 36 - 12 = 24. So the old setting of |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
799 prior.n=10 is equivalent for your data to prior.df = 240, a very large |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
800 value. Going the other way, the new setting of prior.df=10 is equivalent |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
801 to prior.n=10/24. |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
802 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
803 To recover old results with the current software you would use |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
804 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
805 estimateTagwiseDisp(object, prior.df=240, trend="none") |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
806 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
807 To get the new default from old software you would use |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
808 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
809 estimateTagwiseDisp(object, prior.n=10/24, trend=TRUE) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
810 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
811 Actually the old trend method is equivalent to trend="loess" in the new |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
812 software. You should use plotBCV(object) to see whether a trend is |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
813 required. |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
814 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
815 Note you could also use |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
816 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
817 prior.n = getPriorN(object, prior.df=10) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
818 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
819 to map between prior.df and prior.n. |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
820 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
821 ** Old rant on variable name changes in bioconductor versions** |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
822 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
823 BioC authors sometimes make small mostly cosmetic changes to variable names (eg: from p.value to PValue) |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
824 often to make them more internally consistent or self describing. Unfortunately, these improvements |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
825 break existing code in ways that can take a while to track down that relies on the library in ways that can take a while to track down, |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
826 increasing downstream tool maintenance effort uselessly. |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
827 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
828 Please, don't do that. It hurts us. |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
829 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
830 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
831 </help> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
832 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
833 </tool> |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
834 |
c6fdf2c6d0f4
Citations added (thanks John!) and a few more output formats for Alistair Chilcott
fubar
parents:
diff
changeset
|
835 |