Package vcf

Class PlinkGenMap

java.lang.Object
vcf.PlinkGenMap
All Implemented Interfaces:
GeneticMap

public final class PlinkGenMap extends 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

    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.
    Constructs and returns a new PlinkGenMap instance from the data in the specified file.
    fromPlinkMapFile(File mapFile, 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.
    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 Details

    • fromPlinkMapFile

      public static PlinkGenMap fromPlinkMapFile(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:
      IllegalArgumentException - if any map position is infinite or NaN
      NullPointerException - if mapFile == null
      NumberFormatException - if the base position on any line of the map file is not a parsable integer
      NumberFormatException - if the genetic map position on any line of the map file is not a parsable double
      IllegalArgumentException - if a non-empty line of the specified genetic map file does not contain 4 fields
      IllegalArgumentException - if the map positions on each chromosome are not sorted in ascending order
      IllegalArgumentException - if there are duplicate base positions on a chromosome
      IllegalArgumentException - if all base positions on a chromosome have the same genetic map position
    • fromPlinkMapFile

      public static PlinkGenMap fromPlinkMapFile(File mapFile, 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:
      IllegalArgumentException - if any map position is infinite or NaN.
      NullPointerException - if mapFile == null || chrom == null
      NumberFormatException - if the base position on a line of the map file that corresponds to the specified chromosome is not a parsable integer
      NumberFormatException - if the genetic map position on a line of the map file that corresponds to the specified chromosome is not a parsable double
      IllegalArgumentException - if a non-empty line of the specified genetic map file does not contain 4 fields
      IllegalArgumentException - if the map positions on the specified chromosome are not sorted in ascending order
      IllegalArgumentException - if there are duplicate base positions on the specified chromosome
      IllegalArgumentException - if all base positions on the specified chromosome have the same genetic map position
      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:
      IllegalArgumentException - if this genetic map has no map positions for the specified chromosome
      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:
      IllegalArgumentException - if this genetic map has no map positions for the specified chromosome
      IndexOutOfBoundsException - if chrom < 0 || chrom >= ChromIds.instance().size()
      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:
      IllegalArgumentException - if this genetic map has no map positions for the specified chromosome
      IndexOutOfBoundsException - if chrom < 0 || chrom >= ChromIds.instance().size()
      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:
      IllegalArgumentException - if this genetic map has no map positions for the specified chromosome
      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 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 Object
      Returns:
      a string representation of this genetic map