-
Notifications
You must be signed in to change notification settings - Fork 0
/
_mrosource
1822 lines (1683 loc) · 58.2 KB
/
_mrosource
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#
# @include "_aligner_stages.mro"
#
#
# Copyright (c) 2019 10x Genomics, Inc. All rights reserved.
#
filetype json;
filetype bam;
#
# @include "_sort_and_mark_dups_stages.mro"
#
#
# Copyright (c) 2019 10x Genomics, Inc. All rights reserved.
#
filetype bam;
filetype bam.bai;
filetype tsv.gz;
filetype tsv.gz.tbi;
filetype json;
filetype csv;
#
# @include "_peak_caller_stages.mro"
#
#
# Copyright (c) 2019 10x Genomics, Inc. All rights reserved.
#
filetype bedgraph;
filetype pickle;
filetype tsv.gz;
filetype tsv.gz.tbi;
filetype bed;
filetype json;
#
# @include "_basic_sc_atac_counter_stages.mro"
#
#
# Copyright (c) 2019 10x Genomics, Inc. All rights reserved.
#
filetype tsv.gz;
filetype tsv.gz.tbi;
filetype csv;
filetype json;
filetype bed;
filetype pickle;
filetype h5;
#
# @include "_produce_cell_barcodes_stages.mro"
#
#
# Copyright (c) 2019 10x Genomics, Inc. All rights reserved.
#
filetype tsv.gz;
filetype tsv.gz.tbi;
filetype csv;
filetype json;
filetype bed;
filetype pickle;
filetype h5;
filetype npy.gz;
#
# @include "_sc_atac_metric_collector_stages.mro"
#
#
# Copyright (c) 2019 10x Genomics, Inc. All rights reserved.
#
filetype tsv.gz;
filetype tsv.gz.tbi;
filetype bed;
filetype bam;
filetype csv;
filetype json;
filetype h5;
filetype txt;
filetype pickle;
#
# @include "_peak_annotator_stages.mro"
#
#
# Copyright (c) 2019 10x Genomics, Inc. All rights reserved.
#
filetype bed;
filetype tsv;
filetype h5;
filetype gz;
filetype pickle;
#
# @include "_sc_atac_analyzer_stages.mro"
#
#
# Copyright (c) 2019 10x Genomics, Inc. All rights reserved.
#
filetype tsv;
filetype h5;
filetype pickle;
filetype gz;
filetype bed;
filetype csv;
#
# @include "_sc_atac_reporter_stages.mro"
#
#
# Copyright (c) 2019 10x Genomics, Inc. All rights reserved.
#
filetype json;
filetype html;
filetype csv;
filetype h5;
filetype bam;
#
# @include "_atac_cloupe_stages.mro"
#
#
# Copyright (c) 2019 10x Genomics, Inc. All rights reserved.
#
filetype cloupe;
filetype csv;
filetype json;
filetype h5;
filetype bed;
filetype tsv.gz.tbi;
#
# @include "_preflight_stages.mro"
#
#
# Copyright (c) 2019 10x Genomics, Inc. All rights reserved.
#
filetype csv;
filetype bed;
filetype tsv.gz;
filetype tsv.gz.tbi;
#
# @include "_aligner_stages.mro"
#
# SETUP_CHUNKS chunks up the input fastq data into sets of matched R1, R2, SI, and BC fastq files.
# input_mode specifies how FASTQs were generated. There are two modes:
#
# 1. "BCL_PROCESSOR"
#
# FASTQs produced by the 10X BCL_PROCESSOR pipeline. This mode assumes the FASTQ files obey the internal
# naming conventions and the reads have been interleaved into RA FASTQ files.
#
# 2. "ILMN_BCL2FASTQ"
#
# FASTQs produced directly by Illumina BCL2FASTQ v1.8.4. For this mode, BCL2FASTQ must be configured to emit the
# index2 read, rather than using it for dual-index demultiplexing:
#
# configureBclToFastq.pl --no-eamss --use-bases-mask=Y100,I8,Y14,Y100 --input-dir=<basecalls_dir> \
# --output-dir=<output_dir> --sample-sheet=<sample_sheet.csv>
#
# The sample sheet must be formatted as per the BCL2FASTQ documentation (10 column csv), and must contain a row for
# each sample index used. The sequencer must have been run in dual index mode, with the second index read (used to
# read the 10X barcode) emitted as the R2 output file. The --use-bases-mask argument should be set to the read
# length used.
stage SETUP_CHUNKS(
in string sample_id "id of the sample",
in map[] sample_def "list of dictionary specifying input data",
in string input_mode "configuration of the input fastqs",
in map downsample "map specifies either subsample_rate (float) or gigabases (int)",
out map[] chunks "map has barcode, barcode_reverse_complement, sample_index, read1, read2, gem_group, and read_group fields",
out string[] read_groups "list of strings representing read groups",
out json downsample_info "info about downsampling result",
src py "stages/processing/setup_chunks",
)
# Trims adapter sequences from reads and massages fastq output into a fixed format (interleaved R1 file, etc.)
stage TRIM_READS(
in map[] chunks,
in string barcode_whitelist,
in int max_read_num,
in map trim_def,
in map adapters,
out map[] chunks,
out json bc_counts,
out json lot_info,
out json read_counts,
src py "stages/processing/trim_reads",
) split (
in map chunk,
) using (
volatile = strict,
)
# Aligns the reads to the input reference, producing chunked bam files
stage ALIGN_READS(
in map[] chunks,
in string aligner,
in string aligner_method,
in string reference_path,
in string read_group_sample,
in int num_threads,
out bam[],
src py "stages/processing/align_reads",
) split (
in map chunk,
) using (
# N.B. No index files are generated for the bam
volatile = strict,
)
#
# @include "_aligner.mro"
#
# Takes input fastqs and chunks them, trims them, and aligns the trimmed reads to a reference
pipeline _ALIGNER(
in string sample_id,
in string fastq_mode "configuration of the input fastqs",
in map[] sample_def,
in string reference_path "this is the reference_path",
in string barcode_whitelist "name of barcode whitelist file",
in map trim_def,
in map adapters,
in string read_group_sample "sample header for BAM file",
in map downsample,
out bam[] align,
out map[] chunks,
out json bc_counts,
out json lot_info "gelbead lot detected",
out json read_counts "total # of read pairs before and after adapter trimming",
out json downsample_info "info on downsampling",
)
{
call SETUP_CHUNKS(
sample_id = self.sample_id,
input_mode = self.fastq_mode,
sample_def = self.sample_def,
downsample = self.downsample,
) using (
volatile = true,
)
call TRIM_READS(
chunks = SETUP_CHUNKS.chunks,
max_read_num = 5000000,
trim_def = self.trim_def,
adapters = self.adapters,
barcode_whitelist = self.barcode_whitelist,
) using (
volatile = true,
)
call ALIGN_READS(
chunks = TRIM_READS.chunks,
aligner = "bwa",
aligner_method = "MEM",
reference_path = self.reference_path,
read_group_sample = self.read_group_sample,
num_threads = 4,
) using (
volatile = true,
)
return (
align = ALIGN_READS,
chunks = TRIM_READS.chunks,
bc_counts = TRIM_READS.bc_counts,
lot_info = TRIM_READS.lot_info,
read_counts = TRIM_READS.read_counts,
downsample_info = SETUP_CHUNKS.downsample_info,
)
}
#
# @include "_sort_and_mark_dups_stages.mro"
#
# Attaches raw and corrected barcode sequences to the aligned reads
stage ATTACH_BCS(
in string barcode_whitelist,
in bam[] align,
in map[] chunks,
in bool paired_end,
in bool exclude_non_bc_reads,
in float bc_confidence_threshold,
in json bc_counts,
out bam[] output,
out int perfect_read_count,
src py "stages/processing/attach_bcs",
) split (
in bam align_chunk,
in map chunk,
) using (
# N.B. No index files are generated for the bam
volatile = strict,
)
stage SORT_READS_BY_POS(
in bam[] input,
out bam tagsorted_bam,
src py "stages/processing/sort_reads_by_pos",
) split (
in bam chunk_input,
) using (
# N.B. No index files are generated for the bam
volatile = strict,
)
# Marks duplicates in the reads using barcodes and fragment alignments to detect PCR and optical/diffusion duplicates
stage MARK_DUPLICATES(
in bam input,
in string reference_path,
in json raw_barcode_counts,
in string barcode_whitelist,
out bam output,
out bam.bai index,
out csv singlecell_mapping,
out tsv.gz fragments,
out tsv.gz.tbi fragments_index,
src py "stages/processing/mark_duplicates",
) split (
in map lane_map,
in string chunk_start,
in string chunk_end,
in int chunk_num,
) using (
# N.B. BAM/BED index files are explicitly bound where used
volatile = strict,
)
#
# @include "_sort_and_mark_dups.mro"
#
# Attaches barcodes to the aligned reads, marks duplicate reads, and produces a barcode-sorted and position-sorted
# output BAM
pipeline _SORT_AND_MARK_DUPS(
in bam[] align,
in map[] chunks,
in string barcode_whitelist,
in json bc_counts,
in string reference_path,
out bam possorted_bam "bam file sorted by position",
out bam.bai possorted_bam_index "position-sorted bam index",
out tsv.gz fragments,
out tsv.gz.tbi fragments_index,
out csv singlecell_mapping,
out bam[] read_paired_bam,
)
{
call ATTACH_BCS(
align = self.align,
chunks = self.chunks,
paired_end = true,
barcode_whitelist = self.barcode_whitelist,
exclude_non_bc_reads = false,
bc_confidence_threshold = 0.975,
bc_counts = self.bc_counts,
) using (
volatile = true,
)
call SORT_READS_BY_POS(
input = ATTACH_BCS.output,
) using (
volatile = true,
)
call MARK_DUPLICATES(
input = SORT_READS_BY_POS.tagsorted_bam,
reference_path = self.reference_path,
barcode_whitelist = self.barcode_whitelist,
raw_barcode_counts = self.bc_counts,
) using (
volatile = true,
)
return (
possorted_bam = MARK_DUPLICATES.output,
possorted_bam_index = MARK_DUPLICATES.index,
singlecell_mapping = MARK_DUPLICATES.singlecell_mapping,
fragments = MARK_DUPLICATES.fragments,
fragments_index = MARK_DUPLICATES.fragments_index,
read_paired_bam = ATTACH_BCS.output,
)
}
#
# @include "_peak_caller_stages.mro"
#
stage COUNT_CUT_SITES(
in path reference_path,
in tsv.gz fragments,
in tsv.gz.tbi fragments_index,
out bedgraph cut_sites,
out pickle count_dict,
src py "stages/processing/count_cut_sites",
) split (
in string contig,
) using (
# N.B. We explicitly bind the index file
volatile = strict,
)
stage DETECT_PEAKS(
in bedgraph cut_sites,
in path reference_path,
in pickle count_dict,
out bed peaks,
out json peak_metrics,
src py "stages/processing/detect_peaks",
) split (
in string contig,
in float[] params,
in float threshold,
) using (
mem_gb = 6,
# N.B. We explicitly bind the index file
volatile = strict,
)
#
# @include "_peak_caller.mro"
#
pipeline _PEAK_CALLER(
in path reference_path,
in tsv.gz fragments,
in tsv.gz.tbi fragments_index,
out bedgraph cut_sites,
out bed peaks,
out json peak_metrics,
)
{
call COUNT_CUT_SITES(
reference_path = self.reference_path,
fragments = self.fragments,
fragments_index = self.fragments_index,
)
call DETECT_PEAKS(
reference_path = self.reference_path,
cut_sites = COUNT_CUT_SITES.cut_sites,
count_dict = COUNT_CUT_SITES.count_dict,
)
return (
cut_sites = COUNT_CUT_SITES.cut_sites,
peaks = DETECT_PEAKS.peaks,
peak_metrics = DETECT_PEAKS.peak_metrics,
)
}
#
# @include "_basic_sc_atac_counter_stages.mro"
#
stage GENERATE_PEAK_MATRIX(
in string reference_path,
in tsv.gz fragments,
in bed peaks,
out h5 raw_matrix,
out path raw_matrix_mex,
src py "stages/processing/generate_peak_matrix",
) split (
in file barcodes,
) using (
mem_gb = 4,
# N.B. we don't explicitly need the fragment index
volatile = strict,
)
stage FILTER_PEAK_MATRIX(
in h5 raw_matrix,
in int num_analysis_bcs,
in int random_seed,
in csv cell_barcodes,
out h5 filtered_matrix,
out path filtered_matrix_mex,
src py "stages/processing/filter_peak_matrix",
) split (
) using (
volatile = strict,
)
#
# @include "_produce_cell_barcodes_stages.mro"
#
stage REMOVE_LOW_TARGETING_BARCODES(
in bed peaks,
in tsv.gz fragments,
in tsv.gz.tbi fragments_index,
in string reference_path,
out json barcode_counts,
out json low_targeting_barcodes,
out json low_targeting_summary,
out json fragment_lengths,
out json covered_bases,
src py "stages/processing/cell_calling/remove_low_targeting_barcodes",
) split (
in string contig,
out pickle fragment_counts,
out pickle targeted_counts,
out int peak_coverage,
) using (
mem_gb = 4,
volatile = strict,
)
stage REMOVE_GEL_BEAD_DOUBLET_BARCODES(
in tsv.gz fragments,
in tsv.gz.tbi fragments_index,
in string reference_path,
in json barcode_counts,
out json gel_bead_doublet_barcodes,
out json gel_bead_doublet_summary,
out csv connect_matrix,
src py "stages/processing/cell_calling/remove_gel_bead_doublet_barcodes",
) split (
in string contig,
in file valid_barcodes,
) using (
mem_gb = 4,
volatile = strict,
)
stage REMOVE_BARCODE_MULTIPLETS(
in tsv.gz fragments,
in tsv.gz.tbi fragments_index,
in string reference_path,
in string barcode_whitelist,
in json barcode_counts,
out json barcode_multiplets,
out json barcode_multiplets_summary,
src py "stages/processing/cell_calling/remove_barcode_multiplets",
) split (
in string contig,
in string gem_group,
out npy.gz part_a_linkage_matrix,
out npy.gz part_b_linkage_matrix,
) using (
mem_gb = 4,
volatile = strict,
)
stage MERGE_EXCLUDED_BARCODES(
in json[] barcode_exclusions,
out json excluded_barcodes,
src py "stages/processing/cell_calling/merge_excluded_barcodes",
)
stage DETECT_CELL_BARCODES(
in tsv.gz fragments,
in tsv.gz.tbi fragments_index,
in string barcode_whitelist,
in json excluded_barcodes,
in map force_cells,
in string reference_path,
in bed peaks,
out csv cell_barcodes,
out csv singlecell,
out json cell_calling_summary,
src py "stages/processing/cell_calling/detect_cell_barcodes",
) split (
in string contig,
out pickle barcode_counts,
out pickle targeted_counts,
out int fragment_depth,
) using (
mem_gb = 4,
volatile = strict,
)
# TODO: This should be in mro/common for general use
stage MERGE_SUMMARY_METRICS(
in json[] summary_jsons,
out json merged_summary,
src py "stages/processing/cell_calling/merge_summary_metrics",
)
#
# @include "_produce_cell_barcodes.mro"
#
pipeline _PRODUCE_CELL_BARCODES(
in bed peaks,
in tsv.gz fragments,
in tsv.gz.tbi fragments_index,
in string reference_path,
in string barcode_whitelist,
in map force_cells,
out csv cell_barcodes,
out csv singlecell,
out json cell_calling_summary,
out json excluded_barcodes,
out json fragment_lengths,
out json covered_bases,
)
{
call REMOVE_LOW_TARGETING_BARCODES(
fragments = self.fragments,
fragments_index = self.fragments_index,
peaks = self.peaks,
reference_path = self.reference_path,
)
call REMOVE_GEL_BEAD_DOUBLET_BARCODES(
fragments = self.fragments,
fragments_index = self.fragments_index,
reference_path = self.reference_path,
barcode_counts = REMOVE_LOW_TARGETING_BARCODES.barcode_counts,
)
call REMOVE_BARCODE_MULTIPLETS(
fragments = self.fragments,
fragments_index = self.fragments_index,
reference_path = self.reference_path,
barcode_whitelist = self.barcode_whitelist,
barcode_counts = REMOVE_LOW_TARGETING_BARCODES.barcode_counts,
)
call MERGE_EXCLUDED_BARCODES(
barcode_exclusions = [
REMOVE_BARCODE_MULTIPLETS.barcode_multiplets,
REMOVE_GEL_BEAD_DOUBLET_BARCODES.gel_bead_doublet_barcodes,
REMOVE_LOW_TARGETING_BARCODES.low_targeting_barcodes,
],
)
call DETECT_CELL_BARCODES(
fragments = self.fragments,
fragments_index = self.fragments_index,
barcode_whitelist = self.barcode_whitelist,
force_cells = self.force_cells,
excluded_barcodes = MERGE_EXCLUDED_BARCODES.excluded_barcodes,
reference_path = self.reference_path,
peaks = self.peaks,
)
call MERGE_SUMMARY_METRICS as MERGE_CELL_METRICS(
summary_jsons = [
REMOVE_LOW_TARGETING_BARCODES.low_targeting_summary,
REMOVE_GEL_BEAD_DOUBLET_BARCODES.gel_bead_doublet_summary,
REMOVE_BARCODE_MULTIPLETS.barcode_multiplets_summary,
DETECT_CELL_BARCODES.cell_calling_summary,
],
)
return (
cell_barcodes = DETECT_CELL_BARCODES.cell_barcodes,
excluded_barcodes = MERGE_EXCLUDED_BARCODES.excluded_barcodes,
singlecell = DETECT_CELL_BARCODES.singlecell,
cell_calling_summary = MERGE_CELL_METRICS.merged_summary,
fragment_lengths = REMOVE_LOW_TARGETING_BARCODES.fragment_lengths,
covered_bases = REMOVE_LOW_TARGETING_BARCODES.covered_bases,
)
}
#
# @include "_basic_sc_atac_counter.mro"
#
pipeline _BASIC_SC_ATAC_COUNTER(
in string sample_id,
in string fastq_mode "configuration of the input fastqs",
in map[] sample_def,
in string reference_path "this is the reference_path",
in string barcode_whitelist "name of barcode whitelist file",
in map trim_def,
in map adapters,
in map downsample,
in map force_cells,
out bam possorted_bam "bam file sorted by position",
out bam.bai possorted_bam_index "position-sorted bam index",
out tsv.gz fragments,
out tsv.gz.tbi fragments_index,
out json lot_info "gelbead lot detected",
out json read_counts "total # of read pairs before and after adapter trimming",
out json downsample_info "info on downsampling",
out csv cell_barcodes,
out json excluded_barcodes,
out json cell_calling_summary,
out bed peaks,
out bedgraph cut_sites,
out csv singlecell_mapping,
out csv singlecell_cells,
out json peak_metrics,
out bam[] read_paired_bam,
out h5 raw_peak_bc_matrix,
out path raw_peak_bc_matrix_mex,
out h5 filtered_peak_bc_matrix,
out path filtered_peak_bc_matrix_mex,
)
{
call _ALIGNER(
sample_id = self.sample_id,
fastq_mode = self.fastq_mode,
sample_def = self.sample_def,
read_group_sample = self.sample_id,
trim_def = self.trim_def,
adapters = self.adapters,
reference_path = self.reference_path,
barcode_whitelist = self.barcode_whitelist,
downsample = self.downsample,
)
call _SORT_AND_MARK_DUPS(
align = _ALIGNER.align,
chunks = _ALIGNER.chunks,
reference_path = self.reference_path,
barcode_whitelist = self.barcode_whitelist,
bc_counts = _ALIGNER.bc_counts,
)
call _PEAK_CALLER(
fragments = _SORT_AND_MARK_DUPS.fragments,
fragments_index = _SORT_AND_MARK_DUPS.fragments_index,
reference_path = self.reference_path,
)
call _PRODUCE_CELL_BARCODES(
fragments = _SORT_AND_MARK_DUPS.fragments,
fragments_index = _SORT_AND_MARK_DUPS.fragments_index,
peaks = _PEAK_CALLER.peaks,
force_cells = self.force_cells,
reference_path = self.reference_path,
barcode_whitelist = self.barcode_whitelist,
)
call GENERATE_PEAK_MATRIX(
reference_path = self.reference_path,
fragments = _SORT_AND_MARK_DUPS.fragments,
peaks = _PEAK_CALLER.peaks,
)
call FILTER_PEAK_MATRIX(
num_analysis_bcs = null,
cell_barcodes = _PRODUCE_CELL_BARCODES.cell_barcodes,
raw_matrix = GENERATE_PEAK_MATRIX.raw_matrix,
random_seed = null,
)
return (
possorted_bam = _SORT_AND_MARK_DUPS.possorted_bam,
possorted_bam_index = _SORT_AND_MARK_DUPS.possorted_bam_index,
singlecell_mapping = _SORT_AND_MARK_DUPS.singlecell_mapping,
singlecell_cells = _PRODUCE_CELL_BARCODES.singlecell,
lot_info = _ALIGNER.lot_info,
read_counts = _ALIGNER.read_counts,
downsample_info = _ALIGNER.downsample_info,
cell_barcodes = _PRODUCE_CELL_BARCODES.cell_barcodes,
excluded_barcodes = _PRODUCE_CELL_BARCODES.excluded_barcodes,
cell_calling_summary = _PRODUCE_CELL_BARCODES.cell_calling_summary,
peak_metrics = _PEAK_CALLER.peak_metrics,
cut_sites = _PEAK_CALLER.cut_sites,
peaks = _PEAK_CALLER.peaks,
fragments = _SORT_AND_MARK_DUPS.fragments,
fragments_index = _SORT_AND_MARK_DUPS.fragments_index,
read_paired_bam = _SORT_AND_MARK_DUPS.read_paired_bam,
raw_peak_bc_matrix = GENERATE_PEAK_MATRIX.raw_matrix,
raw_peak_bc_matrix_mex = GENERATE_PEAK_MATRIX.raw_matrix_mex,
filtered_peak_bc_matrix = FILTER_PEAK_MATRIX.filtered_matrix,
filtered_peak_bc_matrix_mex = FILTER_PEAK_MATRIX.filtered_matrix_mex,
)
}
#
# @include "_sc_atac_metric_collector_stages.mro"
#
stage ESTIMATE_LIBRARY_COMPLEXITY(
in json sequencing_summary,
in tsv.gz fragments,
in csv cell_barcodes,
out json bulk_complexity,
out json complexity_summary,
out json singlecell_complexity,
src py "stages/metrics/estimate_library_complexity",
) split (
in file barcodes,
) using (
mem_gb = 6,
volatile = strict,
)
stage GENERATE_SEQUENCING_METRICS(
in bam[] input,
out txt misc_sm,
out json summary,
src py "stages/metrics/generate_sequencing_metrics",
) split (
in bam chunk_bam,
) using (
volatile = strict,
)
stage GENERATE_SINGLECELL_TARGETING(
in tsv.gz fragments,
in tsv.gz.tbi fragments_index,
in bed peaks,
in string reference_path,
out csv singlecell,
out json summary,
out csv tss_relpos,
out csv ctcf_relpos,
src py "stages/metrics/generate_singlecell_targeting",
) split (
in string contig,
out int read_count,
out pickle target_counts_by_barcode,
out pickle chunk_tss,
out pickle chunk_ctcf,
) using (
mem_gb = 6,
volatile = strict,
)
stage MERGE_SINGLECELL_METRICS(
in string reference_path,
in csv singlecell_mapping,
in csv singlecell_targets,
in csv singlecell_cells,
out csv singlecell,
out json summary,
src py "stages/metrics/merge_singlecell_metrics",
) using (
mem_gb = 8,
volatile = strict,
)
stage REPORT_INSERT_SIZES(
in tsv.gz fragments,
in bool exclude_non_nuclear,
in string reference_path,
out csv insert_sizes,
out json insert_summary,
src py "stages/metrics/report_insert_sizes",
) split (
in file barcode,
out file total,
) using (
volatile = strict,
)
stage REPORT_TSS_CTCF(
in csv tss_relpos,
in csv ctcf_relpos,
out json summary_metrics,
src py "stages/metrics/report_tss_ctcf",
) using (
volatile = strict,
)
#
# @include "_sc_atac_metric_collector.mro"
#
pipeline _SC_ATAC_METRIC_COLLECTOR(
in bam[] read_paired_bam,
in tsv.gz fragments,
in tsv.gz.tbi fragments_index,
in bed peaks,
in string reference_path "this is the reference_path",
in csv cell_barcodes,
in csv singlecell_mapping,
in csv singlecell_cells,
out json singlecell_results,
out csv singlecell,
out json enrichment_results,
out json basic_summary,
out json insert_summary,
out csv insert_sizes,
out json bulk_complexity,
out json singlecell_complexity,
out json complexity_summary,
out csv tss_relpos,
out csv ctcf_relpos,
)
{
call GENERATE_SINGLECELL_TARGETING(
fragments = self.fragments,
fragments_index = self.fragments_index,
peaks = self.peaks,
reference_path = self.reference_path,
)
call MERGE_SINGLECELL_METRICS(
reference_path = self.reference_path,
singlecell_mapping = self.singlecell_mapping,
singlecell_cells = self.singlecell_cells,
singlecell_targets = GENERATE_SINGLECELL_TARGETING.singlecell,
)
call GENERATE_SEQUENCING_METRICS(
input = self.read_paired_bam,
)
call ESTIMATE_LIBRARY_COMPLEXITY(
sequencing_summary = GENERATE_SEQUENCING_METRICS.summary,
fragments = self.fragments,
cell_barcodes = self.cell_barcodes,
)
call REPORT_INSERT_SIZES(
fragments = self.fragments,
reference_path = self.reference_path,
exclude_non_nuclear = true,
)
call REPORT_TSS_CTCF(
tss_relpos = GENERATE_SINGLECELL_TARGETING.tss_relpos,
ctcf_relpos = GENERATE_SINGLECELL_TARGETING.ctcf_relpos,
)
return (
###
singlecell = MERGE_SINGLECELL_METRICS.singlecell,
singlecell_results = MERGE_SINGLECELL_METRICS.summary,
###
enrichment_results = REPORT_TSS_CTCF.summary_metrics,
basic_summary = GENERATE_SEQUENCING_METRICS.summary,
insert_summary = REPORT_INSERT_SIZES.insert_summary,
insert_sizes = REPORT_INSERT_SIZES.insert_sizes,
bulk_complexity = ESTIMATE_LIBRARY_COMPLEXITY.bulk_complexity,
singlecell_complexity = ESTIMATE_LIBRARY_COMPLEXITY.singlecell_complexity,
complexity_summary = ESTIMATE_LIBRARY_COMPLEXITY.complexity_summary,
tss_relpos = GENERATE_SINGLECELL_TARGETING.tss_relpos,
ctcf_relpos = GENERATE_SINGLECELL_TARGETING.ctcf_relpos,
)
}
#
# @include "_peak_annotator_stages.mro"
#
stage ANNOTATE_PEAKS(
in bed peaks,
in string reference_path,
out tsv peak_annotation,
src py "stages/analysis/annotate_peaks",
) split (
in int chunk_start,
in int chunk_end,
) using (
mem_gb = 5,
volatile = strict,
)
stage COMPUTE_GC_DISTRIBUTION(
in bed peaks,
in string reference_path,
out pickle GCdict,
src py "stages/analysis/compute_gc_dist",
) split (
) using (
volatile = strict,
)
stage SCAN_MOTIFS(
in pickle globalGCdict,
in bed peaks,
in string reference_path,
in float pwm_threshold,
out bed peak_motif_hits,
src py "stages/analysis/scan_motifs",
) split (
in file GCdict,
) using (
volatile = strict,
)
stage GENERATE_TF_MATRIX(
in path reference_path,
in bed peaks,
in bed peak_motif_hits,
in h5 filtered_matrix,
out h5 filtered_tf_bc_matrix,
out path filtered_tf_bc_matrix_mex,
out gz tf_propZ_matrix,
src py "stages/analysis/generate_tf_matrix",
) split (
) using (
volatile = strict,
)
#
# @include "_peak_annotator.mro"
#
pipeline _PEAK_ANNOTATOR(
in string reference_path,
in bed peaks,