Package vcf

Class PlinkGenMap

  • All Implemented Interfaces:
    GeneticMap

    public final class PlinkGenMap
    extends java.lang.Object
    implements GeneticMap

    Class PlinkGenMap represents a genetic map derived from a PLINK map file with map positions in cM units for one or more chromosomes.

    Instances of class PlinkGenMap are immutable.

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int basePos​(int chrom, double geneticPosition)
      Returns the base position corresponding to the specified genetic map position.
      int closestIndex​(int chrom, int basePosition)
      Returns the index of the genetic map position that is closest to the specified base position.
      static PlinkGenMap fromPlinkMapFile​(java.io.File mapFile)
      Constructs and returns a new PlinkGenMap instance from the data in the specified file.
      static PlinkGenMap fromPlinkMapFile​(java.io.File mapFile, java.lang.String chrom)
      Constructs and returns a new PlinkGenMap instance from the data in the specified file.
      double genPos​(int chrom, int basePosition)
      Returns the genetic map position of the specified genome coordinate.
      double genPos​(Marker marker)
      Returns the genetic map position of the specified marker.
      int index2BasePos​(int chrom, int index)
      Returns the specified base position
      double index2GenPos​(int chrom, int index)
      Returns the specified genetic map position
      int nMapPositions​(int chrom)
      Returns the number of mapped loci in this genetic map.
      java.lang.String toString()
      Returns a string representation of this genetic map.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • fromPlinkMapFile

        public static PlinkGenMap fromPlinkMapFile​(java.io.File mapFile)
        Constructs and returns a new PlinkGenMap instance from the data in the specified file.
        Parameters:
        mapFile - a genetic map file in PLINK format with genetic map positions in cM units
        Returns:
        a new PlinkGenMap instance
        Throws:
        java.lang.IllegalArgumentException - if any map position is infinite or NaN
        java.lang.NullPointerException - if mapFile == null
        java.lang.NumberFormatException - if the base position on any line of the map file is not a parsable integer
        java.lang.NumberFormatException - if the genetic map position on any line of the map file is not a parsable double
        java.lang.IllegalArgumentException - if a non-empty line of the specified genetic map file does not contain 4 fields
        java.lang.IllegalArgumentException - if the map positions on each chromosome are not sorted in ascending order
        java.lang.IllegalArgumentException - if there are duplicate base positions on a chromosome
        java.lang.IllegalArgumentException - if all base positions on a chromosome have the same genetic map position
      • fromPlinkMapFile

        public static PlinkGenMap fromPlinkMapFile​(java.io.File mapFile,
                                                   java.lang.String chrom)
        Constructs and returns a new PlinkGenMap instance from the data in the specified file. The returned genetic map will contain only positions on the specified chromosome
        Parameters:
        mapFile - a genetic map file in PLINK format with genetic map positions in cM units
        chrom - a chromosome
        Returns:
        a new PlinkGenMap instance
        Throws:
        java.lang.IllegalArgumentException - if any map position is infinite or NaN.
        java.lang.NullPointerException - if mapFile == null || chrom == null
        java.lang.NumberFormatException - if the base position on a line of the map file that corresponds to the specified chromosome is not a parsable integer
        java.lang.NumberFormatException - if the genetic map position on a line of the map file that corresponds to the specified chromosome is not a parsable double
        java.lang.IllegalArgumentException - if a non-empty line of the specified genetic map file does not contain 4 fields
        java.lang.IllegalArgumentException - if the map positions on the specified chromosome are not sorted in ascending order
        java.lang.IllegalArgumentException - if there are duplicate base positions on the specified chromosome
        java.lang.IllegalArgumentException - if all base positions on the specified chromosome have the same genetic map position
        java.lang.IllegalArgumentException - if the specified chromosome does not have at least two distinct positions in the genetic map
      • nMapPositions

        public int nMapPositions​(int chrom)
        Returns the number of mapped loci in this genetic map.
        Parameters:
        chrom - a chromosome index
        Returns:
        the number of mapped loci in this genetic map
        Throws:
        java.lang.IllegalArgumentException - if this genetic map has no map positions for the specified chromosome
        java.lang.IndexOutOfBoundsException - if chrom < 0 || chrom >= ChromIds.instance().size()
      • index2BasePos

        public int index2BasePos​(int chrom,
                                 int index)
        Returns the specified base position
        Parameters:
        chrom - a chromosome index
        index - a map position index
        Returns:
        the specified base position
        Throws:
        java.lang.IllegalArgumentException - if this genetic map has no map positions for the specified chromosome
        java.lang.IndexOutOfBoundsException - if chrom < 0 || chrom >= ChromIds.instance().size()
        java.lang.IndexOutOfBoundsException - if index < 0 || index >= this.nMapPositions(chrom)
      • index2GenPos

        public double index2GenPos​(int chrom,
                                   int index)
        Returns the specified genetic map position
        Parameters:
        chrom - a chromosome index
        index - a map position index
        Returns:
        the specified genetic map position
        Throws:
        java.lang.IllegalArgumentException - if this genetic map has no map positions for the specified chromosome
        java.lang.IndexOutOfBoundsException - if chrom < 0 || chrom >= ChromIds.instance().size()
        java.lang.IndexOutOfBoundsException - if index < 0 || index >= this.nMapPositions(chrom)
      • closestIndex

        public int closestIndex​(int chrom,
                                int basePosition)
        Returns the index of the genetic map position that is closest to the specified base position.
        Parameters:
        chrom - a chromosome index
        basePosition - a base position
        Returns:
        the genetic map position index that is closes to the specified base position.
        Throws:
        java.lang.IllegalArgumentException - if this genetic map has no map positions for the specified chromosome
        java.lang.IndexOutOfBoundsException - if chrom < 0 || chrom >= ChromIds.instance().size()
      • genPos

        public double genPos​(Marker marker)
        Description copied from interface: GeneticMap
        Returns the genetic map position of the specified marker. The genetic map position is estimated using linear interpolation.
        Specified by:
        genPos in interface GeneticMap
        Parameters:
        marker - a genetic marker
        Returns:
        the genetic map position of the specified marker
      • genPos

        public double genPos​(int chrom,
                             int basePosition)
        Description copied from interface: GeneticMap
        Returns the genetic map position of the specified genome coordinate. The genetic map position is estimated using linear interpolation.
        Specified by:
        genPos in interface GeneticMap
        Parameters:
        chrom - the chromosome index
        basePosition - the base coordinate on the chromosome
        Returns:
        the genetic map position of the specified genome coordinate
      • basePos

        public int basePos​(int chrom,
                           double geneticPosition)
        Description copied from interface: GeneticMap
        Returns the base position corresponding to the specified genetic map position. If the genetic position is not a map position then the base position is estimated from the nearest genetic map positions using linear interpolation.
        Specified by:
        basePos in interface GeneticMap
        Parameters:
        chrom - the chromosome index
        geneticPosition - the genetic position on the chromosome
        Returns:
        the base position corresponding to the specified genetic map position
      • toString

        public java.lang.String toString()
        Description copied from interface: GeneticMap
        Returns a string representation of this genetic map. The exact details of the representation are unspecified and subject to change.
        Specified by:
        toString in interface GeneticMap
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation of this genetic map