diff --git a/docs/api/examples.rst b/docs/api/examples.rst index 608b5854..09882ce9 100644 --- a/docs/api/examples.rst +++ b/docs/api/examples.rst @@ -6,9 +6,9 @@ examples Converting a ``.blocks.det`` file into a ``.hap`` file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -You can use the :ref:`data API ` to easily convert `a PLINK 1.9 .blocks.det file `_ into a ``.hap`` file. +You can use the :ref:`data API ` to convert `a PLINK 1.9 .blocks.det file `_ into a ``.hap`` file. -As an example, let's say we would like to convert `the following .blocks.det file `_. +As an example, let's say we would like to convert `the following simple.blocks.det file `_. .. include:: ../../tests/data/simple.blocks.det :literal: @@ -31,7 +31,7 @@ As an example, let's say we would like to convert `the following .blocks.det fil for idx, line in enumerate(blocks_file.read().splitlines()[1:]): # initialize variables and parse line from the blocks file hap_id = f"H{idx}" - chrom, bp1, bp2, kb, nsnps, snps = line.split("\t") + chrom, bp1, bp2, kb, nsnps, snps = line.strip().split() # create a haplotype line in the .hap file hp.data[hap_id] = data.Haplotype( @@ -72,7 +72,7 @@ Then your ``.hap`` file might look something like this. .. include:: ../../tests/data/apoe.hap :literal: -You can easily use the :ref:`data API ` and the :ref:`simphenotype API ` to create such a file. +You can use the :ref:`data API ` and the :ref:`simphenotype API ` to create such a file. .. code-block:: python diff --git a/docs/commands/transform.rst b/docs/commands/transform.rst index 4fe6a9bc..2a500207 100644 --- a/docs/commands/transform.rst +++ b/docs/commands/transform.rst @@ -6,7 +6,7 @@ transform Transform a set of genotypes via a list of haplotypes. Create a new VCF containing haplotypes instead of variants. -The ``transform`` command takes as input a set of genotypes and a list of haplotypes and outputs a set of haplotype *pseudo-genotypes*, where each haplotype is encoded as a bi-allelic variant record in the output. In other words, each sample will have a genotype of ``0|0``, ``1|0``, ``0|1``, or ``1|1`` indicating whether each of their two chromosome copies contains the alleles of a haplotype. +The ``transform`` command takes as input a set of **phased** genotypes and a list of haplotypes and outputs a set of haplotype *pseudo-genotypes*, where each haplotype is encoded as a bi-allelic variant record in the output. In other words, each sample will have a genotype of ``0|0``, ``1|0``, ``0|1``, or ``1|1`` indicating whether each of their two chromosome copies contains the alleles of a haplotype. .. figure:: https://drive.google.com/uc?id=1GyluoQ3IeGXo9FjWsCC3XwaRuflr68pn :figwidth: 600 diff --git a/tests/data/simple.blocks.det b/tests/data/simple.blocks.det index 19c4c3e4..cc36a3a5 100644 --- a/tests/data/simple.blocks.det +++ b/tests/data/simple.blocks.det @@ -1,4 +1,4 @@ -CHR BP1 BP2 KB NSNPS SNPS -1 10114 10117 2.001 2 1:10114:T:C|1:10116:A:G -1 10114 10119 2.007 2 1:10114:T:C|1:10117:C:A -1 10116 10119 2.011 2 1:10116:A:G|1:10117:C:A +CHR BP1 BP2 KB NSNPS SNPS + 1 10114 10117 2.001 2 1:10114:T:C|1:10116:A:G + 1 10114 10119 2.007 2 1:10114:T:C|1:10117:C:A + 1 10116 10119 2.011 2 1:10116:A:G|1:10117:C:A diff --git a/tests/test_data.py b/tests/test_data.py index 31b8481a..dc129866 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -2129,7 +2129,7 @@ def test_blocks2hap(self): for idx, line in enumerate(blocks_file.read().splitlines()[1:]): # initialize variables and parse line from the blocks file hap_id = f"H{idx}" - chrom, bp1, bp2, kb, nsnps, snps = line.split("\t") + chrom, bp1, bp2, kb, nsnps, snps = line.strip().split() # create a haplotype line in the .hap file hp.data[hap_id] = Haplotype(