Mercurial > repos > iuc > calculate_contrast_threshold
annotate calculate_contrast_threshold.py @ 0:5320a0774e03 draft default tip
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
| author | iuc |
|---|---|
| date | Wed, 11 Sep 2019 09:28:31 -0400 |
| parents | |
| children |
| rev | line source |
|---|---|
|
0
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
1 #!/usr/bin/python |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
2 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
3 import getopt |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
4 import math |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
5 import sys |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
6 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
7 import numpy as np |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
8 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
9 """ |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
10 Program to calculate the contrast thresholds for heatmap from tagPileUp CDT |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
11 """ |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
12 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
13 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
14 def rebin(a, new_shape): |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
15 M, N = a.shape |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
16 m, n = new_shape |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
17 if m >= M: |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
18 # repeat rows in data matrix |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
19 a = np.repeat(a, math.ceil(float(m) / M), axis=0) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
20 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
21 M, N = a.shape |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
22 m, n = new_shape |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
23 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
24 row_delete_num = M % m |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
25 col_delete_num = N % n |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
26 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
27 np.random.seed(seed=0) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
28 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
29 if row_delete_num > 0: |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
30 # select deleted rows with equal intervals |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
31 row_delete = np.linspace(0, M - 1, num=row_delete_num, dtype=int) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
32 # sort the random selected deleted row ids |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
33 row_delete = np.sort(row_delete) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
34 row_delete_plus1 = row_delete[1:-1] + \ |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
35 1 # get deleted rows plus position |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
36 # get deleted rows plus position (top +1; end -1) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
37 row_delete_plus1 = np.append( |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
38 np.append(row_delete[0] + 1, row_delete_plus1), row_delete[-1] - 1) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
39 # put the info of deleted rows into the next rows by mean |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
40 a[row_delete_plus1, :] = ( |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
41 a[row_delete, :] + a[row_delete_plus1, :]) / 2 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
42 a = np.delete(a, row_delete, axis=0) # random remove rows |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
43 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
44 if col_delete_num > 0: |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
45 # select deleted cols with equal intervals |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
46 col_delete = np.linspace(0, N - 1, num=col_delete_num, dtype=int) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
47 # sort the random selected deleted col ids |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
48 col_delete = np.sort(col_delete) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
49 col_delete_plus1 = col_delete[1:-1] + \ |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
50 1 # get deleted cols plus position |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
51 # get deleted cols plus position (top +1; end -1) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
52 col_delete_plus1 = np.append( |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
53 np.append(col_delete[0] + 1, col_delete_plus1), col_delete[-1] - 1) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
54 # put the info of deleted cols into the next cols by mean |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
55 a[:, col_delete_plus1] = ( |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
56 a[:, col_delete] + a[:, col_delete_plus1]) / 2 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
57 a = np.delete(a, col_delete, axis=1) # random remove columns |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
58 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
59 M, N = a.shape |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
60 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
61 # compare the heatmap matrix |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
62 a_compress = a.reshape((m, int(M / m), n, int(N / n))).mean(3).mean(1) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
63 return np.array(a_compress) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
64 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
65 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
66 def load_Data(input_file, quantile, absolute, header, start_col, row_num, col_num, min_upper_lim): |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
67 data0 = [] |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
68 with open(input_file, 'r') as data: |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
69 if header == 'T': |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
70 data.readline() |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
71 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
72 for rec in data: |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
73 tmp = [(x.strip()) for x in rec.split('\t')] |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
74 data0.append(tmp[start_col:]) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
75 data0 = np.array(data0, dtype=float) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
76 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
77 if row_num == -999: |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
78 row_num = data0.shape[0] |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
79 if col_num == -999: |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
80 col_num = data0.shape[1] |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
81 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
82 # rebin data0 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
83 if row_num < data0.shape[0] and col_num < data0.shape[1]: |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
84 data0 = rebin(data0, (row_num, col_num)) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
85 elif row_num < data0.shape[0]: |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
86 data0 = rebin(data0, (row_num, data0.shape[1])) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
87 elif col_num < data0.shape[1]: |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
88 data0 = rebin(data0, (data0.shape[0], col_num)) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
89 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
90 # Calculate contrast limits here |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
91 rows, cols = np.nonzero(data0) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
92 upper_lim = np.percentile(data0[rows, cols], quantile) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
93 lower_lim = 0 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
94 if absolute != -999: |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
95 upper_lim = absolute |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
96 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
97 # Setting an absolute threshold to a minimum, |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
98 # in cases the 95th percentile contrast is <= user defined min_upper_lim |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
99 if quantile > 0.0: |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
100 print("\nQUANTILE: {}".format(quantile)) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
101 print("Quantile calculated UPPER LIM: {}".format(upper_lim)) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
102 print("LOWER LIM: {}".format(lower_lim)) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
103 if upper_lim <= min_upper_lim: |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
104 print("setting heatmap upper_threshold to min_upper_lim\n") |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
105 upper_lim = min_upper_lim |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
106 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
107 outfile = open('calcThreshold.txt', 'w') |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
108 outfile.write("upper_threshold:{}\nlower_threshold:{}\nrow_num:{}\ncol_num:{}\nheader:{}\nstart_col:{}".format( |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
109 upper_lim, lower_lim, row_num, col_num, header, start_col)) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
110 print('heatmap_upper_threshold:' + str(upper_lim)) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
111 print('heatmap_lower_threshold:' + str(lower_lim)) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
112 outfile.flush() |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
113 outfile.close() |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
114 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
115 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
116 ############################################################################ |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
117 # python cdt_to_heatmap.py -i test.tabular.split_line -o test.tabular.split_line.png -q 0.9 -c black -d T -s 2 -r 500 -l 300 -b test.colorsplit |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
118 ############################################################################ |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
119 usage = """ |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
120 Usage: |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
121 This script calculates the contrast thresholds from Tag pile up heatmap data. Outputs a text file that contains the parameters for the heatmap script. |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
122 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
123 python calculateThreshold.py -i <input file> -q <quantile> -m <min upper thresold after quantile calculation> -t <absolute tag threshold> -d <header T/F> -s <start column> -r <row num after compress> -l <col num after compress>' |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
124 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
125 Example: |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
126 python calculateThreshold.py -i test.tabular.split_line -q 90 -m 5 -d T -s 2 -r 600 -l 300 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
127 """ |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
128 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
129 if __name__ == '__main__': |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
130 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
131 # check for command line arguments |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
132 if len(sys.argv) < 2 or not sys.argv[1].startswith("-"): |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
133 sys.exit(usage) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
134 # get arguments |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
135 try: |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
136 optlist, alist = getopt.getopt(sys.argv[1:], 'hi:o:q:t:c:d:s:r:l:m:') |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
137 except getopt.GetoptError: |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
138 sys.exit(usage) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
139 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
140 # default quantile contrast saturation = 0.9 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
141 quantile = 90.0 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
142 min_upper_lim = 5.0 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
143 # absolute contrast saturation overrides quantile |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
144 absolute = -999 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
145 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
146 # default figure width/height is defined by matrix size |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
147 # if user-defined size is smaller than matrix, activate rebin function |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
148 row_num = -999 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
149 col_num = -999 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
150 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
151 for opt in optlist: |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
152 if opt[0] == "-h": |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
153 sys.exit(usage) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
154 elif opt[0] == "-i": |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
155 input_file = opt[1] |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
156 elif opt[0] == "-q": |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
157 quantile = float(opt[1]) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
158 elif opt[0] == '-t': |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
159 absolute = float(opt[1]) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
160 elif opt[0] == "-d": |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
161 header = opt[1] |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
162 elif opt[0] == "-s": |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
163 start_col = int(opt[1]) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
164 elif opt[0] == "-r": |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
165 row_num = int(opt[1]) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
166 elif opt[0] == "-l": |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
167 col_num = int(opt[1]) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
168 elif opt[0] == "-m": |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
169 min_upper_lim = float(opt[1]) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
170 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
171 print("Header present:", header) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
172 print("Start column:", start_col) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
173 print("Row number (pixels):", row_num) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
174 print("Col number (pixels):", col_num) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
175 print("Min Upper Limit while using Quantile:", min_upper_lim) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
176 if absolute != -999: |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
177 print("Absolute tag contrast threshold:", absolute) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
178 else: |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
179 print("Percentile tag contrast threshold:", quantile) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
180 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
181 if absolute == -999 and quantile <= 0: |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
182 print("\nInvalid threshold!!!") |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
183 sys.exit(usage) |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
184 |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
185 load_Data(input_file, quantile, absolute, |
|
5320a0774e03
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff
changeset
|
186 header, start_col, row_num, col_num, min_upper_lim) |
