-
Notifications
You must be signed in to change notification settings - Fork 0
/
sainsc_benchmark.py
53 lines (36 loc) · 1.24 KB
/
sainsc_benchmark.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
#!/usr/bin/env python
def main():
from argparse import ArgumentParser
from pathlib import Path
parser = ArgumentParser(description="")
parser.add_argument("input", help="Path to input file.", type=Path)
parser.add_argument("signatures", help="Path to signature file (tsv).", type=Path)
parser.add_argument(
"--genes", help="Path to gene file.", type=Path, default=None, required=False
)
parser.add_argument(
"--n_threads",
help="Number of threads for parallelization.",
type=int,
default=1,
required=False,
)
args = parser.parse_args()
print(args)
import pandas as pd
from sainsc import read_StereoSeq
stereo = read_StereoSeq(args.input, resolution=500, n_threads=args.n_threads)
stereo.gaussian_kernel(8)
print(stereo)
signatures = pd.read_csv(args.signatures, index_col=0, sep="\t").loc[
lambda df: df.index.isin(stereo.genes)
]
if args.genes is not None:
signatures = signatures.loc[
lambda df: df.index.isin(pd.read_csv(args.genes, header=None).iloc[:, 0])
]
print(signatures.shape)
stereo.assign_celltype(signatures, log=True)
print("Done")
if __name__ == "__main__":
main()