]> git.donarmstrong.com Git - rsem.git/blob - rsem-plot-transcript-wiggles
Added support for DE analysis on multiple conditions via running EBSeq
[rsem.git] / rsem-plot-transcript-wiggles
1 #!/usr/bin/perl
2
3 use Getopt::Long;
4 use Pod::Usage;
5 use FindBin;
6 use lib $FindBin::Bin;
7 use strict;
8
9 use rsem_perl_utils;
10
11 my $gene_list = 0; # default is 0, means input is a transcript list; 1 means input is a gene list
12 my $show_unique = 0; # 0, default value, means do not show unique transcript wiggles; 1 means show unique transcript wiggles
13 my $help = 0;
14
15 GetOptions("gene-list" => \$gene_list,
16            "show-unique" => \$show_unique,
17            "h|help" => \$help) or pod2usage(-exitval => 2, -verbose => 2);
18
19 pod2usage(-verbose => 2) if ($help == 1);
20 pod2usage(-msg => "Invalid number of arguments!", -exitval => 2, -verbose => 2) if (scalar(@ARGV) != 3);
21
22 my $dir = "$FindBin::Bin/";
23 my $command = "";
24
25 unless (-e "$ARGV[0].transcript.sorted.bam") {
26     $command = $dir."sam/samtools sort $ARGV[0].transcript.bam $ARGV[0].transcript.sorted";
27     &runCommand($command);
28 }
29 unless (-e "$ARGV[0].transcript.readdepth") {
30     $command = $dir."rsem-bam2readdepth $ARGV[0].transcript.sorted.bam $ARGV[0].transcript.readdepth";
31     &runCommand($command);
32 }
33
34 if ($show_unique) {
35     unless (-e "$ARGV[0].uniq.transcript.bam") {
36         $command = $dir."rsem-get-unique $ARGV[0].transcript.bam $ARGV[0].uniq.transcript.bam";
37         &runCommand($command);
38     }
39     unless (-e "$ARGV[0].uniq.transcript.sorted.bam") {
40         $command = $dir."sam/samtools sort $ARGV[0].uniq.transcript.bam $ARGV[0].uniq.transcript.sorted";
41         &runCommand($command);
42     }
43     unless (-e "$ARGV[0].uniq.transcript.readdepth") {
44         $command = $dir."rsem-bam2readdepth $ARGV[0].uniq.transcript.sorted.bam $ARGV[0].uniq.transcript.readdepth";
45         &runCommand($command);
46     }
47 }
48
49 $command = $dir."rsem-gen-transcript-plots $ARGV[0] $ARGV[1] $gene_list $show_unique $ARGV[2]";
50 &runCommand($command);
51
52 __END__
53
54 =head1 NAME
55
56 rsem-plot-transcript-wiggles
57
58 =head1 SYNOPSIS
59
60 rsem-plot-transcript-wiggles [options] sample_name input_list output_plot_file
61
62 =head1 ARGUMENTS
63
64 =over
65
66 =item B<sample_name>
67
68 The name of the sample analyzed.
69
70 =item B<input_list>
71
72 A list of transcript ids or gene ids. But it cannot be a mixture of transcript & gene ids. Each id occupies one line without extra spaces.
73
74 =item B<output_plot_file>
75
76 The file name of the pdf file which contains all plots.
77
78 =back
79
80 =head1 OPTIONS
81
82 =over
83
84 =item B<--gene-list>
85
86 The input-list is a list of gene ids. (Default: off)
87
88 =item B<--show-unique>
89
90 Show the wiggle plots as stacked bar plots. See description section for details. (Default: off)
91
92 =item B<-h/--help>
93
94 Show help information.
95
96 =back
97
98 =head1 DESCRIPTION
99
100 This program generates transcript wiggle plots and outputs them in a pdf file. This program can accept either a list of transcript ids or gene ids (if transcript to gene mapping information is provided) and has two modes of showing wiggle plots. If '--show-unique' is not specified, the wiggle plot for each transcript is a histogram where each position has the expected read depth at this position as its height. If '--show-unique' is specified, for each transcript a stacked bar plot is generated. For each position, the read depth of unique reads, which have only one alignment, is showed in black. The read depth of multi-reads, which align to more than one places, is showed in red on top of the read depth of unique reads.This program will use some files RSEM generated previouslly. So please do not delete/move any file 'rsem-calculate-expression' generated.
101
102 =head1 OUTPUT
103
104 =over
105
106 =item B<output_plot_file>
107
108 This is a pdf file containing all plots generated. If a list of transcript ids is provided, each page display at most 6 plots in 3 rows and 2 columns. If gene ids are provided, each page display a gene. The gene's id is showed at the top and all its transcripts' wiggle plots are showed in this page. The arrangment of plots is determined automatically. For each transcript wiggle plot, the transcript id is displayed as title. x-axis is position in the transcript and y-axis is read depth. 
109
110 =item B<sample_name.transcript.sorted.bam and sample_name.transcript.readdepth>
111
112 If these files do not exist, 'rsem-plot-transcript-wiggles' will automatically generate them.
113
114 =item B<sample_name.uniq.transcript.bam, sample_name.uniq.transcript.sorted.bam and sample_name.uniq.transcript.readdepth>
115
116 If '--show-unique' option is specified and these files do not exist, 'rsem-plot-transcript-wiggles' will automatically generate them. 
117
118 =back
119
120 =head1 EXAMPLES
121
122 Suppose sample_name and output_plot_file are set to 'mmliver_single_quals' and 'output.pdf' respectively. input_list is set to 'transcript_ids.txt' if transcript ids are provided, and is set to 'gene_ids.txt' if gene ids are provided.
123
124 1) Transcript ids are provided and we just want normal wiggle plots:
125
126  rsem-plot-transcript-wiggles mmliver_single_quals transcript_ids.txt output.pdf
127
128 2) Gene ids are provided and we want to show stacked bar plots:
129
130  rsem-plot-transcript-wiggles --gene-list --show-unique mmliver_single_quals gene_ids.txt output.pdf 
131
132 =cut