-
Notifications
You must be signed in to change notification settings - Fork 953
Add minimac4 imputation subworkfllow #9451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
LouisLeNezet
merged 17 commits into
nf-core:master
from
LouisLeNezet:vcf_impute_minimac4
Dec 11, 2025
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
1827107
Add vcf_impute_minimac4
LouisLeNezet fb0af5b
Merge branch 'master' into vcf_impute_minimac4
LouisLeNezet 8e17f02
Update linting
LouisLeNezet 5990923
Update test
LouisLeNezet d125a00
Fix linting
LouisLeNezet 7c11636
Merge branch 'master' into vcf_impute_minimac4
LouisLeNezet 87763ce
Update minimac4 sbwf
LouisLeNezet 4e6a12e
Merge branch 'master' into vcf_impute_minimac4
LouisLeNezet fd65a4b
Remove tag
LouisLeNezet 262e1c2
Remove tag
LouisLeNezet 2c1fa5a
Fix linting
LouisLeNezet 21706d5
Add comment
LouisLeNezet 66c8fd1
Merge branch 'master' into vcf_impute_minimac4
LouisLeNezet 0c1d34b
Update snapshot
LouisLeNezet 93587a2
Merge branch 'master' into vcf_impute_minimac4
LouisLeNezet 5bfa26e
Fix nf-test
LouisLeNezet 3720bbd
Merge branch 'master' into vcf_impute_minimac4
LouisLeNezet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| include { MINIMAC4_COMPRESSREF } from '../../../modules/nf-core/minimac4/compressref' | ||
| include { MINIMAC4_IMPUTE } from '../../../modules/nf-core/minimac4/impute' | ||
| include { GLIMPSE2_LIGATE } from '../../../modules/nf-core/glimpse2/ligate' | ||
| include { BCFTOOLS_INDEX as BCFTOOLS_INDEX_PHASE } from '../../../modules/nf-core/bcftools/index' | ||
| include { BCFTOOLS_INDEX as BCFTOOLS_INDEX_LIGATE } from '../../../modules/nf-core/bcftools/index' | ||
|
|
||
| workflow VCF_IMPUTE_MINIMAC4 { | ||
| take: | ||
| ch_input // channel (mandatory): [ [id, chr], vcf, tbi ] | ||
| ch_panel // channel (mandatory): [ [panel, chr], vcf, tbi ] | ||
| ch_posfile // channel (optional) : [ [panel, chr], sites_vcf, sites_index ] | ||
| ch_chunks // channel (optional) : [ [panel, chr], regionout ] | ||
| ch_map // channel (optional) : [ [panel, chr], map] | ||
|
|
||
| main: | ||
|
|
||
| ch_versions = channel.empty() | ||
|
|
||
| ch_panel_branched = ch_panel.branch { _meta, file, _index -> | ||
| def name = file.toString() | ||
| vcf: name.matches(/.*\.(vcf|bcf)(\.gz)?$/) | ||
| msav: name.endsWith('.msav') | ||
| other: true | ||
| } | ||
|
|
||
| ch_panel_branched.other.map { | ||
| error("ERROR: ch_panel files must be either VCF/BCF or MSAV.") | ||
| } | ||
|
|
||
| // Compress reference panel to MSAV format | ||
| MINIMAC4_COMPRESSREF(ch_panel_branched.vcf) | ||
| ch_versions = ch_versions.mix(MINIMAC4_COMPRESSREF.out.versions.first()) | ||
|
|
||
| ch_panel_msav = MINIMAC4_COMPRESSREF.out.msav.mix( | ||
| ch_panel_branched.msav.map { meta, file, _index -> [meta, file] } | ||
| ) | ||
|
|
||
| // Channel with all reference and chunks informations | ||
| // [ meta, reference panel msav, sites to impute vcf, sites index, region to impute, genetic map ] | ||
| ch_panel_impute = ch_panel_msav | ||
LouisLeNezet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .combine(ch_posfile, by: 0) | ||
| .combine(ch_chunks, by: 0) | ||
| .combine(ch_map, by: 0) | ||
|
|
||
| ch_panel_impute.ifEmpty { | ||
| error("ERROR: join operation resulted in an empty channel. Please provide a valid ch_posfile, ch_chunks and ch_map channel as input.") | ||
| } | ||
|
|
||
| // Prepare input channels for MINIMAC4 | ||
| ch_minimac4_input = ch_input | ||
| .combine(ch_panel_impute) | ||
| .map { metaI, target_vcf, target_tbi, metaPC, ref_msav, sites_vcf, sites_index, regionout, map -> | ||
| [ | ||
| metaPC + metaI + ["regionout": regionout], | ||
| target_vcf, | ||
| target_tbi, | ||
| ref_msav, | ||
| sites_vcf, | ||
| sites_index, | ||
| map, | ||
| regionout, | ||
| ] | ||
| } | ||
| // Perform imputation | ||
| MINIMAC4_IMPUTE(ch_minimac4_input) | ||
| ch_versions = ch_versions.mix(MINIMAC4_IMPUTE.out.versions.first()) | ||
|
|
||
| // Index the output VCF file | ||
| BCFTOOLS_INDEX_PHASE(MINIMAC4_IMPUTE.out.vcf) | ||
| ch_versions = ch_versions.mix(BCFTOOLS_INDEX_PHASE.out.versions.first()) | ||
|
|
||
| // Ligate all phased files in one and index it | ||
| ligate_input = MINIMAC4_IMPUTE.out.vcf | ||
| .join( | ||
| BCFTOOLS_INDEX_PHASE.out.tbi.mix(BCFTOOLS_INDEX_PHASE.out.csi) | ||
| ) | ||
| .map { meta, vcf, index -> | ||
| def keysToKeep = meta.keySet() - ['regionout'] | ||
| [meta.subMap(keysToKeep), vcf, index] | ||
| } | ||
| .groupTuple() | ||
|
|
||
| GLIMPSE2_LIGATE(ligate_input) | ||
| ch_versions = ch_versions.mix(GLIMPSE2_LIGATE.out.versions.first()) | ||
|
|
||
| BCFTOOLS_INDEX_LIGATE(GLIMPSE2_LIGATE.out.merged_variants) | ||
| ch_versions = ch_versions.mix(BCFTOOLS_INDEX_LIGATE.out.versions.first()) | ||
|
|
||
| // Join imputed and index files | ||
| ch_vcf_index = GLIMPSE2_LIGATE.out.merged_variants.join( | ||
| BCFTOOLS_INDEX_LIGATE.out.tbi.mix(BCFTOOLS_INDEX_LIGATE.out.csi) | ||
| ) | ||
|
|
||
| emit: | ||
| vcf_index = ch_vcf_index // channel: [ [id, panel, chr], vcf, index ] | ||
| versions = ch_versions // channel: [ versions.yml ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| # yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/subworkflows/yaml-schema.json | ||
| name: "VCF_IMPUTE_MINIMAC4" | ||
| description: | | ||
| Subworkflow to impute VCF files using MINIMAC4 software. The subworkflow | ||
| takes VCF files, phased reference panel, and genetic maps to perform imputation | ||
| and outputs phased and imputed VCF files. | ||
| Meta map of all channels, except ch_input, will be used to perform joint operations. | ||
| "regionout" key will be added to the meta map to distinguish the different file | ||
| before ligation and therefore should not be used. | ||
| keywords: | ||
| - VCF | ||
| - imputation | ||
| - minimac4 | ||
| - phasing | ||
| - MSAV | ||
| components: | ||
| - minimac4/compressref | ||
| - minimac4/impute | ||
| - bcftools/index | ||
| - glimpse2/ligate | ||
| input: | ||
| - ch_input: | ||
| description: Channel with input data | ||
| structure: | ||
| - meta: | ||
| type: map | ||
| description: | | ||
| Metadata map containing sample information | ||
| - vcf: | ||
| type: file | ||
| description: Input VCF files | ||
| pattern: "*.{vcf,bcf,vcf.gz}" | ||
| - index: | ||
| type: file | ||
| description: Input index file | ||
| pattern: "*.{tbi,csi}" | ||
| - ch_panel: | ||
| description: Channel with phased reference panel data | ||
| structure: | ||
| - meta: | ||
| type: map | ||
| description: | | ||
| Metadata map that will be combined with the input data map | ||
| - vcf: | ||
| type: file | ||
| description: Reference panel VCF files by chromosomes | ||
| pattern: "*.{vcf,bcf,vcf.gz}" | ||
| - index: | ||
| type: file | ||
| description: Reference panel VCF index files | ||
| pattern: "*.{tbi,csi}" | ||
| - ch_posfile: | ||
| description: Channel with variants position to impute | ||
| structure: | ||
| - meta: | ||
| type: map | ||
| description: | | ||
| Metadata map containing chromosome information | ||
| - sites_vcf: | ||
| type: file | ||
| descrition: | | ||
| VCF/BCF file containing position to impute | ||
| - sites_index: | ||
| type: file | ||
| description: | | ||
| CSI|TBI index file of the sites to impute | ||
| - ch_chunks: | ||
| description: Channel containing the region to impute | ||
| structure: | ||
| - meta: | ||
| type: map | ||
| description: | | ||
| Metadata map containing chromosome information | ||
| - regionout: | ||
| type: string | ||
| description: Region to perform the phasing on | ||
| pattern: "[chr]+[0-9]+:[0-9]+-[0-9]+" | ||
| - ch_map: | ||
| description: Channel with genetic map data | ||
| structure: | ||
| - meta: | ||
| type: map | ||
| description: | | ||
| Metadata map containing chromosome information | ||
| - map: | ||
| type: file | ||
| description: Minimac format genetic map files | ||
| pattern: "*.map" | ||
| output: | ||
| - vcf_index: | ||
| description: Channel with imputed and phased VCF files | ||
| structure: | ||
| - meta: | ||
| type: map | ||
| description: | | ||
| Metadata map of the target input file combined with the reference panel map. | ||
| - vcf: | ||
| type: file | ||
| description: VCF imputed and phased file by sample | ||
| pattern: "*.{vcf,bcf,vcf.gz}" | ||
| - index: | ||
| type: file | ||
| description: VCF index file | ||
| pattern: "*.{tbi,csi}" | ||
| - versions: | ||
| description: Channel containing software versions file | ||
| structure: | ||
| - versions.yml: | ||
| type: file | ||
| description: File containing versions of the software used | ||
| authors: | ||
| - "@LouisLeNezet" | ||
| - "@gichas" | ||
| maintainers: | ||
| - "@LouisLeNezet" | ||
| - "@gichas" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.