annotate ipfp_normalisation.py @ 0:8b5e4ea144a5 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
author iuc
date Tue, 04 Feb 2025 09:11:16 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
1 #!/usr/bin/env python
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
2 """
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
3 IPFP Normalisation
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
4 """
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
5 import argparse
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
6 import sys
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
7
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
8 import numpy as np
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
9
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
10
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
11 def throw_error(msg, exit_code=1):
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
12 sys.stderr.write(msg)
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
13 sys.exit(exit_code)
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
14
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
15
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
16 def ipfp(data, precision=1e-5, maxIterations=50):
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
17 """
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
18 Return the normalized version of the input data (matrix) as an ndarray
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
19 :param data: np.ndArray
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
20 :param precision: float combined allowed deviation (residual error) of col and row means from TARGET (=1)
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
21 :param maxIterations: int maximum amount of iterations (1x row and 1x col per iteration)
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
22 :return normalizedData: np.ndArray normalized data
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
23 """
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
24 try:
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
25 assert isinstance(data, np.ndarray) and data.dtype in ['float64', 'int64']
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
26 assert precision > 0
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
27 assert isinstance(maxIterations, int) and maxIterations > 0
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
28 except AssertionError:
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
29 throw_error("Invalid input parameters. Please check that the input data consists of floats or integers, precision > 0 and maxIterations is a positive integer.")
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
30 # replace zeros with nan
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
31 if (data < 0).any():
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
32 throw_error("Negative values detected, only use positive values.")
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
33
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
34 zeros = (data == 0)
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
35 if zeros.any():
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
36 print("Zero values detected; replacing with NA.")
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
37 data = data.astype(float)
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
38 data[zeros] = np.nan
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
39
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
40 # initialize variables
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
41 Nrows, Ncols = data.shape
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
42 convergenceTrail = np.asarray([np.nan] * (2 * maxIterations))
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
43 convergence = np.inf
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
44 normalized_data = data
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
45 TARGET = 1
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
46
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
47 i = 0 # number of current iteration
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
48 # without reshaping the ndarrays, they have shape (x,) (no second value) and the procedure fails.
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
49 # main loop; iterates until convergence is reached (i.e., L1-norm below variable <h>) or the maximum number of
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
50 # iteration cycles is surpassed.
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
51 while convergence > precision and i < maxIterations:
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
52 # fit the rows
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
53 Ri = TARGET * np.asarray(1 / np.nanmean(normalized_data, 1)).reshape(Nrows,)
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
54 normalized_data = (normalized_data.T * Ri).T
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
55
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
56 # calculate deviation from column marginals; row deviation is zero at even indices. (index start = 0)
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
57 convergenceTrail[2 * i] = Nrows * 0.5 * np.nansum(np.abs(np.nanmean(normalized_data, 0) - TARGET))
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
58
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
59 # fit the columns
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
60 Si = TARGET * np.asarray(1 / np.nanmean(normalized_data, 0)).reshape(Ncols,)
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
61 normalized_data *= Si
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
62 # calculate deviation from row marginals; column deviation is zero at odd indices. (index start = 0)
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
63 convergenceTrail[2 * i + 1] = Ncols * 0.5 * np.nansum(np.abs(np.nanmean(normalized_data, 1) - TARGET))
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
64
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
65 convergence = convergenceTrail[2 * i + 1]
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
66 i += 1
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
67
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
68 if i == maxIterations:
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
69 throw_error(f"Max number of IPFP iterations ({maxIterations}) reached. Attained precision: {convergence}.")
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
70
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
71 return normalized_data
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
72
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
73
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
74 def main():
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
75 parser = argparse.ArgumentParser(description="IPFP Normalisation")
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
76 parser.add_argument('-i', '--input', help="Input file", required=True, metavar="FILE")
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
77 parser.add_argument('-p', '--precision', help="Precision", default=1e-5, type=float)
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
78 parser.add_argument('-m', '--maxIterations', help="Max iterations", default=50, type=int)
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
79 parser.add_argument('-s', '--skipHeaders', help="Skip headers, skips the first n lines", default=0, type=int)
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
80
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
81 args = parser.parse_args()
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
82
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
83 try:
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
84 data = np.genfromtxt(args.input, skip_header=args.skipHeaders, filling_values=np.nan, delimiter='\t')
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
85 normalized_data = ipfp(data, args.precision, args.maxIterations)
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
86 np.savetxt("output.tsv", normalized_data, delimiter='\t')
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
87
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
88 except Exception as e:
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
89 throw_error(str(e))
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
90
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
91
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
92 if __name__ == "__main__":
8b5e4ea144a5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ipfp_normalisation commit 1facbf5b9d74f0f7cd1f9346acb405a2e327c639
iuc
parents:
diff changeset
93 main()