-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmark.py
88 lines (74 loc) · 2.39 KB
/
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env python
def main():
import argparse
from pathlib import Path
parser = argparse.ArgumentParser(description="")
parser.add_argument(
"-i", "--h5ad", help="Path to h5ad file.", required=True, type=Path
)
parser.add_argument(
"-o", "--out", help="Path of outputfile (tsv).", required=True, type=Path
)
parser.add_argument(
"--stereoseq",
help="Whether to process StereoSeq or image-based data.",
action="store_true",
)
parser.add_argument(
"--spatial_weight", help="Weight for spatial layer.", required=True, type=float
)
parser.add_argument(
"--mspca", help="Transform using MultispatiPCA.", action="store_true"
)
parser.add_argument(
"--neighbors", help="Neighbors, 'delaunay' or int.", required=False, default=4
)
parser.add_argument(
"--n_rings",
help="number of rings for grid. (only used with stereoseq)",
required=False,
type=int,
default=1,
)
parser.add_argument(
"--n_pcs", help="Number of components.", required=False, type=int
)
parser.add_argument(
"--n_genes",
help="Number of genes. (only used with stereoseq)",
required=False,
type=int,
)
parser.add_argument(
"--svg", help="Use SVG instead of HVG (only stereo-seq).", action="store_true"
)
parser.add_argument("--seed", help="Random seed.", required=True, type=int)
args = parser.parse_args()
import numpy as np
from utils import process_imagingbased, process_stereoseq
np.random.seed(args.seed)
neighbors = args.neighbors if args.neighbors == "delaunay" else int(args.neighbors)
if args.stereoseq:
label_df = process_stereoseq(
path=args.h5ad,
spatial_weight=args.spatial_weight,
SVG=args.svg,
seed=args.seed,
n_pcs=args.n_pcs,
n_genes=args.n_genes,
n_neighs=neighbors,
n_rings=args.n_rings,
mspca=args.mspca,
)
else:
label_df = process_imagingbased(
path=args.h5ad,
seed=args.seed,
msPCA=args.mspca,
neighbors=neighbors,
spatial_weight=args.spatial_weight,
n_pcs=args.n_pcs,
)
label_df.to_csv(args.out, sep="\t", index_label="")
if __name__ == "__main__":
main()