forked from yal054/snATAC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnATAC.vstack.py
More file actions
executable file
·36 lines (30 loc) · 845 Bytes
/
snATAC.vstack.py
File metadata and controls
executable file
·36 lines (30 loc) · 845 Bytes
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
#!/usr/bin/env python
import argparse
parser = argparse.ArgumentParser(description='stack multiple npz matrix')
parser.add_argument('-i', dest='input', nargs='*', help='input npz files')
parser.add_argument('-o', type=str, dest="output", help='output prefix')
args = parser.parse_args()
import sys
import copy
import numpy as np
from time import perf_counter as pc
from scipy import sparse
from scipy.sparse import save_npz, load_npz
from scipy.sparse import vstack
def main():
input_lists = args.input
outf = args.output
start_time = pc()
npz_list = []
for i in input_lists:
print(i)
npz = load_npz(i)
npz_list.append(npz)
del(npz)
merged_npz = vstack(npz_list)
outnpz = ".".join([outf,"npz"])
save_npz(outnpz, merged_npz)
end_time = pc()
print('Used (secs): ', end_time - start_time)
if __name__ == "__main__":
main()