Package vcf
Class PlinkGenMap
java.lang.Object
vcf.PlinkGenMap
- All Implemented Interfaces:
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 TypeMethodDescriptionint
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
(File mapFile) Constructs and returns a newPlinkGenMap
instance from the data in the specified file.static PlinkGenMap
fromPlinkMapFile
(File mapFile, String chrom) Constructs and returns a newPlinkGenMap
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
Returns the genetic map position of the specified marker.int
index2BasePos
(int chrom, int index) Returns the specified base positiondouble
index2GenPos
(int chrom, int index) Returns the specified genetic map positionint
nMapPositions
(int chrom) Returns the number of mapped loci in this genetic map.toString()
Returns a string representation of this genetic map.
-
Method Details
-
fromPlinkMapFile
Constructs and returns a newPlinkGenMap
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 orNaN
NullPointerException
- ifmapFile == null
NumberFormatException
- if the base position on any line of the map file is not a parsable integerNumberFormatException
- if the genetic map position on any line of the map file is not a parsable doubleIllegalArgumentException
- if a non-empty line of the specified genetic map file does not contain 4 fieldsIllegalArgumentException
- if the map positions on each chromosome are not sorted in ascending orderIllegalArgumentException
- if there are duplicate base positions on a chromosomeIllegalArgumentException
- if all base positions on a chromosome have the same genetic map position
-
fromPlinkMapFile
Constructs and returns a newPlinkGenMap
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 unitschrom
- a chromosome- Returns:
- a new
PlinkGenMap
instance - Throws:
IllegalArgumentException
- if any map position is infinite orNaN
.NullPointerException
- ifmapFile == 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 integerNumberFormatException
- if the genetic map position on a line of the map file that corresponds to the specified chromosome is not a parsable doubleIllegalArgumentException
- if a non-empty line of the specified genetic map file does not contain 4 fieldsIllegalArgumentException
- if the map positions on the specified chromosome are not sorted in ascending orderIllegalArgumentException
- if there are duplicate base positions on the specified chromosomeIllegalArgumentException
- if all base positions on the specified chromosome have the same genetic map positionIllegalArgumentException
- 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 chromosomeIndexOutOfBoundsException
- ifchrom < 0 || chrom >= ChromIds.instance().size()
-
index2BasePos
public int index2BasePos(int chrom, int index) Returns the specified base position- Parameters:
chrom
- a chromosome indexindex
- a map position index- Returns:
- the specified base position
- Throws:
IllegalArgumentException
- if this genetic map has no map positions for the specified chromosomeIndexOutOfBoundsException
- ifchrom < 0 || chrom >= ChromIds.instance().size()
IndexOutOfBoundsException
- ifindex < 0 || index >= this.nMapPositions(chrom)
-
index2GenPos
public double index2GenPos(int chrom, int index) Returns the specified genetic map position- Parameters:
chrom
- a chromosome indexindex
- a map position index- Returns:
- the specified genetic map position
- Throws:
IllegalArgumentException
- if this genetic map has no map positions for the specified chromosomeIndexOutOfBoundsException
- ifchrom < 0 || chrom >= ChromIds.instance().size()
IndexOutOfBoundsException
- ifindex < 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 indexbasePosition
- 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 chromosomeIndexOutOfBoundsException
- ifchrom < 0 || chrom >= ChromIds.instance().size()
-
genPos
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 interfaceGeneticMap
- 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 interfaceGeneticMap
- Parameters:
chrom
- the chromosome indexbasePosition
- 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 interfaceGeneticMap
- Parameters:
chrom
- the chromosome indexgeneticPosition
- the genetic position on the chromosome- Returns:
- the base position corresponding to the specified genetic map position
-
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 interfaceGeneticMap
- Overrides:
toString
in classObject
- Returns:
- a string representation of this genetic map
-