-
Notifications
You must be signed in to change notification settings - Fork 3
/
join_replicates.py
executable file
·54 lines (49 loc) · 1.13 KB
/
join_replicates.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
import argparse
import lib.parse_matrix as pm
parser = argparse.ArgumentParser(
description = 'Join multiple replicates into one matrix file'
)
parser.add_argument(
'-i',
nargs = '+',
required = True,
help = 'Input matrices'
)
parser.add_argument(
'-o',
required = True,
help = 'Output matrix'
)
parser.add_argument(
'--inputs-have-headers',
dest = 'header',
action = 'store_true',
help = 'Whether the input matrices have a header line. '
'Omit if they do not have a header line'
)
parser.add_argument(
'--replicates',
nargs = '+',
required = True,
help = 'condition.replicate value for each input matrix. '
'Example: 1.1 1.2 2.1 2.2'
)
parser.add_argument(
'--comments',
nargs = '+',
default = '',
help = 'Comments, in quotes, separated by spaces. '
'Example: "tissue: muscle" "days: 12"'
)
args = parser.parse_args()
matrices = [
pm.import_sparse_matrix(
input,
header = args.header
) for input in args.i
]
matrix = pm.join_matrices(*matrices)
matrix['replicates'] = args.replicates
matrix['comments'] = args.comments
pm.export_matrix(matrix, args.o)