A Nextflow implementation of the BioResource Genetic QC Pipeline, originally written as a bash script (fullpipe.sh).
This pipeline performs quality control (QC) on genetic data in PLINK format. It includes the following steps:
- Initial data check and missingness filtering
- Hardy-Weinberg equilibrium (HWE) filtering
- Sex check and heterozygosity analysis
- Identity-by-descent (IBD) analysis
- Ancestry analysis using 1000 Genomes reference data
- Nextflow (>=22.10.0)
- Docker or Conda
- PLINK 1.9
- PLINK 2.0
- R (>=4.3.0) with required packages
-
Clone this repository:
git clone https://github.com/yourusername/bioresource-qc-pipeline.git cd bioresource-qc-pipeline -
Install Nextflow:
curl -s https://get.nextflow.io | bash -
Choose your execution method:
- Docker:
docker build -t bioresource-qc:latest . - Conda: No additional steps required, the pipeline will create the environment automatically
- Docker:
nextflow run main.nf --data /path/to/plink_files_prefix --name study_name--data: Path to the input PLINK files (without the .bed/.bim/.fam extension)--name: Study name (e.g., GLADv3, GLADv3_eur)
--outdir: Output directory (default: results)--maf: Minor allele frequency threshold (default: 0.01)--SNP_CR: SNP call rate threshold (default: 95)--Sample_CR: Sample call rate threshold (default: 95)--geno: Missing variant threshold (default: 0.05)--mind: Missing individual threshold (default: 0.05)--hwe: Hardy-Weinberg equilibrium threshold (default: 0.0000000001)--ibd: Pairwise identical-by-descent threshold (default: 0.1875)--ind_ibd: Individual IBD outlier, standard deviations (default: 3)
-
conda: Uses Conda for dependency managementnextflow run main.nf -profile conda --data /path/to/plink_files_prefix --name study_name
-
docker: Uses Docker for dependency managementnextflow run main.nf -profile docker --data /path/to/plink_files_prefix --name study_name
-
singularity: Uses Singularity for dependency managementnextflow run main.nf -profile singularity --data /path/to/plink_files_prefix --name study_name
-
slurm: Uses Slurm workload manager for HPC clustersnextflow run main.nf -profile slurm --data /path/to/plink_files_prefix --name study_name
-
slurm_conda: Combines Slurm with Conda environment managementnextflow run main.nf -profile slurm_conda --data /path/to/plink_files_prefix --name study_name
-
slurm_singularity: Combines Slurm with Singularity containersnextflow run main.nf -profile slurm_singularity --data /path/to/plink_files_prefix --name study_name
For detailed Slurm usage instructions, see docs/SLURM_USAGE.md.
Quick start for Slurm:
# Submit as a Slurm job
sbatch scripts/submit_slurm.sh /path/to/plink_files study_name
# Or run directly with Slurm profile
nextflow run main.nf -profile slurm -c conf/slurm.config --data /path/to/plink_files --name study_nameThe pipeline creates a directory structure with the following components:
results/
└── study_name_timestamp/
├── QC_pipeline_review_documents_study_name/
│ ├── Het_check_hist_study_name.pdf
│ ├── HetFhat2_SexF_study_name.pdf
│ ├── IBD_hist_study_name.pdf
│ ├── Iterative_missingness_table_study_name.txt
│ ├── callrate_pihat_over_9_study_name.txt
│ ├── pihat_btw_4_6_study_name.txt
│ ├── pihat_over_9_study_name.txt
│ ├── sexmismatch_study_name.txt
│ └── ... (other QC plots and tables)
├── study_name_finalreport.log
├── study_name_ancestry_identifier.log
├── study_name.PCs_plot_super_pop.png
└── ... (other output files)
The pipeline requires 1000 Genomes reference data for ancestry analysis. These files should be placed in the ref/1kg/ directory:
1KG_Phase3.chr*.bed/bim/fam: 1000 Genomes PLINK files per chromosomeref_super_pop_keep_list.txt: Reference population scale fileref_pop_dat_reduced.txt: Population data file
This Nextflow implementation includes several important improvements over the original bash script:
-
Separated PLINK Operations: All
system()calls to PLINK/PLINK2 in R scripts (especially inancestry_identifier.r) have been moved to dedicated Nextflow processes, following best practices for workflow management. -
Modular Architecture: Each QC step is now implemented as a separate, reusable Nextflow module with proper input/output channel handling.
-
Improved Resource Management: Automatic CPU and memory allocation based on process requirements, with configurable resource limits.
-
Enhanced Error Handling: Built-in retry mechanisms and better error reporting.
-
Containerization Support: Full support for Docker, Singularity, and Conda environments for reproducible execution.
-
Execution Tracking: Comprehensive execution reports, timelines, and resource usage tracking.
This project is licensed under the MIT License - see the LICENSE file for details.
- Original bash script developed by the BioResource team
- Nextflow implementation by [Your Name]