5 if (scalar(@ARGV) == 0) {
6 print "Usage: rsem-generate-data-matrix sampleA.[alleles/genes/isoforms].results sampleB.[alleles/genes/isoforms].results ... > output_name.matrix\n";
7 print "All result files should have the same file type. The 'expected_count' columns of every result file are extracted to form the data matrix.\n";
11 my $offsite = 4; # for new file formats
12 if ($ARGV[0] =~ /alleles.results$/) { $offsite = 5; }
15 my $n = scalar(@ARGV);
19 # 0, file_name; 1, reference of expected count array; 2, reference of transcript_id/gene_id array
22 my $line = <INPUT>; # The first line contains only column names
23 while ($line = <INPUT>) {
25 my @fields = split(/\t/, $line);
26 push(@{$_[2]}, "\"$fields[0]\"");
27 push(@{$_[1]}, $fields[$offsite]);
31 if (scalar(@{$_[1]}) == 0) {
32 print STDERR "Nothing is detected! $_[0] may not exist or is empty.\n";
37 #0, M; 1, reference of @ids_arr; 2, reference of @ids
40 for (my $i = 0; $i < $size; $i++) {
41 if ($_[1]->[$i] ne $_[2]->[$i]) {
50 for (my $i = 0; $i < $n; $i++) {
52 &loadData($ARGV[$i], \@ecs, \@ids);
58 elsif (!&check($M, \@ids_arr, \@ids)) {
59 print STDERR "Number of lines among samples are not equal!\n";
64 if (substr($ARGV[$i], 0, 2) eq "./") { $colname = substr($ARGV[$i], 2); }
65 else { $colname = $ARGV[$i]; }
66 $colname = "\"$colname\"";
67 @ecs = ($colname, @ecs);
71 @ids_arr = ("", @ids_arr);
72 @matrix = (\@ids_arr, @matrix);
74 for (my $i = 0; $i <= $M; $i++) {
75 for (my $j = 0; $j < $n; $j++) { print "$matrix[$j][$i]\t"; }
76 print "$matrix[$n][$i]\n";