Unicycler + Medaka (HAC) + Polypolish –> identify IS, SNPs, structural variants (Data_Tam_Methylation_19606WT_adeAB_adeIJ_craA)

19606WT △AB △IJ的三个样

1. Specialized Analytical Approach for Isolates of Clinical and Environmental Origin (e.g., Z2605 and Z2914)

  1. cat longreads

     ./cat_longreads.sh
  2. Run unicycler

     conda activate /home/jhuang/miniconda3/envs/trycycler
    
     unicycler -1 /mnt/md1/DATA/Data_Tam_DNAseq_2026_An6_BG5/X101SC26036392-Z01-J002/clean_data/An6/An6_L1_1.clean.rd.fq.gz -2 /mnt/md1/DATA/Data_Tam_DNAseq_2026_An6_BG5/X101SC26036392-Z01-J002/clean_data/An6/An6_L1_2.clean.rd.fq.gz -l /mnt/md1/DATA/Data_Tam_DNAseq_2026_An6_BG5/X101SC26036392-Z01-J003/Release-X101SC26036392-Z01-J003-20260513_01/Data-X101SC26036392-Z01-J003/An6/2157_4C_PBK79106_7ec05c46/merged_An6_longreads.fastq.gz --mode normal -t 100 -o An6_unicycler_normal
    
     unicycler -1 /mnt/md1/DATA/Data_Tam_DNAseq_2026_An6_BG5/X101SC26036392-Z01-J002/clean_data/BG5/BG5_L1_1.clean.rd.fq.gz -2 /mnt/md1/DATA/Data_Tam_DNAseq_2026_An6_BG5/X101SC26036392-Z01-J002/clean_data/BG5/BG5_L1_2.clean.rd.fq.gz -l /mnt/md1/DATA/Data_Tam_DNAseq_2026_An6_BG5/X101SC26036392-Z01-J003/Release-X101SC26036392-Z01-J003-20260513_01/Data-X101SC26036392-Z01-J003/BG5/2157_4C_PBK79106_7ec05c46/merged_BG5_longreads.fastq.gz --mode normal -t 100 -o BG5_unicycler_normal
    
     unicycler -1 /mnt/md1/DATA/Data_Tam_DNAseq_2026_An6_BG5/X101SC26036392-Z01-J002/clean_data/An6/An6_L1_1.clean.rd.fq.gz -2 /mnt/md1/DATA/Data_Tam_DNAseq_2026_An6_BG5/X101SC26036392-Z01-J002/clean_data/An6/An6_L1_2.clean.rd.fq.gz -l /mnt/md1/DATA/Data_Tam_DNAseq_2026_An6_BG5/X101SC26036392-Z01-J003/Release-X101SC26036392-Z01-J003-20260513_01/Data-X101SC26036392-Z01-J003/An6/2157_4C_PBK79106_7ec05c46/merged_An6_longreads.fastq.gz --mode conservative -t 100 -o An6_unicycler_conservative
    
     unicycler -1 /mnt/md1/DATA/Data_Tam_DNAseq_2026_An6_BG5/X101SC26036392-Z01-J002/clean_data/BG5/BG5_L1_1.clean.rd.fq.gz -2 /mnt/md1/DATA/Data_Tam_DNAseq_2026_An6_BG5/X101SC26036392-Z01-J002/clean_data/BG5/BG5_L1_2.clean.rd.fq.gz -l /mnt/md1/DATA/Data_Tam_DNAseq_2026_An6_BG5/X101SC26036392-Z01-J003/Release-X101SC26036392-Z01-J003-20260513_01/Data-X101SC26036392-Z01-J003/BG5/2157_4C_PBK79106_7ec05c46/merged_BG5_longreads.fastq.gz --mode conservative -t 100 -o BG5_unicycler_conservative
    
     unicycler -1 /mnt/md1/DATA/Data_Tam_DNAseq_2026_An6_BG5/X101SC26036392-Z01-J002/clean_data/An6/An6_L1_1.clean.rd.fq.gz -2 /mnt/md1/DATA/Data_Tam_DNAseq_2026_An6_BG5/X101SC26036392-Z01-J002/clean_data/An6/An6_L1_2.clean.rd.fq.gz -l /mnt/md1/DATA/Data_Tam_DNAseq_2026_An6_BG5/X101SC26036392-Z01-J003/Release-X101SC26036392-Z01-J003-20260513_01/Data-X101SC26036392-Z01-J003/An6/2157_4C_PBK79106_7ec05c46/merged_An6_longreads.fastq.gz --mode bold -t 100 -o An6_unicycler_bold
    
     unicycler -1 /mnt/md1/DATA/Data_Tam_DNAseq_2026_An6_BG5/X101SC26036392-Z01-J002/clean_data/BG5/BG5_L1_1.clean.rd.fq.gz -2 /mnt/md1/DATA/Data_Tam_DNAseq_2026_An6_BG5/X101SC26036392-Z01-J002/clean_data/BG5/BG5_L1_2.clean.rd.fq.gz -l /mnt/md1/DATA/Data_Tam_DNAseq_2026_An6_BG5/X101SC26036392-Z01-J003/Release-X101SC26036392-Z01-J003-20260513_01/Data-X101SC26036392-Z01-J003/BG5/2157_4C_PBK79106_7ec05c46/merged_BG5_longreads.fastq.gz --mode bold -t 100 -o BG5_unicycler_bold
  3. Run nextflow bacass

     conda deactivate
    
     # Downlod k2_standard_08_GB_20251015.tar.gz from https://benlangmead.github.io/aws-indexes/k2#kraken2--bracken
     # Download 20190108_kmerfinder_stable_dirs.tar.gz from https://zenodo.org/records/13447056; 'tar xzf 20190108_kmerfinder_stable_dirs.tar.gz'  #The database does not work!
     # Download the kmerfinder database: https://www.genomicepidemiology.org/services/ --> https://cge.food.dtu.dk/services/KmerFinder/ --> https://cge.food.dtu.dk/services/KmerFinder/etc/kmerfinder_db.tar.gz  #The database works!
    
     # DEBUG: --kmerfinderdb /mnt/nvme1n1p1/REFs/kmerfinder/bacteria/ not working!
    
     nextflow run nf-core/bacass -r 2.6.0 -profile docker --help
     nextflow run nf-core/bacass -r 2.6.0 -profile docker \
       --input samplesheet_bacass.tsv \
       --outdir bacass_out \
       --assembly_type hybrid \
       --assembler unicycler,dragonflye \
       --kraken2db /mnt/nvme1n1p1/REFs/k2_standard_08_GB_20251015.tar.gz \
       --skip_kmerfinder \
       -resume \
       -work-dir bacass_out/work
    
     #We can skip kmerfinder since kraken2 do similar function:
     功能,KmerFinder,Kraken2,您的需求
     物种鉴定,✅ 基于 k-mer 频率,✅ 基于 k-mer 分类,二者选一即可
     污染筛查,✅ 可检测外源序列,✅ 可检测外源序列,✅ 有 Kraken2 足够
     数据库大小,~32 GB,~8 GB,Kraken2 更轻量
     运行速度,较慢,较快,Kraken2 更快
     细菌特异性,✅ 针对细菌优化,✅ 支持细菌,二者均可
    
     # Using Polished genomes for downstream analyses
     jhuang@WS-2290C:~/DATA/Data_Tam_DNAseq_2026_An6_BG5/bacass_out/Medaka$ grep ">" An6-unicycler-medaka_polished_genome.fa
     jhuang@WS-2290C:~/DATA/Data_Tam_DNAseq_2026_An6_BG5/bacass_out/Medaka$ grep ">" BG5-unicycler-medaka_polished_genome.fa
  4. Manually Unicycler+medaka_consensus+Polypolish/Pilon for 19606_adeAB

     # See https://bioinformatics.cc/wp-admin/post.php?post=429&action=edit
    
     conda activate /home/jhuang/miniconda3/envs/trycycler    # under jhuang@WS-2290C
     unicycler -1 /home/jhuang/DATA/Data_Foong_RNAseq_2021_ATCC19606_Cm/X101SC26025981-Z02-J001/01.RawData/19606_adeAB/19606_adeAB_1.fq.gz -2 /home/jhuang/DATA/Data_Foong_RNAseq_2021_ATCC19606_Cm/X101SC26025981-Z02-J001/01.RawData/19606_adeAB/19606_adeAB_2.fq.gz -l /mnt/md1/DATA/Data_Tam_Methylation_19606WT_adeAB_adeIJ_craA/X101SC26036392-Z01-J005/Release-X101SC26036392-Z01-J005-20260729_01/Data-X101SC26036392-Z01-J005/19606_adeAB/1625_2G_PBM33313_0ff34bb6/merged_19606_adeAB_longreads.fastq.gz --mode normal -t 100 -o adeAB_unicycler_normal
     unicycler -1 /home/jhuang/DATA/Data_Foong_RNAseq_2021_ATCC19606_Cm/X101SC26025981-Z02-J001/01.RawData/19606_adeAB/19606_adeAB_1.fq.gz -2 /home/jhuang/DATA/Data_Foong_RNAseq_2021_ATCC19606_Cm/X101SC26025981-Z02-J001/01.RawData/19606_adeAB/19606_adeAB_2.fq.gz -l /mnt/md1/DATA/Data_Tam_Methylation_19606WT_adeAB_adeIJ_craA/X101SC26036392-Z01-J005/Release-X101SC26036392-Z01-J005-20260729_01/Data-X101SC26036392-Z01-J005/19606_adeAB/1625_2G_PBM33313_0ff34bb6/merged_19606_adeAB_longreads.fastq.gz --mode bold -t 100 -o adeAB_unicycler_bold
     unicycler -1 /home/jhuang/DATA/Data_Foong_RNAseq_2021_ATCC19606_Cm/X101SC26025981-Z02-J001/01.RawData/19606_adeAB/19606_adeAB_1.fq.gz -2 /home/jhuang/DATA/Data_Foong_RNAseq_2021_ATCC19606_Cm/X101SC26025981-Z02-J001/01.RawData/19606_adeAB/19606_adeAB_2.fq.gz -l /mnt/md1/DATA/Data_Tam_Methylation_19606WT_adeAB_adeIJ_craA/X101SC26036392-Z01-J005/Release-X101SC26036392-Z01-J005-20260729_01/Data-X101SC26036392-Z01-J005/19606_adeAB/1625_2G_PBM33313_0ff34bb6/merged_19606_adeAB_longreads.fastq.gz --mode conservative -t 100 -o adeAB_unicycler_conservative
    
     # 1. Confirm Pilon already ran inside Unicycler
     grep -i pilon unicycler_out/unicycler.log
     # --> No Pilon step at all in the unicycler.log, so the assembly is mostly accurate (from Illumina contigs), but the long-read-derived bridge regions were never corrected with high-accuracy short reads → they may still carry indel/homopolymer errors.
    
     # 2. One long-read polish with Medaka on hamm only for adeAB, since WT and adeIJ
     rsync -a -P X101SC26036392-Z01-J005/Release-X101SC26036392-Z01-J005-20260729_01/Data-X101SC26036392-Z01-J005/19606_adeAB/1625_2G_PBM33313_0ff34bb6/merged_19606_adeAB_longreads.fastq.gz jhuang@10.169.63.113:/home/jhuang/DATA/Data_Tam_19606_WT_adeAB_adeIJ/
     rsync -a -P X101SC26036392-Z01-J005/Release-X101SC26036392-Z01-J005-20260729_01/Data-X101SC26036392-Z01-J005/19606_adeIJ/1625_2G_PBM33313_0ff34bb6/merged_19606_adeIJ_longreads.fastq.gz jhuang@10.169.63.113:/home/jhuang/DATA/Data_Tam_19606_WT_adeAB_adeIJ/
     rsync -a -P X101SC26036392-Z01-J005/Release-X101SC26036392-Z01-J005-20260729_01/Data-X101SC26036392-Z01-J005/19606WT/1625_2G_PBM33313_0ff34bb6/merged_19606WT_longreads.fastq.gz jhuang@10.169.63.113:/home/jhuang/DATA/Data_Tam_19606_WT_adeAB_adeIJ/
     cp adeAB_unicycler_conservative/assembly.fasta bacass_out/Unicycler/19606_adeAB-unicycler.scaffolds.fa
     rsync -a -P bacass_out/Unicycler/*-unicycler.scaffolds.fa jhuang@10.169.63.113:/home/jhuang/DATA/Data_Tam_19606_WT_adeAB_adeIJ/
    
     (medaka) jhuang@hamm:~/DATA/Data_Tam_19606_WT_adeAB_adeIJ$  medaka tools list_models | grep r1041
     Available: r103_fast_g507, r103_fast_snp_g507, r103_fast_variant_g507, r103_hac_g507, r103_hac_snp_g507, r103_hac_variant_g507, r103_sup_g507, r103_sup_snp_g507, r103_sup_variant_g507, r1041_e82_260bps_fast_g632, r1041_e82_260bps_fast_variant_g632, r1041_e82_260bps_hac_g632, r1041_e82_260bps_hac_v4.0.0, r1041_e82_260bps_hac_v4.1.0, r1041_e82_260bps_hac_variant_g632, r1041_e82_260bps_hac_variant_v4.1.0, r1041_e82_260bps_joint_apk_ulk_v5.0.0, r1041_e82_260bps_sup_g632, r1041_e82_260bps_sup_v4.0.0, r1041_e82_260bps_sup_v4.1.0, r1041_e82_260bps_sup_variant_g632, r1041_e82_260bps_sup_variant_v4.1.0, r1041_e82_400bps_bacterial_methylation, r1041_e82_400bps_fast_g615, r1041_e82_400bps_fast_g632, r1041_e82_400bps_fast_variant_g615, r1041_e82_400bps_fast_variant_g632, r1041_e82_400bps_hac_g615, r1041_e82_400bps_hac_g632, r1041_e82_400bps_hac_v4.0.0, r1041_e82_400bps_hac_v4.1.0, r1041_e82_400bps_hac_v4.2.0, r1041_e82_400bps_hac_v4.3.0, r1041_e82_400bps_hac_v5.0.0, r1041_e82_400bps_hac_v5.0.0_rl_lstm384_dwells, r1041_e82_400bps_hac_v5.0.0_rl_lstm384_no_dwells, r1041_e82_400bps_hac_v5.2.0, r1041_e82_400bps_hac_v5.2.0_rl_lstm384_dwells, r1041_e82_400bps_hac_v5.2.0_rl_lstm384_no_dwells, r1041_e82_400bps_hac_v6.0.0, r1041_e82_400bps_hac_v6.0.0_rl_lstm384_dwells, r1041_e82_400bps_hac_v6.0.0_rl_lstm384_no_dwells, r1041_e82_400bps_hac_variant_g615, r1041_e82_400bps_hac_variant_g632, r1041_e82_400bps_hac_variant_v4.1.0, r1041_e82_400bps_hac_variant_v4.2.0, r1041_e82_400bps_hac_variant_v4.3.0, r1041_e82_400bps_hac_variant_v5.0.0, r1041_e82_400bps_sup_g615, r1041_e82_400bps_sup_v4.0.0, r1041_e82_400bps_sup_v4.1.0, r1041_e82_400bps_sup_v4.2.0, r1041_e82_400bps_sup_v4.3.0, r1041_e82_400bps_sup_v5.0.0, r1041_e82_400bps_sup_v5.0.0_rl_lstm384_dwells, r1041_e82_400bps_sup_v5.0.0_rl_lstm384_no_dwells, r1041_e82_400bps_sup_v5.2.0, r1041_e82_400bps_sup_v5.2.0_rl_lstm384_dwells, r1041_e82_400bps_sup_v5.2.0_rl_lstm384_no_dwells, r1041_e82_400bps_sup_variant_g615, r1041_e82_400bps_sup_variant_v4.1.0, r1041_e82_400bps_sup_variant_v4.2.0, r1041_e82_400bps_sup_variant_v4.3.0, r1041_e82_400bps_sup_variant_v5.0.0, r104_e81_fast_g5015, r104_e81_fast_variant_g5015, r104_e81_hac_g5015, r104_e81_hac_variant_g5015, r104_e81_sup_g5015, r104_e81_sup_g610, r104_e81_sup_variant_g610, r941_e81_fast_g514, r941_e81_fast_variant_g514, r941_e81_hac_g514, r941_e81_hac_variant_g514, r941_e81_sup_g514, r941_e81_sup_variant_g514, r941_min_fast_g507, r941_min_fast_snp_g507, r941_min_fast_variant_g507, r941_min_hac_g507, r941_min_hac_snp_g507, r941_min_hac_variant_g507, r941_min_sup_g507, r941_min_sup_snp_g507, r941_min_sup_variant_g507, r941_prom_fast_g507, r941_prom_fast_snp_g507, r941_prom_fast_variant_g507, r941_prom_hac_g507, r941_prom_hac_snp_g507, r941_prom_hac_variant_g507, r941_prom_sup_g507, r941_prom_sup_snp_g507, r941_prom_sup_variant_g507, r941_sup_plant_g610, r941_sup_plant_variant_g610
     Default consensus:  r1041_e82_400bps_sup_v5.2.0
     Default variant:  r1041_e82_400bps_sup_variant_v5.0.0
    
     (trycycler) jhuang@WS-2290C:~/DATA/Data_Tam_Methylation_19606WT_adeAB_adeIJ_craA/X101SC26036392-Z01-J005$ find . -name "sequencing_summary*"
     ./Release-X101SC26036392-Z01-J005-20260729_01/Data-X101SC26036392-Z01-J005/19606_adeAB/1625_2G_PBM33313_0ff34bb6/sequencing_summary_PBM33313_0ff34bb6_ca9b9600.txt
     ./Release-X101SC26036392-Z01-J005-20260729_01/Data-X101SC26036392-Z01-J005/19606WT/1625_2G_PBM33313_0ff34bb6/sequencing_summary_PBM33313_0ff34bb6_ca9b9600.txt
     ./Release-X101SC26036392-Z01-J005-20260729_01/Data-X101SC26036392-Z01-J005/19606_adeIJ/1625_2G_PBM33313_0ff34bb6/sequencing_summary_PBM33313_0ff34bb6_ca9b9600.txt
    
     # ---- 抓取 Basecalling 模型(如 Dorado)----
     # Show the first fastq header lines directly (simplest)
     zcat $(find . -name "*.fastq.gz" | head -1) | head -n 4
     # Or extract the model string explicitly (stop after a few matches for speed)
     zcat $(find . -name "*.fastq.gz" | head -1) | grep -m 10 -o 'dna_r[^ ]*' | sort -u
     #--> dna_r10.4.1_e8.2_400bps_hac@v5.2.0_barcode12    DT:Z:2026-07-09T16:27:12.060751+08:00   PU:Z:PBM33313   LB:Z:FOND26H004005-1A   SM:Z:barcode12  al:Z:barcode12
     # Equivalent:
     zcat $(find . -name "*.fastq.gz" | head -1) | grep -m 10 -o 'model_version_id=[^ ]*' | sort -u
    
     # ---- 抓到了!真相大白。这是一个非常关键的发现!----
     从你提取出的 fastq header 信息中,我们看到了真实的 Basecalling 模型:
     👉 dna_r10.4.1_e8.2_400bps_hac@v5.2.0_barcode12
     ⚠️ 关键纠正:是 HAC,不是 SUP!
     之前我们根据诺禾致源的常规细菌完成图经验,推测他们使用的是超高精度的 SUP (Super Accuracy) 模型。但实际数据证明,他们这批数据使用的是 HAC (High Accuracy) 模型,版本正是 v5.2.0。
     在 Medaka 中,模型必须与 Basecalling 模型严格匹配。 如果你用 SUP 模型去抛光 HAC 的数据,神经网络会因为错误特征不匹配而导致抛光效果变差,甚至引入错误。
     🎯 最终 100% 匹配的 Medaka 模型
     根据你之前 medaka tools list_models 的列表,完美对应的模型是:r1041_e82_400bps_hac_v5.2.0
       * R10.4.1: 纳米孔的“物理结构”。代表第 10 代孔蛋白的 4.1 亚型。它的孔径比早期的 R9 更长,能同时容纳更多碱基,从而大幅提高了读取准确度。
       * e8.2: 纳米孔的“化学/工程微调”。代表孔蛋白的第 8 大代、第 2 次工程化微调版本(Engineering version)。
       * 400 bases per second: 马达蛋白的“测序速度”。DNA 以每秒 400 个碱基的速度穿过纳米孔(早期版本是 450bps,故意降到 400bps 是为了让电信号采样更密集、更清晰)。
       * High Accuracy: Basecalling 神经网络的“精度等级”。HAC 是较高精度的标准模型(比 SUP 稍不准,但计算更快)。
     🛠️ 最终正确的 Medaka 运行命令 (See bioinformatics.cc/unicyclermedaka_consensuspolypolish-pilon-manually/)
     (medaka) jhuang@hamm:~/DATA/Data_Tam_19606_WT_adeAB_adeIJ$ for c in 19606WT 19606_adeAB 19606_adeIJ; do
         medaka_consensus -i merged_${c}_longreads.fastq.gz -d ${c}-unicycler.scaffolds.fa -o "$c"/medaka -m r1041_e82_400bps_hac_v5.2.0 -t 20
         mv "$c"/medaka/consensus.fasta ${c}-unicycler-medaka_polished_genome.fa
         rm -r "$c"/medaka "$c" *.fai *.mmi  # clean up
     done
     mkdir unicycler-medaka_polished_genomes
     rsync -a -P jhuang@10.169.63.113:~/DATA/Data_Tam_19606_WT_adeAB_adeIJ/*-unicycler-medaka_polished_genome.fa unicycler-medaka_polished_genomes
    
     # 3. Short-read polish first (the priority) Polish the already-complete, circularized assembly with your Illumina reads.
     # 激活环境 (只需在循环外激活一次)
     conda activate /home/jhuang/miniconda3/envs/trycycler
     bash run_polypolish.sh
    
     # 4. Evaluate before & after with QUAST to confirm improvement
     quast.py assembly.fasta polypolished.fasta -o polish_compare
     # Confirm: genome size still ~3.9 Mb, circularity preserved, no new fragmentation
  5. Structural variant calling using Assemblytics.

     conda activate /home/jhuang/miniconda3/envs/bengal3_ac3
     # MLST calling
     for sample in 19606WT 19606_adeAB 19606_adeIJ; do
         mlst unicycler-medaka_polished_genomes/${sample}_polypolished.fasta >> mlst_res
     done
    
     conda activate sv_assembly
     for sample in 19606WT 19606_adeAB 19606_adeIJ; do
             nucmer --maxmatch -l 100 -c 500 CP059040.fasta unicycler-medaka_polished_genomes/${sample}_polypolished.fasta -p ${sample};
             delta-filter -1 -q ${sample}.delta > ${sample}.filtered.delta;
             #Usage: Assemblytics delta output_prefix    unique_length_required    min_size    max_size
             Assemblytics ${sample}.filtered.delta ${sample}_assemblytics 1000 100 500000;
     done
    
     ./merge_variants.sh
             #!/bin/bash
             # Define the output file name
             OUTPUT="merged_assemblytics_variants.txt"
             # 1. Write the header with the new 'Sample' column
             # We read the header from the first file, strip the '#', and append 'Sample'
             head -n 1 *_assemblytics.variant_preview.txt | grep '^#' | sed 's/^#//' | awk '{print $0 "\tSample"}' > "$OUTPUT"
             # 2. Loop through all matching files
             for file in *_assemblytics.variant_preview.txt; do
                 # Extract sample name (e.g., "HD46_Ctrl" from "HD46_Ctrl_assemblytics.variant_preview.txt")
                 sample=$(echo "$file" | sed 's/_assemblytics\.variant_preview\.txt//')
    
                 # Append data lines, skipping the header line (lines starting with '#')
                 # and append the sample name as the last column
                 grep -v '^#' "$file" | awk -v samp="$sample" '{print $0 "\t" samp}' >> "$OUTPUT"
             done
             echo "✅ Successfully merged $(ls *_assemblytics.variant_preview.txt | wc -l) files into $OUTPUT"
    
     #Manually sorted the generated file merged_assemblytics_variants.txt with Qwen.
  6. Structural variant report

     Based on the `merged_assemblytics_variants.txt` file, here is the summary of structural variants (SVs) identified specifically in your **long-sequencing complete genomes** (`19606WT`, `19606_adeAB`, and `19606_adeIJ`) compared to the reference genome CP059040.
    
     I have separated the **targeted knockouts** from the **inherent background variations** to make it ready for your manuscript or report.
    
     ### Table 1: Structural Variants in Complete Long-Read Assemblies (vs. CP059040)
    
     | Strain | Variant Type | Size (bp) | Reference Coordinates (CP059040) | Classification / Biological Significance |
     | :--- | :--- | :--- | :--- | :--- |
     | **19606WT** | Tandem Contraction | 52,668 | 2,810,861 - 2,863,470 | **Background variation** (inherent to your 19606 lab strain) |
     | | Tandem Contraction | 198 | 3,124,916 - 3,125,037 | **Background variation** |
     | **19606_adeAB** | **Deletion** | **4,282** | **1,844,323 - 1,848,605** | **Targeted ΔadeAB knockout** |
     | | Tandem Contraction | 52,668 | 2,810,861 - 2,863,470 | **Background variation** |
     | | Tandem Contraction | 198 | 3,124,916 - 3,125,037 | **Background variation** |
     | **19606_adeIJ** | **Deletion** | **4,436** | **737,224 - 741,667** | **Targeted ΔadeIJ knockout** |
     | | Tandem Contraction | 52,668 | 2,810,861 - 2,863,470 | **Background variation** |
     | | Tandem Contraction | 198 | 3,124,916 - 3,125,037 | **Background variation** |
    
     ---
    
     ### Table 2: Overall SV Burden Summary
    
     | Strain | Total SVs | Targeted Deletions | Background SVs |
     | :--- | :---: | :---: | :---: |
     | **19606WT** | 2 | 0 | 2 |
     | **19606_adeAB** | 3 | 1 | 2 |
     | **19606_adeIJ** | 3 | 1 | 2 |
    
     ---
    
     ### 💡 Key Takeaways for your Manuscript/Discussion:
    
     1. **Clean and Precise Knockouts:**
       The Assemblytics results perfectly validate your genetic engineering. The $\Delta$adeAB mutant shows exactly one major deletion of **4,282 bp**, and the $\Delta$adeIJ mutant shows one deletion of **4,436 bp**. These sizes match the expected lengths of the targeted operons. Crucially, **no other large off-target deletions or unintended rearrangements** occurred during the mutant construction.
    
     2. **High Genome Stability:**
       Apart from the intended target deletion, the chromosomes of both mutants are structurally identical to the `19606WT`. This proves that the knockout process did not induce global genomic instability or secondary structural variations.
    
     3. **Strain-Specific Background Variations:**
       The ~52.6 kb tandem contraction and the 198 bp contraction are present in the Wildtype as well as both mutants. Therefore, they are **not** artifacts of the knockout process. Instead, they represent natural structural differences (e.g., a prophage loss, genomic island contraction, or repeat variation) between your specific ATCC 19606 lab isolate and the NCBI reference sequence (CP059040). You can briefly mention this in your paper as a "strain-specific structural feature relative to the reference."
  7. Identify any IS and SNPs

     # TODOs !!!! see https://bioinformatics.cc/analysis-of-snps-indels-transposons-and-is-elements-in-5-a-baumannii-strains/

We have the ideal data for it: high-accuracy short reads for SNPs + complete long-read assemblies for IS elements (IS copies are near-identical repeats that short reads cannot resolve). Here’s the division of labor and concrete commands:

1. SNP identification

A. Short reads (gold standard) → snippy (you already have snippy_env)

conda activate /home/jhuang/miniconda3/envs/bengal3_ac3
for s in A6WT 19606adeAB adeIJ; do
  snippy --cpus 32 --outdir snippy/$s --ref CP059040.fasta \
    --R1 raw_data/${s}_R1.fastq.gz --R2 raw_data/${s}_R2.fastq.gz
done
# Core-genome SNP alignment across strains (for phylogeny / off-target check)
snippy-core --prefix core snippy/19606*

Outputs snps.tab (position, ref/alt, coverage, quality) per strain.

Alternative (bcftools): bwa mem → samtools sort → bcftools mpileup -f CP059040.fa | bcftools call -mv, then filter (QUAL≥30, DP≥10).

!!!!!!!!!!!!!!!!! TODO_AFTERNOON using Qwen NEXT_WEEK, finishing and send the results to Tam today or this week !!!!!!!!!!!!!!!!!! #to construct hybrid complete genomes and compare them with CP059040? #We would also like to request an analysis to identify any IS, SNPs, and large insertions or deletions (indels/structural variations) across these genomes. #Assume that no IS, SNPs, only large insertions or deletions.

B. Long reads / polished assemblies (validation)

# Assembly-vs-reference SNPs (your assemblies are Medaka+Polypolish polished → reliable)
nucmer --maxmatch -p wt_vs_ref CP059040.fa 19606WT_final.fasta
delta-filter -1 wt_vs_ref.delta > wt_vs_ref.1delta
show-snps -Clr wt_vs_ref.1delta > wt_vs_ref.snps

# OR read-based long-read variant calling (model must match your HAC v5.2.0 basecalling)
medaka_variant -i long_reads.fq.gz -d CP059040.fa \
  -m r1041_e82_400bps_hac_variant_v5.0.0 -t 32 -o medaka_var

High-confidence SNPs = intersection of short-read and long-read/assembly calls.

2. IS element identification

A. Annotate IS in each complete assembly → ISEScan + ISfinder BLAST

isescan.sh 19606WT_final.fasta bacteria 19606WT_is      # predicts IS copies + families
# Classify precisely against ISfinder:
makeblastdb -in ISfinder.fasta -dbtype nucl
blastn -query 19606WT_final.fasta -db ISfinder.fasta -evalue 1e-20 -outfmt 6

Compare copy number + insertion coordinates between CP059040, WT, and mutants → gains/losses of IS copies.

B. Detect new IS insertions vs the reference → Assemblytics + BLAST

You already have Assemblytics output. Take every Insertion / Tandem_expansion call, extract the inserted sequence from your assembly (using query_coordinates), and BLAST it against ISfinder:

samtools faidx 19606WT_final.fasta 
<ins_start>-<ins_end> > ins.fa
blastn -query ins.fa -db ISfinder.fasta -outfmt 6 -max_target_seqs 5

A hit to e.g. ISAba1/ISAba16/ISAba25 transposase = confirmed IS insertion.

C. Short-read support for IS junctions → ISMapper

ismapper -1 ${s}_R1.fastq.gz -2 ${s}_R2.fastq.gz \
  -ref CP059040.fa -inserts ISfinder.fasta -cov 10 -output ismap_$s

ISMapper reports left/right junctions of each IS relative to the reference — perfect for confirming that an insertion is real and present in the raw reads (not an assembly artifact).

D. Mutant-vs-WT comparison (off-target transposition check)

Run nucmer/Assemblytics mutant vs 19606WT (not just vs CP059040). Any insertion appearing only in a mutant = candidate new IS hop; classify it with the BLAST step above.

3. Filtering rules (avoid false positives)

  • Mask the knockout loci (adeAB 1,844,323–1,848,605; adeIJ 737,224–741,667) when counting SNPs/SVs.
  • Exclude SNPs within ~10 bp of indels or homopolymers (ONT/Illumina artifacts).
  • Exclude SNPs inside IS/repeat copies (mis-mapped reads); only keep SNPs in unique regions (delta-filter -1 already helps).
  • Require reciprocal support: short-read SNP confirmed by long-read assembly, IS insertion confirmed by junction-spanning reads in IGV.

Summary table

Variant Best data Tool Validation
SNPs Short reads snippy / bcftools nucmer show-snps / medaka_variant
IS copy number/position Long-read assemblies ISEScan + ISfinder BLAST IGM/IGV inspection
New IS insertions Assemblies vs ref/WT Assemblytics + BLAST ISMapper (short reads)

Want me to write a single bash script that runs snippy + nucmer + ISEScan + ISfinder-BLAST in a loop over your three strains and produces one combined SNP/IS table per strain?



Good catch — but it’s not a typo. The two model families are released on different schedules, and your medaka installation simply does not contain a v5.2.0 variant model. Look at your own medaka tools list_models output:

Model family (r1041_e82_400bps_hac) Available versions Best match for your hac@v5.2.0 reads
Consensus v4.0.0 → v4.3.0 → v5.0.0 → v5.2.0 → v6.0.0 ..._hac_v5.2.0 ✅ exact match exists
Variant g615/g632 → v4.1.0 → v4.2.0 → v4.3.0 → v5.0.0 (stops here) ..._hac_variant_v5.0.0 ⚠️ closest available

There is no r1041_e82_400bps_hac_variant_v5.2.0 (and not even a v6.0.0 variant model) — the variant line ends at v5.0.0. Even medaka’s own default variant model is still r1041_e82_400bps_sup_variant_v5.0.0.

Why the two lines are out of sync

  • The version suffix = the Dorado basecaller version whose reads the network was trained on.
  • Consensus models are cheap to retrain at every Dorado release (they learn to correct systematic basecalling errors using self-consistent training data), so they track every release (v5.2.0, v6.0.0…).
  • Variant models must be trained on curated truth-variant benchmarks to learn the difference between real mutations and basecalling artifacts. That’s expensive, so ONT updates them much more rarely.

Why the v5.0.0-vs-v5.2.0 mismatch is acceptable

  • Both are the same chemistry (R10.4.1 / e8.2 / 400 bps) and same network family; the error profile changed only marginally between Dorado v5.0.0 and v5.2.0.
  • What matters far more is matching the accuracy tier: HAC reads → HAC model. (Do not switch to the sup variant model just because it’s the default — the tier mismatch hurts more than the 0.2 version offset.)
  • For SNP calling, read depth, mapping quality, and your downstream filters (plus the short-read snippy cross-validation) dominate the result; a minor model-version offset is negligible.

Rule of thumb

  • Consensus: use the exact matching model when it exists → r1041_e82_400bps_hac_v5.2.0.
  • Variant: use the closest available model with the same chemistry + tier → r1041_e82_400bps_hac_variant_v5.0.0.

You can verify anytime with medaka tools list_models | grep hac_variant. If a future medaka release adds ..._hac_variant_v5.2.0, just switch to it then.

Leave a Reply

Your email address will not be published. Required fields are marked *