Skip to content
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

Handle new reference naming #173

Merged
merged 8 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions modules/local/ancestry/bootstrap/make_database.nf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ process MAKE_DATABASE {

input:
path '*'
tuple val(grch37_king_meta), path(grch37_king)
tuple val(grch38_king_meta), path(grch38_king)
path checksums

output:
Expand All @@ -26,6 +28,12 @@ process MAKE_DATABASE {

echo $workflow.manifest.version > meta.txt

# can't use meta variables in stageAs
# don't want to use renameTo because it's destructive for the input
cp -L $grch37_king ${grch37_king_meta.build}_${grch37_king_meta.id}.king.cutoff.out.id
cp -L $grch38_king ${grch38_king_meta.build}_${grch38_king_meta.id}.king.cutoff.out.id
rm $grch37_king $grch38_king

tar --dereference -acf pgsc_calc.tar.zst *

cat <<-END_VERSIONS > versions.yml
Expand Down
16 changes: 8 additions & 8 deletions modules/local/plink2_relabelpvar.nf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ process PLINK2_RELABELPVAR {

tag "$meta.id chromosome $meta.chrom"

storeDir ( params.genotypes_cache ? "$params.genotypes_cache/${meta.id}/${params.target_build}/${meta.chrom}" :
"$workDir/genomes/${meta.id}/${params.target_build}/${meta.chrom}/")
storeDir ( params.genotypes_cache ? "$params.genotypes_cache/${meta.id}/${meta.build}/${meta.chrom}" :
"$workDir/genomes/${meta.id}/${meta.build}/${meta.chrom}/")

conda "${task.ext.conda}"

Expand All @@ -21,9 +21,9 @@ process PLINK2_RELABELPVAR {
tuple val(meta), path(geno), path(pheno), path(variants)

output:
tuple val(meta), path("*.pgen"), emit: geno
tuple val(meta), path("*.zst") , emit: variants
tuple val(meta), path("*.psam"), emit: pheno
tuple val(meta), path("${meta.build}_*.pgen"), emit: geno
tuple val(meta), path("${meta.build}_*.pvar.zst") , emit: variants
tuple val(meta), path("${meta.build}_*.psam"), emit: pheno
tuple val(meta), path("*.vmiss.gz"), emit: vmiss
path "versions.yml" , emit: versions

Expand All @@ -49,11 +49,11 @@ process PLINK2_RELABELPVAR {
$set_ma_missing \\
--pfile ${geno.baseName} $compressed \\
--make-just-pvar zs \\
--out ${params.target_build}_${prefix}${meta.chrom}
--out ${meta.build}_${prefix}${meta.chrom}

# cross platform (mac, linux) method of preserving symlinks
cp -a $geno ${params.target_build}_${prefix}${meta.chrom}.pgen
cp -a $pheno ${params.target_build}_${prefix}${meta.chrom}.psam
cp -a $geno ${meta.build}_${prefix}${meta.chrom}.pgen
nebfield marked this conversation as resolved.
Show resolved Hide resolved
cp -a $pheno ${meta.build}_${prefix}${meta.chrom}.psam
gzip *.vmiss

cat <<-END_VERSIONS > versions.yml
Expand Down
24 changes: 13 additions & 11 deletions subworkflows/local/ancestry/bootstrap_ancestry.nf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Create a database containing reference data required for ancestry inference
//
include { SETUP_RESOURCE } from '../../../modules/local/ancestry/bootstrap/setup_resource'
include { PLINK2_RELABELPVAR } from '../../../modules/local/plink2_relabelpvar'
include { PLINK2_RELABELPVAR as BOOTSTRAP_RELABEL } from '../../../modules/local/plink2_relabelpvar'
include { MAKE_DATABASE } from '../../../modules/local/ancestry/bootstrap/make_database'

workflow BOOTSTRAP_ANCESTRY {
Expand Down Expand Up @@ -33,11 +33,11 @@ workflow BOOTSTRAP_ANCESTRY {

SETUP_RESOURCE.out.plink.dump( tag: 'ref_setup' )

PLINK2_RELABELPVAR( SETUP_RESOURCE.out.plink )
ch_versions = ch_versions.mix(PLINK2_RELABELPVAR.out.versions.first())
BOOTSTRAP_RELABEL( SETUP_RESOURCE.out.plink )
ch_versions = ch_versions.mix(BOOTSTRAP_RELABEL.out.versions.first())

PLINK2_RELABELPVAR.out.geno
.concat(PLINK2_RELABELPVAR.out.pheno, PLINK2_RELABELPVAR.out.variants)
BOOTSTRAP_RELABEL.out.geno
.concat(BOOTSTRAP_RELABEL.out.pheno, BOOTSTRAP_RELABEL.out.variants)
.dump(tag: 'ancestry_relabelled')
.set { relabelled }

Expand All @@ -47,12 +47,14 @@ workflow BOOTSTRAP_ANCESTRY {
.groupTuple(size: 3)
.dump(tag: 'ancestry_relabelled_grouped')
.map { drop_meta_keys(it).flatten() }
.set{ relabelled_flat }
.set{ relabelled_flat }

ref.king
.map { drop_meta_keys(it) }
// dropping meta keys simplifies the join
.join( relabelled_flat )
ref.king.branch {
GRCh37: it[0].build == "GRCh37"
GRCh38: it[0].build == "GRCh38"
}.set { ch_king }

relabelled_flat
.flatten()
.filter(Path)
.collect()
Expand All @@ -62,7 +64,7 @@ workflow BOOTSTRAP_ANCESTRY {
Channel.fromPath(params.ancestry_checksums, checkIfExists: true)
.set { ch_checksums }

MAKE_DATABASE( ch_raw_ref, ch_checksums )
MAKE_DATABASE( ch_raw_ref, ch_king.GRCh37, ch_king.GRCh38, ch_checksums )
ch_versions = ch_versions.mix(MAKE_DATABASE.out.versions)

emit:
Expand Down