-#!/usr/bin/perl
+#!/usr/bin/env perl
use strict;
if (scalar(@ARGV) == 0) {
- print "Usage: rsem-generate-data-matrix sampleA.[genes/isoforms].results sampleB.[genes/isoforms].results ... > output_name.matrix\n";
- print "Results files should be either all .genes.results or all .isoforms.results.\n";
+ print "Usage: rsem-generate-data-matrix sampleA.[alleles/genes/isoforms].results sampleB.[alleles/genes/isoforms].results ... > output_name.matrix\n";
+ print "All result files should have the same file type. The 'TPM' columns of every result file are extracted to form the data matrix.\n";
exit(-1);
}
my $offsite = 4; # for new file formats
+if ($ARGV[0] =~ /alleles.results$/) { $offsite = 5; }
my $line;
my $n = scalar(@ARGV);
while ($line = <INPUT>) {
chomp($line);
my @fields = split(/\t/, $line);
- push(@{$_[2]}, $fields[0]);
+ push(@{$_[2]}, "\"$fields[0]\"");
push(@{$_[1]}, $fields[$offsite]);
}
close(INPUT);
exit(-1);
}
- @ecs = ($ARGV[$i], @ecs);
+ my $colname;
+ if (substr($ARGV[$i], 0, 2) eq "./") { $colname = substr($ARGV[$i], 2); }
+ else { $colname = $ARGV[$i]; }
+ $colname = "\"$colname\"";
+ @ecs = ($colname, @ecs);
push(@matrix, \@ecs);
}