5 if (scalar(@ARGV) == 0) {
6 print "Usage: rsem-form-counts-matrix sampleA.[genes/isoforms].results sampleB.[genes/isoforms].results ... > output_name.counts.matrix\n";
7 print "Results files should be either all .genes.results or all .isoforms.results.\n";
12 my $n = scalar(@ARGV);
16 for (my $i = 0; $i < $n; $i++) {
18 open(INPUT, $ARGV[$i]);
19 while ($line = <INPUT>) {
21 my @fields = split(/\t/, $line);
22 push(@sample, $fields[1]);
25 if (scalar(@sample) == 0) {
26 print STDERR "No transcript is detected! Please check if $ARGV[$i] exists.\n";
29 if ($M < 0) { $M = scalar(@sample); }
30 elsif ($M != scalar(@sample)) {
31 print STDERR "Number of transcripts among samples are not equal!\n";
34 push(@matrix, \@sample);
37 for (my $i = 0; $i < $M; $i++) {
38 for (my $j = 0; $j < $n - 1; $j++) { print "$matrix[$j][$i]\t"; }
39 print "$matrix[$n - 1][$i]\n";