Created
May 21, 2022 14:26
-
-
Save lindenb/4eb3c0ae70161b08705a79252a8aa976 to your computer and use it in GitHub Desktop.
biostar9524046.nf https://www.biostars.org/p/9524046/ Forum:Compare the samples in a VCF concordance picard
This file contains 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
nextflow.enable.dsl=2 | |
params.vcf="" | |
workflow { | |
picard = downloadPicard() | |
samples_ch = vcf2samples(params.vcf).splitCsv(header: false,sep:'\t',strip:true) | |
pair_ch = samples_ch.combine(samples_ch).filter{T->!T[1].equals(T[3])} | |
concordances_ch = concordance(picard,pair_ch) | |
zipIt(concordances_ch.collect()) | |
} | |
process downloadPicard { | |
output: | |
path("picard.jar") | |
script: | |
""" | |
wget -O "picard.jar" "https://github.com/broadinstitute/picard/releases/download/2.27.1/picard.jar" | |
""" | |
} | |
process vcf2samples { | |
tag "${file(vcf).name}" | |
input: | |
val(vcf) | |
output: | |
path("samples.tsv") | |
script: | |
""" | |
bcftools query -l '${vcf}' | awk '{printf("${vcf}\t%s\\n",\$1);}' > samples.tsv | |
""" | |
} | |
process concordance { | |
tag "${sn1} / ${sn2}" | |
input: | |
path(picard) | |
tuple val(vcf1),val(sn1),val(vcf2),val(sn2) | |
output: | |
path("out.paths") | |
script: | |
""" | |
java -jar ${picard} GenotypeConcordance \ | |
CALL_VCF=${vcf1} \ | |
CALL_SAMPLE=${sn1} \ | |
O="${sn1}_${sn2}" \ | |
TRUTH_VCF=${vcf2} \ | |
TRUTH_SAMPLE=${sn2} | |
find \${PWD} -type f -name "*_metrics" > out.paths | |
""" | |
} | |
process zipIt { | |
tag "N=${L.size()}" | |
input: | |
val(L) | |
output: | |
path("concordances.zip") | |
script: | |
""" | |
cat ${L.join(" ")} | zip -@ -9 -j concordances.zip | |
""" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment