SlitherCode commited on
Commit
746e176
·
verified ·
1 Parent(s): 1f00f57

Add files using upload-large-folder tool

Browse files
.gitattributes CHANGED
@@ -58,3 +58,17 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
61
+ test/tumor_chr17.bai filter=lfs diff=lfs merge=lfs -text
62
+ full/hcc1143_T_clean.bai filter=lfs diff=lfs merge=lfs -text
63
+ test/normal_chr17.bai filter=lfs diff=lfs merge=lfs -text
64
+ full/hcc1143_N_clean.bai filter=lfs diff=lfs merge=lfs -text
65
+ hla/hla_candidates_R1.fastq filter=lfs diff=lfs merge=lfs -text
66
+ hla/hla_unmapped.bam filter=lfs diff=lfs merge=lfs -text
67
+ hla/hla_candidates_R2.fastq filter=lfs diff=lfs merge=lfs -text
68
+ hla/hla_chr6_primary.bam filter=lfs diff=lfs merge=lfs -text
69
+ test/normal_chr17.bam filter=lfs diff=lfs merge=lfs -text
70
+ test/tumor_chr17.bam filter=lfs diff=lfs merge=lfs -text
71
+ hla/hla_alt_contigs.bam filter=lfs diff=lfs merge=lfs -text
72
+ hla/hla_candidates.bam filter=lfs diff=lfs merge=lfs -text
73
+ full/hcc1143_T_clean.bam filter=lfs diff=lfs merge=lfs -text
74
+ full/hcc1143_N_clean.bam filter=lfs diff=lfs merge=lfs -text
full/hcc1143_N_clean.bai ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f5791c76a900d735c7a702eee4ee1e4269a70f357d1dd01685a006433cdc69ff
3
+ size 5210880
full/hcc1143_N_clean.bam ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c016582042e34b5da052f5ab9508a750ff479d1e6d5779bb7980ffb7ab333f78
3
+ size 10335505477
full/hcc1143_T_clean.bai ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b73657fee9ed6d433cfeccab043bbeb898b38fbabdb03aa084e79b4fb8011d33
3
+ size 5341328
full/hcc1143_T_clean.bam ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:347af8bb1537af6466d5645ddc42d302bf783b97f8718d3dd2fad7452beb11ab
3
+ size 13478097244
hla/hla_alt_contigs.bam ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a7d770993cb9d30570617daf73cee11ceae9c84a66200e5684c308710670709a
3
+ size 1075924450
hla/hla_candidates.bam ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:38cf6f491c02d76a2e59575ef5161b3b574af10a57d9f3784e7d69d5f422b860
3
+ size 1199213974
hla/hla_candidates_R1.fastq ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:91a942d187c7584afce3eb24bbb736dcfb9ddc1abfdcd136b1ae2a282b19f7ff
3
+ size 50579738
hla/hla_candidates_R2.fastq ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a3d38935f05a43d061308b7ea56557c0d21661f165e81183ccfdf33722c6359f
3
+ size 50579738
hla/hla_chr6_primary.bam ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f1e5f63219a38348aef23ed6ed19c7beaa8a5ec656ffbf35e4726f7deec64f7f
3
+ size 81028383
hla/hla_fished_R1.fastq ADDED
The diff for this file is too large to render. See raw diff
 
hla/hla_fished_R2.fastq ADDED
The diff for this file is too large to render. See raw diff
 
hla/hla_unmapped.bam ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2dd79affe338166578983a55f0c3676fbe64df290a36f9265da7ec4136ad72ef
3
+ size 41464499
hla/patient_hla.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # HCC1143 Clinical HLA Typing
2
+ # Source: Boegel et al. (2014) PubMed 25960936
3
+ # Confirmed: Cellosaurus CVCL_1245
4
+ # Method: seq2HLA from RNA-seq
5
+ # Note: HLA-A is homozygous A*31:01
6
+ # Computational tools (OptiType) may misresolved second A allele
7
+ # as A*23:01 due to homozygosity ambiguity — use this file as ground truth
8
+ HLA-A*31:01
9
+ HLA-A*31:01
10
+ HLA-B*37:01
11
+ HLA-B*35:08
12
+ HLA-C*06:02
13
+ HLA-C*04:01
tcga/TCGA-SKCM.maf.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c92e5eee271ee8aebc3d646019caab11656ad507579a2057f31ae6532437500c
3
+ size 89383976
test/create_test_data.sh ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ── Subset full HCC1143 BAMs to chr17 for pipeline development ───────────────
2
+ # Input: full WES BAMs (wherever you downloaded them)
3
+ # Output: hcc1143_T_clean.bam / hcc1143_N_clean.bam (chr17 only)
4
+ #
5
+ # Why chr17: TP53 is on chr17 — the known HCC1143 driver mutation
6
+ # we use as our validated anchor epitope. Subsetting to chr17 keeps
7
+ # the test data small (~50MB vs ~23GB) while retaining the mutation
8
+ # we actually care about.
9
+ # ─────────────────────────────────────────────────────────────────────────────
10
+
11
+ TUMOR_FULL=~/melanoma-pipeline/data/full/hcc1143_T_clean.bam
12
+ NORMAL_FULL=~/melanoma-pipeline/data/full/hcc1143_N_clean.bam
13
+ OUT=~/melanoma-pipeline/data/test
14
+
15
+ mkdir -p $OUT
16
+
17
+ # Subset tumor to chr17
18
+ # -b: output BAM format, -h: include header, -@ 8: 8 threads
19
+ samtools view \
20
+ -b \
21
+ -h \
22
+ -@ 8 \
23
+ $TUMOR_FULL \
24
+ chr17 \
25
+ -o $OUT/tumor_chr17.bam
26
+
27
+ # Index tumor subset
28
+ samtools index \
29
+ -@ 8 \
30
+ $OUT/tumor_chr17.bam \
31
+ $OUT/tumor_chr17.bai
32
+
33
+ # Subset normal to chr17
34
+ samtools view \
35
+ -b \
36
+ -h \
37
+ -@ 8 \
38
+ $NORMAL_FULL \
39
+ chr17 \
40
+ -o $OUT/normal_chr17.bam
41
+
42
+ # Index normal subset
43
+ samtools index \
44
+ -@ 8 \
45
+ $OUT/normal_chr17.bam \
46
+ $OUT/normal_chr17.bai
47
+
48
+ # Verify read counts
49
+ echo "Tumor chr17 reads:"
50
+ samtools flagstat $OUT/tumor_chr17.bam
51
+
52
+ echo "Normal chr17 reads:"
53
+ samtools flagstat $OUT/normal_chr17.bam
54
+
55
+
56
+ # ── Extract HLA reads from normal BAM for OptiType ───────────────────────────
57
+ # Always use normal BAM for HLA typing — tumor DNA can have LOH
58
+ # (Loss of Heterozygosity) at HLA loci which gives wrong alleles.
59
+ #
60
+ # Three-bucket strategy to avoid missing HLA reads due to ALT contigs:
61
+ # Bucket 1 — primary MHC region on chr6
62
+ # Bucket 2 — ALT contigs (reads that overflowed from primary chr6 assembly)
63
+ # Bucket 3 — unmapped reads (too divergent to map anywhere in hg38)
64
+ # All three are merged and remapped against OptiType's HLA-specific reference.
65
+ # ─────────────────────────────────────────────────────────────────────────────
66
+
67
+ OUT_HLA=~/melanoma-pipeline/data/hla
68
+ mkdir -p $OUT_HLA
69
+
70
+ # Bucket 1 — primary MHC region on chr6
71
+ # 28510120-33480577 = full MHC locus including HLA-A, B, C and flanking genes
72
+ samtools view \
73
+ -b \
74
+ -h \
75
+ -@ 8 \
76
+ $NORMAL_FULL \
77
+ chr6:28510120-33480577 \
78
+ -o $OUT_HLA/hla_chr6_primary.bam
79
+
80
+ # Bucket 2 — ALT contigs
81
+ # Reads from patients with HLA alleles too divergent for the primary reference
82
+ # — most common in non-European populations. Dynamically finds all ALT/HLA
83
+ # contigs in the BAM header so this works regardless of hg38 build variant.
84
+ ALT_CONTIGS=$(samtools view -H $NORMAL_FULL \
85
+ | grep "^@SQ" \
86
+ | grep -iE "_alt|HLA" \
87
+ | awk '{print $2}' \
88
+ | sed 's/SN://')
89
+
90
+ if [ -n "$ALT_CONTIGS" ]; then
91
+ ALT_TMP=$(mktemp -d)
92
+ while IFS= read -r contig; do
93
+ safe_name="${contig//\//_}"
94
+ samtools view -b -h -@ 8 $NORMAL_FULL "$contig" -o "$ALT_TMP/${safe_name}.bam"
95
+ done <<< "$ALT_CONTIGS"
96
+ samtools merge -f -@ 8 $OUT_HLA/hla_alt_contigs.bam "$ALT_TMP"/*.bam
97
+ rm -rf "$ALT_TMP"
98
+ else
99
+ # No ALT contigs — create an empty BAM so downstream merge still works
100
+ samtools view -b -h $NORMAL_FULL -o $OUT_HLA/hla_alt_contigs.bam /dev/null 2>/dev/null || \
101
+ samtools view -H $NORMAL_FULL -b -o $OUT_HLA/hla_alt_contigs.bam
102
+ fi
103
+
104
+ # Bucket 3 — unmapped reads
105
+ # Small fraction of BAM but catches rare/unusual alleles that couldn't
106
+ # map anywhere in hg38 due to extreme divergence from the reference
107
+ # -f 4: flag 4 = read unmapped
108
+ samtools view \
109
+ -b \
110
+ -f 4 \
111
+ -@ 8 \
112
+ $NORMAL_FULL \
113
+ -o $OUT_HLA/hla_unmapped.bam
114
+
115
+ # Merge all three buckets into one candidate pool
116
+ samtools merge \
117
+ -f \
118
+ -@ 8 \
119
+ $OUT_HLA/hla_candidates.bam \
120
+ $OUT_HLA/hla_chr6_primary.bam \
121
+ $OUT_HLA/hla_alt_contigs.bam \
122
+ $OUT_HLA/hla_unmapped.bam
123
+
124
+ # Convert merged BAM to paired FASTQ for remapping
125
+ # Sort by name first (-n) so read pairs are adjacent
126
+ samtools sort -n -@ 8 $OUT_HLA/hla_candidates.bam \
127
+ | samtools fastq \
128
+ -1 $OUT_HLA/hla_candidates_R1.fastq \
129
+ -2 $OUT_HLA/hla_candidates_R2.fastq \
130
+ -0 /dev/null \
131
+ -s /dev/null
132
+
133
+ # Remap against OptiType's HLA-specific reference
134
+ # This is the critical step — reads that were on ALT contigs or unmapped
135
+ # now find their correct HLA allele sequence. The HLA reference contains
136
+ # sequences for thousands of known alleles across all populations.
137
+ # hla_reference_dna.fasta is bundled inside the fred2/optitype Docker image
138
+ # at /usr/local/bin/data/hla_reference_dna.fasta
139
+ # Extract it once and reuse:
140
+ # docker run --rm fred2/optitype cat /usr/local/bin/data/hla_reference_dna.fasta \
141
+ # > ~/melanoma-pipeline/reference/hla_reference_dna.fasta
142
+ HLA_REF=~/melanoma-pipeline/reference/hla_reference_dna.fasta
143
+
144
+ # Index HLA reference if not already done
145
+ if [ ! -f "${HLA_REF}.bwt" ]; then
146
+ echo "Indexing HLA reference..."
147
+ bwa index $HLA_REF
148
+ fi
149
+
150
+ bwa mem \
151
+ -t 8 \
152
+ $HLA_REF \
153
+ $OUT_HLA/hla_candidates_R1.fastq \
154
+ $OUT_HLA/hla_candidates_R2.fastq \
155
+ | samtools sort -n -@ 8 \
156
+ | samtools fastq \
157
+ -F 4 \
158
+ -1 $OUT_HLA/hla_fished_R1.fastq \
159
+ -2 $OUT_HLA/hla_fished_R2.fastq \
160
+ -0 /dev/null \
161
+ -s /dev/null
162
+
163
+ # hla_fished_R1/R2.fastq are now ready to pass to OptiType (Step 3 of the pipeline)
164
+ echo "HLA read extraction complete."
165
+ echo "Fished read pairs: $(( $(wc -l < $OUT_HLA/hla_fished_R1.fastq) / 4 ))"
166
+ echo "Ready for OptiType: $OUT_HLA/hla_fished_R1.fastq + hla_fished_R2.fastq"
test/normal_chr17.bai ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:816bcba845d66875298ce2899b38d042ce13d58a76bf92866f591896f0445b66
3
+ size 170056
test/normal_chr17.bam ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fb08426ca658d5ddc1cd339d67ad3849fc3b15ae4f2a408344d105c55e280b14
3
+ size 537682923
test/tumor_chr17.bai ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:242acea031c1ba8c484eeb6d9cc97c0452a4380671d1379c47d12cf5d21f27fd
3
+ size 172248
test/tumor_chr17.bam ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:420bca073180c073f78852a44fe701c9a493c7ff7385894db05d8953bde5fd4c
3
+ size 731812561