5 if (scalar(@ARGV) == 0) {
6 print "Usage: rsem-generate-data-matrix sampleA.[genes/isoforms].results sampleB.[genes/isoforms].results ... > output_name.matrix\n";
7 print "Results files should be either all .genes.results or all .isoforms.results.\n";
11 my $offsite = 4; # for new file formats
14 my $n = scalar(@ARGV);
18 # 0, file_name; 1, reference of expected count array; 2, reference of transcript_id/gene_id array
21 my $line = <INPUT>; # The first line contains only column names
22 while ($line = <INPUT>) {
24 my @fields = split(/\t/, $line);
25 push(@{$_[2]}, "\"$fields[0]\"");
26 push(@{$_[1]}, $fields[$offsite]);
30 if (scalar(@{$_[1]}) == 0) {
31 print STDERR "Nothing is detected! $_[0] may not exist or is empty.\n";
36 #0, M; 1, reference of @ids_arr; 2, reference of @ids
39 for (my $i = 0; $i < $size; $i++) {
40 if ($_[1]->[$i] ne $_[2]->[$i]) {
49 for (my $i = 0; $i < $n; $i++) {
51 &loadData($ARGV[$i], \@ecs, \@ids);
57 elsif (!&check($M, \@ids_arr, \@ids)) {
58 print STDERR "Number of lines among samples are not equal!\n";
63 if (substr($ARGV[$i], 0, 2) eq "./") { $colname = substr($ARGV[$i], 2); }
64 else { $colname = $ARGV[$i]; }
65 $colname = "\"$colname\"";
66 @ecs = ($colname, @ecs);
70 @ids_arr = ("", @ids_arr);
71 @matrix = (\@ids_arr, @matrix);
73 for (my $i = 0; $i <= $M; $i++) {
74 for (my $j = 0; $j < $n; $j++) { print "$matrix[$j][$i]\t"; }
75 print "$matrix[$n][$i]\n";