本篇内容主要讲解“perl怎么画韦恩图”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“perl怎么画韦恩图”吧!
用法如下:
perl venn_up_or_down.pl -in All_DEG_venn.xls -id1 left_DEG.final.xls -id2 right_DEG.final.xls -k trans_full_table.xls -od out
该脚本的输入文件都为转录组分析结果文件,All_DEG_venn.xls是画韦恩图时生成的,*_DEG.final.xls分别是两个差异组合的。trans_full_table.xls是总的所有基因统计文件。
Usage Forced parameter: -in All_DEG_venn.xls <infile> must be given -od outdir <dir> must be given -id1 left DEG.final.xls <infile> must be given -id2 right DEG.final.xls <infile> must be given -k noRef_trans_full_table.xls (kegg anno) <infile> must be given Other parameter: -h Help document
脚本代码:
#!/usr/bin/perl -w use strict; use warnings; use Getopt::Long; use Data::Dumper; use Config::General; use Cwd qw(abs_path getcwd); use FindBin qw($Bin $Script); use File::Basename qw(basename dirname); use Math::BigFloat; use Bio::SeqIO; use Bio::Seq; my $version = "1.3"; ## prepare parameters ####################################################################### ## ------------------------------------------------------------------------------------------- ## GetOptions my %opts; GetOptions(\%opts, "in=s", "id1=s", "id2=s", "k=s", "od=s","h"); if(!defined($opts{in}) || !defined($opts{id1}) || !defined($opts{k}) || !defined($opts{id2}) || !defined($opts{od}) ||defined($opts{h})) { print <<"Usage End."; Description: $version:lefse analysis Usage Forced parameter: -inAll_DEG_venn.xls<infile> must be given -od outdir <dir> must be given -id1 left DEG.final.xls <infile> must be given -id2 right DEG.final.xls <infile> must be given -k noRef_trans_full_table.xls (kegg anno) Other parameter: -h Help document Usage End. exit; } open(IN,"$opts{in}")||die "open file $opts{in} failed.\n"; my %left; my %right; my %center; while(<IN>){ next if(/^all_id/); chomp; my @line = split ("\t",$_); if($line[1] ne "-" && $line[2] eq "-"){ $left{$line[0]} = $line[0]; } if($line[1] eq "-" && $line[2] ne "-"){ $right{$line[0]} = $line[0]; } if($line[1] ne "-" && $line[2] ne "-"){ $center{$line[0]} = $line[0]; } } close(IN); open(IN,"$opts{k}") || die "open file $opts{k} failed.\n"; open(ID1,"$opts{id1}")||die "open file $opts{id1} failed.\n"; open(ID2,"$opts{id2}")||die "open file $opts{id2} failed.\n"; my %kegg; while(<IN>){ chomp; my @line = split("\t"); if(/^#/){print "$line[23]\n\n";} $kegg{$line[0]} = $line[23]; } close(IN); my %deg1; while(<ID1>){ next if(/^#/); chomp; my @line = split("\t"); $deg1{$line[0]} = $_; } close(ID1); my %deg2; while(<ID2>){ next if(/^#/); chomp; my @line = split("\t"); $deg2{$line[0]} = $_; } close(ID2); open(UP,">$opts{od}/left_up.txt")||die "open file $opts{od}/left_up.txt failed.\n"; open(DOWN,">$opts{od}/left_down.txt")||die "open file $opts{od}/left_down.txt failed.\n"; while((my $key,my $value) = each %left){ my @line = split("\t",$deg1{$key}); if($line[7] eq "up"){ print UP "$deg1{$key}\t$kegg{$key}\n"; } if($line[7] eq "down"){ print DOWN "$deg1{$key}\t$kegg{$key}\n"; } } close(UP); close(DOWN); open(UP,">$opts{od}/right_up.txt")||die "open file $opts{od}/right_up.txt failed.\n"; open(DOWN,">$opts{od}/right_down.txt")||die "open file $opts{od}/right_down.txt failed.\n"; while((my $key,my $value) = each %right){ my @line = split("\t",$deg2{$key}); if($line[7] eq "up"){ print UP "$deg2{$key}\t$kegg{$key}\n"; } if($line[7] eq "down"){ print DOWN "$deg2{$key}\t$kegg{$key}\n"; } } close(UP); close(DOWN); open(UP,">$opts{od}/center_up.txt")||die "open file $opts{od}/center_up.txt failed.\n"; open(DOWN,">$opts{od}/center_down.txt")||die "open file $opts{od}/center_down.txt failed.\n"; open(DIFF,">$opts{od}/center_diff.txt")||die "open file $opts{od}/center_diff.txt failed.\n"; while((my $key,my $value) = each %center){ my @line1 = split("\t",$deg1{$key}); my @line2 = split("\t",$deg2{$key}); if($line1[7] eq "up" && $line2[7] eq "up"){ print UP "$deg1{$key}\t$deg2{$key}\t$kegg{$key}\n"; }elsif($line1[7] eq "down" && $line2[7] eq "down"){ print DOWN "$deg1{$key}\t$deg2{$key}\t$kegg{$key}\n"; }else{ print DIFF "$deg1{$key}\t$deg2{$key}\t$kegg{$key}\n"; } } close(UP); close(DOWN); close(DIFF);
到此,相信大家对“perl怎么画韦恩图”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。