根据FPKM将基因分组

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/msw521sg/article/details/52671987

  基因表达量FPKM计算之后,可以根据其值分组。
  输入格式:

Geneid  UN003324    UN004629    UN011750    UN013498    UN016818    UN018363    UN018537    UN019619    UN019632    UN026711    UN054416    UN056756    UN058273
root_Z10_mean   0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 
root_Z13_mean   0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 
root_Z39_mean   0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 
stem_Z30_mean   0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 
stem_Z32_mean   0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 
stem_Z65_mean   0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 
leaf_Z10_mean   0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 
leaf_Z23_mean   0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 
leaf_Z71_mean   0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 
spike_Z32_mean  0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 
spike_Z39_mean  0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 
spike_Z65_mean  0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 
new_carpel  0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 
new_stamen  0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 
latet_lepto_mean    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 
diplo_dia_mean  0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 
zygo_pachy_mean 0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 
metaphaseI_mean 0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 
grain_Z71_mean  0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 
grain_Z75_mean  0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00 
grain_Z85_mean  0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  

  python代码:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

with open('rna_seq.txt', 'r') as f:
    print 'Tissue''\t''no''\t''low''\t''medium''\t''high'
    for line in f:
        if 'Geneid' not in line:
            line = line.strip().split()
            no = []
            low = []
            medium = []
            high = []
            for i in line[1:]:
                if float(i) < 0.02:
                    no.append(i)
                if 0.02 <= float(i) < 20:
                    low.append(i)
                if 20 <= float(i) < 50:
                    medium.append(i)
                if float(i) >= 50:
                    high.append(i)
            print '%s\t%d\t%d\t%d\t%d' % (line[0], len(no), len(low), len(medium), len(high))
展开阅读全文

没有更多推荐了,返回首页