Perl 矩阵排序(根据TCGA的样品信息)

#!/usr/bin/perl -w
use strict;
use warnings;

my $usage=<<USAGE;
Usage:
    perl dz_merge.pl /path/to/inutfile /path/to/outfile
USAGE
if(@ARGV==0){die $usage};

my $file1=$ARGV[0];
my $file2=$ARGV[1];
my @normalsample;
my @tumorsample;
my @normalindex;
my @tumorindex;
my %gene_exp;

open(RF,$file1) || die "can't open $file1";
while(my $line=<RF>){
    chomp($line);
    my @arr=split("\t",$line);
    if ($.==1){
        for my $i (1..$#arr){
            my @sample=split("-",$arr[$i]);
            if ($sample[3]=~/^1/){
                push(@normalsample,$arr[$i]);
                push(@normalindex,$i);
            }elsif($sample[3]=~/^0/){
                push(@tumorsample,$arr[$i]);
                push(@tumorindex,$i);
            }
        }
    }
}
close(RF);

open(RF,$file1) || die $!;
open(WF,">".$file2) || die $!;
print WF "id\t",join("\t",@normalsample),"\t",join("\t",@tumorsample),"\n";
while(my $line=<RF>){
    next if ($.==1);
    chomp($line);
    my @arr=split("\t",$line);
    print WF $arr[0];
    for my $i (0..$#normalindex){
        print WF "\t",$arr[$normalindex[$i]];
    }
    for my $j (0..$#tumorindex){
        print WF "\t",$arr[$tumorindex[$j]]
    }
    print WF "\n";
}
close(RF);
close(WF);
此条目发表在Perl, TCGA分类目录。将固定链接加入收藏夹。

Perl 矩阵排序(根据TCGA的样品信息)》有4条回应

  1. Jeremy-bin说:

    请问会出ensemble_ID转换为gene_symbol的perl脚本吗?刚接触TCGA,感觉数据合并整理比较麻烦,希望up主能提供点经验和资源分享,谢谢!

发表评论

电子邮件地址不会被公开。 必填项已用*标注

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

Protected with IP Blacklist CloudIP Blacklist Cloud