File: venn_pairwise_summaries.pair_stats.pl

package info (click to toggle)
trinityrnaseq 2.11.0%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 417,528 kB
  • sloc: perl: 48,420; cpp: 17,749; java: 12,695; python: 3,124; sh: 1,030; ansic: 983; makefile: 688; xml: 62
file content (55 lines) | stat: -rwxr-xr-x 1,168 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env perl

use strict;
use warnings;

my $usage = "venn_pairwise_out.dat\n\n";

my $venn_txt = $ARGV[0] or die $usage;

main: {

    my %combos;
    
    my %sample_pair_to_combo_count;

    open (my $fh, $venn_txt) or die $!;

    while (<$fh>) {
        chomp;
        my ($feature, $sampleA, $sampleB, $combo) = split(/\t/);
        
        my @combo_renamed;
        foreach my $c (split(/,/, $combo)) {
            $c =~ /^([^\.]+)/ or die "Error, cannot parse combo $c";
            push (@combo_renamed, $1);
        }
        $combo = join(",", @combo_renamed);
        
        my $sample_pair = join(",", $sampleA, $sampleB);

        $sample_pair_to_combo_count{$sample_pair}->{$combo}++;
        $combos{$combo}++;
        
    }
    close $fh;

    my @combos = sort keys %combos;

    print join("\t", "#sample", @combos) . "\n";

    foreach my $sample_pair (sort keys %sample_pair_to_combo_count) {

        print $sample_pair;
        foreach my $combo (@combos) {
            my $val = $sample_pair_to_combo_count{$sample_pair}->{$combo} || 0;
            print "\t$val";
        }
        print "\n";
        
    }
    
    exit(0);
}