Skip to content

HybPhaser

HybPhaser detects hybrids and polyploids in target capture data and phases them. It measures the heterozygosity of each sample and gene, and separates the reads of hybrid samples by their similarity to samples that represent the parental clades. HybPhaser works on the output of HybPiper.

License

Free to use and open source under the GNU General Public License v3.0.

Available

  • Roihu-CPU: 2.1, via the bio-apps module.

Usage

HybPhaser is part of the bio-apps collection on Roihu. Load the bio-apps module tree and then the HybPhaser module:

module load bio-apps/v202603
module load hybphaser/2.1

The module also loads the programs HybPhaser uses: BWA, SAMtools, BCFtools, BBMap and R with the packages the R scripts need.

HybPhaser consists of bash scripts that map the reads and R scripts that analyze the results. If you assembled your samples with the HybPiper option --compress_sample_folder, extract each sample archive (tar -xzf <sample>.tar.gz) before running HybPhaser.

Consensus sequences

The first step maps the reads of each sample and gene to the contigs assembled by HybPiper and generates consensus sequences, with ambiguity codes at the heterozygous sites:

1_generate_consensus_sequences.sh -n namelist.txt -p hybpiper_results -o hybphaser_out -t 8

Here namelist.txt lists the sample names, one per line, -p is the folder with the HybPiper results and -o is the HybPhaser output folder. The -t option sets the number of threads for the mapping and variant calling.

R scripts and the configuration file

The R scripts read their settings from a file called config.txt in the directory where you run them. Copy the template to your working directory and set the variables in it, for example the paths to the output folder, the target file and the name list:

cp $HYBPHASER_INSTROOT/share/hybphaser/config.txt .

Then run the R scripts of each part from that directory. For example, the SNP assessment (part 1):

Rscript $HYBPHASER_INSTROOT/share/hybphaser/1a_count_snps.R
Rscript $HYBPHASER_INSTROOT/share/hybphaser/1b_assess_dataset.R
Rscript $HYBPHASER_INSTROOT/share/hybphaser/1c_generate_sequence_lists.R

HybPhaser_Main_script.R in the same directory lists all the steps in order. Between the parts, you check the results and set new variables in config.txt, for example the clade references for the clade association (part 2) and the samples to phase (part 3). Templates for these files are in $HYBPHASER_INSTROOT/share/hybphaser/example_files. The 2_extract_mapped_reads.sh script extracts the reads that mapped to the targets, to use in the clade association.

Example batch script

This script runs the consensus sequence step and counts the SNPs. Set the variables in config.txt before submitting it.

#!/bin/bash
#SBATCH --job-name=hybphaser
#SBATCH --account=<project>
#SBATCH --output=output_%j.txt
#SBATCH --error=errors_%j.txt
#SBATCH --partition=small
#SBATCH --time=04:00:00
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=8
#SBATCH --mem=16G

module load bio-apps/v202603
module load hybphaser/2.1

1_generate_consensus_sequences.sh -n namelist.txt -p hybpiper_results -o hybphaser_out -t $SLURM_CPUS_PER_TASK
Rscript $HYBPHASER_INSTROOT/share/hybphaser/1a_count_snps.R

Replace <project> with your CSC project (for example project_2001234).

See creating a batch job script for Roihu for more information about running batch jobs.

Support

CSC Service Desk

More information

December 2, 2026