From 06d28c7f8b860182f81820bce0576b8b8f31eb99 Mon Sep 17 00:00:00 2001
From: Chris Hartl
Date: Thu, 10 Oct 2013 12:53:15 -0400
Subject: [PATCH] VariantsToBinaryPed: Move .fam file writing to initialize to
ensure ordering matches the ordering of the VCF. Change the documentation to
clarify that the fam files are not directly copied, but subset and
re-ordered.
---
.../walkers/variantutils/VariantsToBinaryPed.java | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToBinaryPed.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToBinaryPed.java
index c414b443e..55b4c0029 100644
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToBinaryPed.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToBinaryPed.java
@@ -81,8 +81,9 @@ public class VariantsToBinaryPed extends RodWalker {
* wherein unknown parents needn't be specified. The columns are the individual ID, and a list of key-value pairs.
*
* Regardless of which file is specified, the walker will output a .fam file alongside the bed file. If the
- * command line has "-md [name].fam", the fam file will simply be copied. However, if a metadata file of the
- * alternate format is passed by "-md [name].txt", the walker will construct a formatted .fam file from the data.
+ * command line has "-md [name].fam", the fam file will be subset and reordered to match the sample content and ordering
+ * of the VCF. However, if a metadata file of the alternate format is passed by "-md [name].txt", the walker will
+ * construct a formatted .fam file from the data.
*
*/
@Input(shortName="m",fullName = "metaData",required=true,doc="Sample metadata file. You may specify a .fam file " +
@@ -170,6 +171,13 @@ public class VariantsToBinaryPed extends RodWalker {
if ( ! sampleMetaValues.containsKey(sample) ) {
throw new UserException("No metadata provided for sample "+sample);
}
+ Map mVals = sampleMetaValues.get(sample);
+ String fid = mVals.containsKey("fid") ? mVals.get("fid") : String.format("dummy_%d",++dummyID);
+ String pid = mVals.containsKey("dad") ? mVals.get("dad") : String.format("dummy_%d",++dummyID);
+ String mid = mVals.containsKey("mom") ? mVals.get("mom") : String.format("dummy_%d",++dummyID);
+ String sex = mVals.containsKey("sex") ? mVals.get("sex") : "3";
+ String pheno = mVals.containsKey("phenotype") ? mVals.get("phenotype") : "-1";
+ outFam.printf("%s\t%s\t%s\t%s\t%s\t%s%n",fid,sample,pid,mid,sex,pheno);
}
if ( mode == OutputMode.INDIVIDUAL_MAJOR ) {
// only need to instantiate the files and buffers if in individual major.
@@ -469,7 +477,6 @@ public class VariantsToBinaryPed extends RodWalker {
values.put("sex",sex);
values.put("phenotype",pheno);
metaValues.put(sid,values);
- outFam.printf("%s%n",line);
}
} else {
for ( String line : new XReadLines(metaDataFile) ) {