Skip to content

Commit ef7fb3d

Browse files
authored
Merge pull request #5 from Biochemistry1-FFM/ratiolist
Ratiolist
2 parents 961c988 + 100d363 commit ef7fb3d

File tree

3 files changed

+44
-39
lines changed

3 files changed

+44
-39
lines changed

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,9 @@ Installation is described below, for usage please refer to the [Userguide](https
66

77
### <u>Installation via bioconda</u>
88

9-
uORF-Tools requires snakemake (Version=5.4.2), which can be installed with all dependencies via [conda](https://conda.io/projects/conda/en/latest/user-guide/install/index.html). Once you have conda installed simply type:
9+
uORF-Tools requires snakemake (Version=5.4.5), which can be installed with all dependencies via [conda](https://conda.io/projects/conda/en/latest/user-guide/install/index.html). Once you have conda installed simply type:
1010

11-
$ conda create -c conda-forge -c bioconda -n snakemake snakemake==5.4.2
12-
13-
**IMPORTANT!!!** The workflow relies on an older version of conda. To change your conda version type:
14-
15-
$ conda install -n base conda=4.5.13
11+
$ conda create -c conda-forge -c bioconda -n snakemake snakemake==5.4.5
1612

1713
$ source activate
1814

changelog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
-*-change-log-*-
2+
3.1.0 Florian Eggenhofer <egg@informatik.uni-freiburg.de> 17. April 2019
3+
* Replaced average reads with uORF/ORF ratios for each replicate
4+
3.0.0 Rick Gelhausen <gelhausr@informatik.uni-freiburg.de> 8. March 2019
5+
* the workflow now uses .bam files as input.
6+
* A second workflow (Preprocessing_Snakefile) is now available to convert .fastq to .bam files.
7+
* all tool versions used are now fixed in order to ensure reproducibility and easier maintenance.
8+
* some conda environment changes ensure faster runtimes.
29
2.0.0 Florian Eggenhofer <egg@informatik.uni-freiburg.de> 21.December 2018
310
* New streamlined ribosome-profiling workflow
411
* Added computation of ribo_change parameter

scripts/final_table.py

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,65 +8,65 @@
88
import math
99
import numpy as np
1010

11+
def create_ratio_header(replicate_number):
12+
replicate_cond1 = []
13+
replicate_cond2 = []
14+
for replicate in range(1, replicate_number+1):
15+
cond1 = "Ratio-A-" + str(replicate)
16+
replicate_cond1.append(cond1)
17+
cond2 = "Ratio-B-" + str(replicate)
18+
replicate_cond2.append(cond2)
19+
cond1string = '\t'.join(map(str,replicate_cond1))
20+
cond2string = '\t'.join(map(str,replicate_cond2))
21+
replicate_header = cond1string + "\t" + cond2string
22+
return replicate_header
1123

1224
def uORF_change(uORFrowIn, ORFreadsIn):
1325
uORFrow = uORFrowIn
1426
ORFreads = ORFreadsIn
15-
replicates = math.ceil(len(uORFrow)/2)
27+
replicate_number = math.ceil(len(uORFrow)/2)
1628
uorf1sum = 0
1729
orf1sum = 0
1830
uorf2sum = 0
1931
orf2sum = 0
2032
changesum = 0
21-
for replicate in range(0, replicates):
33+
cond1_ratios = []
34+
cond2_ratios = []
35+
for replicate in range(0, replicate_number):
2236
uORFCond1 = uORFrow[replicate] + 1
2337
orfCond1 = ORFreads[replicate] + 1
24-
uORFCond2 = uORFrow[replicate + replicates] + 1
25-
orfCond2 = ORFreads[replicate + replicates] + 1
38+
uORFCond2 = uORFrow[replicate + replicate_number] + 1
39+
orfCond2 = ORFreads[replicate + replicate_number] + 1
2640
ratio1 = orfCond1 / uORFCond1
41+
cond1_ratios.append(ratio1)
2742
ratio2 = orfCond2 / uORFCond2
43+
cond2_ratios.append(ratio2)
2844
change = ratio1 / ratio2
2945
uorf1sum += uORFCond1
3046
orf1sum += orfCond1
3147
uorf2sum += uORFCond2
3248
orf2sum += orfCond2
3349
changesum += change
34-
averageuORF1 = uorf1sum / replicates
35-
averageORF1 = orf1sum / replicates
36-
averageuORF2 = uorf2sum / replicates
37-
averageORF2 = orf2sum / replicates
38-
averagechange = changesum / replicates
50+
averageuORF1 = uorf1sum / replicate_number
51+
averageORF1 = orf1sum / replicate_number
52+
averageuORF2 = uorf2sum / replicate_number
53+
averageORF2 = orf2sum / replicate_number
54+
averagechange = changesum / replicate_number
3955
logaveragechange = math.log2(averagechange)
40-
return (averagechange,averageuORF1,averageORF1,averageuORF2,averageORF2,logaveragechange)
56+
return (cond1_ratios,cond2_ratios,logaveragechange)
4157

4258
def uORF_changes(uorf_table, uorf_reads_dict, orf_reads_dict):
43-
averagechanges = []
44-
averageuORF1s = []
45-
averageORF1s = []
46-
averageuORF2s = []
47-
averageORF2s = []
48-
logaveragechanges = []
59+
output = []
4960
for _, uORFrow in uorf_table.iterrows():
5061
uORFid = uORFrow['uORFids']
5162
ORFid = uORFrow['transcript_id']
5263
uORFreads = uorf_reads_dict[uORFid]
5364
ORFreads = orf_reads_dict[ORFid]
54-
(averagechange,averageuORF1,averageORF1,averageuORF2,averageORF2,logaveragechange) = uORF_change(uORFreads, ORFreads)
55-
averageuORF1s.append(averageuORF1)
56-
averageORF1s.append(averageORF1)
57-
averageuORF2s.append(averageuORF2)
58-
averageORF2s.append(averageORF2)
59-
averagechanges.append(averagechange)
60-
logaveragechanges.append(logaveragechange)
61-
uorf_table['averageuORF1'] = averageuORF1s
62-
uorf_table['averageORF1'] = averageORF1s
63-
uorf_table['averageuORF2'] = averageuORF2s
64-
uorf_table['averageORF2'] = averageORF2s
65-
uorf_table['logaveragechange'] = logaveragechanges
66-
output = []
67-
for _, uORFrow2 in uorf_table.iterrows():
68-
joined_row = '\t'.join(map(str, uORFrow2))
69-
uORF_changes_string = joined_row
65+
(cond1ratios,cond2ratios,logaveragechange) = uORF_change(uORFreads, ORFreads)
66+
annotation_row = '\t'.join(map(str, uORFrow))
67+
cond1ratiosstring = '\t'.join(map(str,cond1ratios))
68+
cond2ratiosstring = '\t'.join(map(str,cond2ratios))
69+
uORF_changes_string=annotation_row + "\t" + cond1ratiosstring + "\t" + cond2ratiosstring + "\t" + str(logaveragechange)
7070
output.append(uORF_changes_string)
7171
return (output)
7272

@@ -98,8 +98,10 @@ def main():
9898
orf_reads.columns = orf_cols
9999
orf_reads_dict = orf_reads.set_index('ID').T.to_dict('list')
100100
df_final = create_output(args)
101+
replicate_number = math.ceil(len(uorf_reads.columns)/2)
101102
changes_list = uORF_changes(df_final, uorf_reads_dict, orf_reads_dict)
102-
changes_header = "coordinates\tgene_symbol\ttranscript_id\tuORF_id\tmean_reads_uORF_c1\tmean_reads_ORF_c1\tmean_reads_uORF_c2\tmean_reads_ORF_c2\tlog2FC_main_ORF_to_uORF_ratios\n"
103+
ratios_header = create_ratio_header(replicate_number)
104+
changes_header = "coordinates\tgene_symbol\ttranscript_id\tuORF_id\t" + ratios_header + "\tlog2FC_main_ORF_to_uORF_ratios\n"
103105
changes_string = changes_header + '\n'.join(map(str, changes_list))
104106
f = open(args.output_csv_filepath, 'wt', encoding='utf-8')
105107
f.write(changes_string)

0 commit comments

Comments
 (0)