]> git.donarmstrong.com Git - rsem.git/blob - rsem-plot-transcript-wiggles
Added user-friendly error messages if users forget to compile the source codes
[rsem.git] / rsem-plot-transcript-wiggles
1 #!/usr/bin/perl
2
3 use Getopt::Long;
4 use Pod::Usage;
5 use File::Basename;
6 use strict;
7
8 use rsem_perl_utils;
9
10 my $gene_list = 0; # default is 0, means input is a transcript list; 1 means input is a gene list
11 my $show_unique = 0; # 0, default value, means do not show unique transcript wiggles; 1 means show unique transcript wiggles
12 my $help = 0;
13
14 GetOptions("gene-list" => \$gene_list,
15            "show-unique" => \$show_unique,
16            "h|help" => \$help) or pod2usage(-exitval => 2, -verbose => 2);
17
18 pod2usage(-verbose => 2) if ($help == 1);
19 pod2usage(-msg => "Invalid number of arguments!", -exitval => 2, -verbose => 2) if (scalar(@ARGV) != 3);
20
21 my ($fn, $dir, $suf) = fileparse($0);
22 my $command = "";
23
24 unless (-e "$ARGV[0].transcript.sorted.bam") {
25     $command = $dir."sam/samtools sort $ARGV[0].transcript.bam $ARGV[0].transcript.sorted";
26     &runCommand($command);
27 }
28 unless (-e "$ARGV[0].transcript.readdepth") {
29     $command = $dir."rsem-bam2readdepth $ARGV[0].transcript.sorted.bam $ARGV[0].transcript.readdepth";
30     &runCommand($command);
31 }
32
33 if ($show_unique) {
34     unless (-e "$ARGV[0].uniq.transcript.bam") {
35         $command = $dir."rsem-get-unique $ARGV[0].transcript.bam $ARGV[0].uniq.transcript.bam";
36         &runCommand($command);
37     }
38     unless (-e "$ARGV[0].uniq.transcript.sorted.bam") {
39         $command = $dir."sam/samtools sort $ARGV[0].uniq.transcript.bam $ARGV[0].uniq.transcript.sorted";
40         &runCommand($command);
41     }
42     unless (-e "$ARGV[0].uniq.transcript.readdepth") {
43         $command = $dir."rsem-bam2readdepth $ARGV[0].uniq.transcript.sorted.bam $ARGV[0].uniq.transcript.readdepth";
44         &runCommand($command);
45     }
46 }
47
48 $command = $dir."rsem-gen-transcript-plots $ARGV[0] $ARGV[1] $gene_list $show_unique $ARGV[2]";
49 &runCommand($command);
50
51 __END__
52
53 =head1 NAME
54
55 rsem-plot-transcript-wiggles
56
57 =head1 SYNOPSIS
58
59 =over
60
61  rsem-plot-transcript-wiggles [options] sample_name input_list output_plot_file
62
63 =back
64
65 =head1 ARGUMENTS
66
67 =over
68
69 =item B<sample_name>
70
71 The name of the sample analyzed.
72
73 =item B<input_list>
74
75 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.
76
77 =item B<output_plot_file>
78
79 The file name of the pdf file which contains all plots.
80
81 =back
82
83 =head1 OPTIONS
84
85 =over
86
87 =item B<--gene-list>
88
89 The input-list is a list of gene ids. (Default: off)
90
91 =item B<--show-unique>
92
93 Show the wiggle plots as stacked bar plots. See description section for details. (Default: off)
94
95 =item B<-h/--help>
96
97 Show help information.
98
99 =back
100
101 =head1 DESCRIPTION
102
103 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.
104
105 =head1 OUTPUT
106
107 =over
108
109 =item B<output_plot_file>
110
111 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. 
112
113 =item B<sample_name.transcript.sorted.bam and sample_name.transcript.readdepth>
114
115 If these files do not exist, 'rsem-plot-transcript-wiggles' will automatically generate them.
116
117 =item B<sample_name.uniq.transcript.bam, sample_name.uniq.transcript.sorted.bam and sample_name.uniq.transcript.readdepth>
118
119 If '--show-unique' option is specified and these files do not exist, 'rsem-plot-transcript-wiggles' will automatically generate them. 
120
121 =back
122
123 =head1 EXAMPLES
124
125 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.
126
127 1) Transcript ids are provided and we just want normal wiggle plots:
128
129  rsem-plot-transcript-wiggles mmliver_single_quals transcript_ids.txt output.pdf
130
131 2) Gene ids are provided and we want to show stacked bar plots:
132
133  rsem-plot-transcript-wiggles --gene-list --show-unique mmliver_single_quals gene_ids.txt output.pdf 
134
135 =cut