-
Notifications
You must be signed in to change notification settings - Fork 0
/
viz2d_command_line.py
77 lines (54 loc) · 2.98 KB
/
viz2d_command_line.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import warnings
warnings.filterwarnings('ignore')
__tool_name__='STREAM'
print('''
_____ _______ _____ ______ __ __
/ ____|__ __| __ \| ____| /\ | \/ |
| (___ | | | |__) | |__ / \ | \ / |
\___ \ | | | _ /| __| / /\ \ | |\/| |
____) | | | | | \ \| |____ / ____ \| | | |
|_____/ |_| |_| \_\______/_/ \_\_| |_|
... Validation
''',flush=True)
import stream as st
import argparse
import multiprocessing
import os
from slugify import slugify
import networkx as nx
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib as mpl
import sys
mpl.use('Agg')
mpl.rc('pdf', fonttype=42)
os.environ['KMP_DUPLICATE_LIB_OK']='True'
print('- STREAM Single-cell Trajectory Reconstruction And Mapping -',flush=True)
print('Version %s\n' % st.__version__,flush=True)
def main():
sns.set_style('white')
sns.set_context('poster')
parser = argparse.ArgumentParser(description='%s Parameters' % __tool_name__ ,formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("-m", "--data-file", dest="input_filename",default = None, help="input file name, pkl format from Stream preprocessing module", metavar="FILE")
parser.add_argument("-of","--of",dest="output_filename_prefix", default="StreamiFSOutput", help="output file name prefix")
parser.add_argument("--flag_useprecomputed",dest="flag_useprecomputed", action="store_true", help="Save the figure")
parser.add_argument("-nb_pct","--percent_neighbor_cells",dest="nb_pct", type=float, default=None, help="")
parser.add_argument("-n_comp_k",dest="n_comp_k", type = int, default=None, help="")
parser.add_argument("-perplexity",dest="perplexity", type=float, default=None, help="")
parser.add_argument("-method",dest="method", default=None, help="")
parser.add_argument("-color_by",dest="color_by", default='label', help="")
parser.add_argument("-fig_width",dest="fig_width", type=int, default=8, help="")
parser.add_argument("-fig_height",dest="fig_height", type=int, default=8, help="")
parser.add_argument("-fig_legend_ncol",dest="fig_legend_ncol", type=int, default=None, help="")
args = parser.parse_args()
print('Starting ...')
workdir = "./"
adata = st.read(file_name=args.input_filename, file_format='pkl', experiment='rna-seq', workdir=workdir)
st.plot_visualization_2D(adata, method=args.method, nb_pct=args.nb_pct, perplexity=args.perplexity, color_by=args.color_by,use_precomputed=args.flag_useprecomputed, save_fig=True, fig_path='./', fig_name=(args.output_filename_prefix +"_2D_plot.png"), fig_size=(args.fig_width,args.fig_height ),fig_legend_ncol=args.fig_legend_ncol)
st.write(adata,file_name=(args.output_filename_prefix + '_stream_result.pkl'),file_path='./',file_format='pkl')
print('Finished computation.')
if __name__ == "__main__":
main()