-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsc_count
More file actions
executable file
·149 lines (135 loc) · 3.68 KB
/
sc_count
File metadata and controls
executable file
·149 lines (135 loc) · 3.68 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/env python3
"""Create count files for 10X FASTQ files
"""
import argparse
import json
from subprocess import call
def main(args):
"main method of script"
with open(args.config) as json_data:
config = json.load(json_data)
if args.debug:
print(config)
for sample in config["samples"]:
script_text = """#!/bin/bash
#SBATCH --partition={partition}
#SBATCH --account={account}
#SBATCH --time={time}
#SBATCH -J cellranger_count_{sample}
#SBATCH -o cellranger_count_{sample}_%j_o.txt
#SBATCH --cpus-per-task {cores}
#SBATCH --mem {mem}G
module load biocompute/biocompute-modules
module load cellranger/cellranger-5.0.1
cellranger count \
--id {sample} \
--transcriptome {transcriptome_path} \
--fastqs {fastq_dir} \
--sample {sample} \
--jobmode local \
--localcores $SLURM_CPUS_PER_TASK \
--localmem {mem}
""".format(
sample=sample,
fastq_dir=config["fastq_dir"],
transcriptome_path=config["transcriptome"],
mem=args.mem,
cores=args.cores,
partition=args.partition,
account=args.account,
time=args.time,
)
script_path = f"{sample}.sbatch"
with open(script_path, 'w') as file_handle:
file_handle.write(script_text)
if args.debug:
print(['sbatch', script_path])
else:
call(['sbatch', script_path])
script_text = """#!/bin/bash
#SBATCH --partition={partition}
#SBATCH --account={account}
#SBATCH --time={time}
#SBATCH -J cellranger_aggr
#SBATCH -o cellranger_aggr_%j_o.txt
#SBATCH --cpus-per-task {cores}
#SBATCH --mem {mem}G
module load biocompute/biocompute-modules
module load cellranger/cellranger-5.0.1
""".format(
mem=args.mem,
cores=args.cores,
partition=args.partition,
account=args.account,
time=args.time,
)
script_text += f"""cellranger aggr \
--id=aggregated \
--csv=molecule_info.csv \
--localcores=$SLURM_CPUS_PER_TASK \
--localmem=40 --jobmode=local
"""
for group in config["groups"]:
script_text += f"""cellranger aggr \
--id=aggregated_{group} \
--csv=molecule_info_{group}.csv \
--localcores=$SLURM_CPUS_PER_TASK \
--localmem=40 \
--jobmode=local
"""
script_path = f"aggregate.sbatch"
with open(script_path, 'w') as file_handle:
file_handle.write(script_text)
print(f"Run {script_path} when the individual jobs have finished")
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description=__doc__
)
parser.add_argument(
'config',
type=str,
help='JSON config file',
)
parser.add_argument(
'--debug',
dest='debug',
action='store_true',
default=False,
)
parser.add_argument(
'--cores',
type=str,
default='24',
help='Number of cores(threads) to use to process data',
)
parser.add_argument(
'--mem',
type=str,
default='184',
help='GB of memory to use to process data',
)
parser.add_argument(
'--pre_mRNA',
type=str,
default=False,
help='Whether this is a "pre_mRNA" count job',
)
parser.add_argument(
'--account',
type=str,
default="warrenlab",
help='SLURM account towards which time should be debited',
)
parser.add_argument(
'--time',
type=str,
default="2-00:00:00",
help='Time limit (for SLURM) in DD-HH:MM:SS format',
)
parser.add_argument(
'--partition',
type=str,
default='hpc6',
help='SLURM partition to use',
)
main(parser.parse_args())