To merge the TPM value generated by run-featurecounts.R, run the following code:
1. Data format
head Leaf.count
gene_id counts fpkm tpm
LOC_Os01g01010 110 0.945530723017136 2.29771048604873
LOC_Os01g01019 1 0.0231100918830517 0.0561592544383935
LOC_Os01g01030 4 0.0422809635587651 0.102745908688424
LOC_Os01g01040 49 0.480138677222636 1.16677295254003
LOC_Os01g01050 33 0.421523995695231 1.02433488563918
LOC_Os01g01060 37 1.04746491459932 2.54541820742018
LOC_Os01g01070 24 0.330032611009917 0.80200396729127
LOC_Os01g01080 82 1.03523801807094 2.51570593294702
LOC_Os01g01090 0 0 0
2. Script
#usr/bin/perl -w
use strict;
my ($sample_list)=@ARGV;
my @sample_list=split (",",$sample_list); # list the input file in "," sperated
#print "@sample_list\n";
my %read_count;
foreach my $sample(@sample_list)
{
open SAMPLE, $sample or die "$!";
while (my $line=<SAMPLE>)
{
chomp $line;
my($gene_id,$count,$fpkm,$tpm)=split("\t",$line);
push @{$read_count{$gene_id}},$tpm;
}
}
print "gene_id\t",join ("\t",@sample_list),"\n";
foreach (keys %read_count)
{
my @count =@{$read_count{$_}};
print "$_\t",join("\t",@count),"\n";
}
Run the code:
perl merge_reads_counts.pl Leaf.count,sperm.count,whole_root.count |head
# Leaf.count,sperm.count,whole_root.count were seperated by ,
Results:
gene_id Leaf.count sperm.count whole_root.count
LOC_Os02g54490 0.0537507259040929 0.31463009388691 0.591264432584185
LOC_Os08g24870 0.010532780787497 0 0
LOC_Os05g16040 0 0 0
LOC_Os12g29280 0 0 0.459882614309195
LOC_Os11g36090 0.0186041974579863 0 0.0170540336411885
LOC_Os07g43800 0 0.44899492265031 19.8109637625006
LOC_Os02g15390 0 0 0.125988756671712
LOC_Os09g21140 0 0 0
LOC_Os02g11060 0.341296176014754 0.69763695815633 2.6766760505955
验证
grep LOC_Os02g54490 whole_root.count|awk '{print $4}'
0.591264432584185
grep LOC_Os02g54490 sperm.count|awk '{print $4}'
0.31463009388691
grep LOC_Os02g54490 Leaf.count|awk '{print $4}'
0.0537507259040929
......................................................................................
grep LOC_Os11g36090 Leaf.count|awk '{print $4}'
0.0186041974579863
grep LOC_Os11g36090 sperm.count|awk '{print $4}'
0
grep LOC_Os11g36090 whole_root.count|awk '{print $4}'
0.0170540336411885
网友评论