@@ -32,6 +32,7 @@ def uORF_change(uORFrowIn, ORFreadsIn):
32
32
changesum = 0
33
33
cond1_ratios = []
34
34
cond2_ratios = []
35
+ changes = []
35
36
for replicate in range (0 , replicate_number ):
36
37
uORFCond1 = uORFrow [replicate ] + 1
37
38
orfCond1 = ORFreads [replicate ] + 1
@@ -42,6 +43,7 @@ def uORF_change(uORFrowIn, ORFreadsIn):
42
43
ratio2 = orfCond2 / uORFCond2
43
44
cond2_ratios .append (ratio2 )
44
45
change = ratio1 / ratio2
46
+ changes .append (change )
45
47
uorf1sum += uORFCond1
46
48
orf1sum += orfCond1
47
49
uorf2sum += uORFCond2
@@ -53,7 +55,7 @@ def uORF_change(uORFrowIn, ORFreadsIn):
53
55
averageORF2 = orf2sum / replicate_number
54
56
averagechange = changesum / replicate_number
55
57
logaveragechange = math .log2 (averagechange )
56
- return (cond1_ratios ,cond2_ratios ,logaveragechange )
58
+ return (cond1_ratios ,cond2_ratios ,changes , logaveragechange )
57
59
58
60
def uORF_changes (uorf_table , uorf_reads_dict , orf_reads_dict ):
59
61
output = []
@@ -62,13 +64,12 @@ def uORF_changes(uorf_table, uorf_reads_dict, orf_reads_dict):
62
64
ORFid = uORFrow ['transcript_id' ]
63
65
uORFreads = uorf_reads_dict [uORFid ]
64
66
ORFreads = orf_reads_dict [ORFid ]
65
- (cond1ratios ,cond2ratios ,logaveragechange ) = uORF_change (uORFreads , ORFreads )
67
+ (cond1ratios ,cond2ratios ,changes , logaveragechange ) = uORF_change (uORFreads , ORFreads )
66
68
annotation_row = '\t ' .join (map (str , uORFrow ))
67
69
cond1ratiosstring = '\t ' .join (map (str ,cond1ratios ))
68
70
cond2ratiosstring = '\t ' .join (map (str ,cond2ratios ))
69
- stdratios1 = str (np .std (cond1ratios ))
70
- stdratios2 = str (np .std (cond2ratios ))
71
- uORF_changes_string = annotation_row + "\t " + cond1ratiosstring + "\t " + cond2ratiosstring + "\t " + stdratios1 + "\t " + stdratios2 + "\t " + str (logaveragechange ) + "\n "
71
+ stdchanges = str (np .std (changes ))
72
+ uORF_changes_string = annotation_row + "\t " + cond1ratiosstring + "\t " + cond2ratiosstring + "\t " + stdchanges + "\t " + str (logaveragechange )
72
73
output .append (uORF_changes_string )
73
74
return (output )
74
75
@@ -103,7 +104,7 @@ def main():
103
104
replicate_number = math .ceil (len (uorf_reads .columns )/ 2 )
104
105
changes_list = uORF_changes (df_final , uorf_reads_dict , orf_reads_dict )
105
106
ratios_header = create_ratio_header (replicate_number )
106
- changes_header = "coordinates\t gene_symbol\t transcript_id\t uORF_id\t " + ratios_header + "\t std_ratios_cond1 \t stdratios_cond2 \t log2FC_main_ORF_to_uORF_ratios\n "
107
+ changes_header = "coordinates\t gene_symbol\t transcript_id\t uORF_id\t " + ratios_header + "\t std_main_ORF_to_uORF_ratios \t log2FC_main_ORF_to_uORF_ratios\n "
107
108
changes_string = changes_header + '\n ' .join (map (str , changes_list ))
108
109
f = open (args .output_csv_filepath , 'wt' , encoding = 'utf-8' )
109
110
f .write (changes_string )
0 commit comments