annotate calculate_contrast_threshold.py @ 0:7371bb087d86 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:55 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
7371bb087d86 "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
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
2
7371bb087d86 "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
7371bb087d86 "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
7371bb087d86 "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
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
6
7371bb087d86 "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
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
8
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
9 """
7371bb087d86 "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
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
11 """
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
12
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
13
7371bb087d86 "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):
7371bb087d86 "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
7371bb087d86 "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
7371bb087d86 "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:
7371bb087d86 "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
7371bb087d86 "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)
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
20
7371bb087d86 "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
7371bb087d86 "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
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
23
7371bb087d86 "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
7371bb087d86 "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
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
26
7371bb087d86 "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)
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
28
7371bb087d86 "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:
7371bb087d86 "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
7371bb087d86 "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)
7371bb087d86 "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
7371bb087d86 "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)
7371bb087d86 "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] + \
7371bb087d86 "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
7371bb087d86 "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)
7371bb087d86 "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(
7371bb087d86 "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)
7371bb087d86 "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
7371bb087d86 "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, :] = (
7371bb087d86 "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
7371bb087d86 "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
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
43
7371bb087d86 "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:
7371bb087d86 "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
7371bb087d86 "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)
7371bb087d86 "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
7371bb087d86 "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)
7371bb087d86 "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] + \
7371bb087d86 "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
7371bb087d86 "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)
7371bb087d86 "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(
7371bb087d86 "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)
7371bb087d86 "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
7371bb087d86 "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] = (
7371bb087d86 "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
7371bb087d86 "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
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
58
7371bb087d86 "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
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
60
7371bb087d86 "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
7371bb087d86 "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)
7371bb087d86 "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)
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
64
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
65
7371bb087d86 "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):
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
67 data0 = []
7371bb087d86 "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:
7371bb087d86 "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':
7371bb087d86 "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()
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
71
7371bb087d86 "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:
7371bb087d86 "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')]
7371bb087d86 "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:])
7371bb087d86 "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)
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
76
7371bb087d86 "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:
7371bb087d86 "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]
7371bb087d86 "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:
7371bb087d86 "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]
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
81
7371bb087d86 "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
7371bb087d86 "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]:
7371bb087d86 "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))
7371bb087d86 "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]:
7371bb087d86 "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]))
7371bb087d86 "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]:
7371bb087d86 "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))
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
89
7371bb087d86 "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
7371bb087d86 "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)
7371bb087d86 "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)
7371bb087d86 "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
7371bb087d86 "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:
7371bb087d86 "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
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
96
7371bb087d86 "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,
7371bb087d86 "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
7371bb087d86 "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:
7371bb087d86 "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))
7371bb087d86 "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))
7371bb087d86 "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))
7371bb087d86 "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:
7371bb087d86 "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")
7371bb087d86 "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
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
106
7371bb087d86 "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')
7371bb087d86 "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(
7371bb087d86 "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))
7371bb087d86 "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))
7371bb087d86 "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))
7371bb087d86 "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()
7371bb087d86 "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()
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
114
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
115
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
116 ############################################################################
7371bb087d86 "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
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
118 ############################################################################
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
119 usage = """
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
120 Usage:
7371bb087d86 "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.
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
122
7371bb087d86 "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>'
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
124
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
125 Example:
7371bb087d86 "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
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
127 """
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
128
7371bb087d86 "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__':
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
130
7371bb087d86 "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
7371bb087d86 "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("-"):
7371bb087d86 "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)
7371bb087d86 "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
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
135 try:
7371bb087d86 "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:')
7371bb087d86 "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:
7371bb087d86 "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)
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
139
7371bb087d86 "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
7371bb087d86 "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
7371bb087d86 "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
7371bb087d86 "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
7371bb087d86 "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
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
145
7371bb087d86 "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
7371bb087d86 "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
7371bb087d86 "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
7371bb087d86 "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
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
150
7371bb087d86 "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:
7371bb087d86 "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":
7371bb087d86 "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)
7371bb087d86 "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":
7371bb087d86 "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]
7371bb087d86 "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":
7371bb087d86 "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])
7371bb087d86 "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':
7371bb087d86 "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])
7371bb087d86 "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":
7371bb087d86 "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]
7371bb087d86 "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":
7371bb087d86 "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])
7371bb087d86 "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":
7371bb087d86 "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])
7371bb087d86 "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":
7371bb087d86 "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])
7371bb087d86 "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":
7371bb087d86 "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])
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
170
7371bb087d86 "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)
7371bb087d86 "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)
7371bb087d86 "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)
7371bb087d86 "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)
7371bb087d86 "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)
7371bb087d86 "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:
7371bb087d86 "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)
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
178 else:
7371bb087d86 "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)
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
180
7371bb087d86 "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:
7371bb087d86 "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!!!")
7371bb087d86 "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)
7371bb087d86 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/calculate_contrast_threshold commit 6ba8e678f8cedabaf9b4759cddb81b8b3cd9ec31"
iuc
parents:
diff changeset
184
7371bb087d86 "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,
7371bb087d86 "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)