Package vcf
Interface GeneticMap
-
- All Known Implementing Classes:
PlinkGenMap
,PositionMap
public interface GeneticMap
Interface
GeneticMap
represents a genetic map for one or more chromosomes.Instances of class
GeneticMap
are immutable.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description int
basePos(int chrom, double geneticPosition)
Returns the base position corresponding to the specified genetic map position.static GeneticMap
geneticMap(java.io.File file, ChromInterval chromInt)
Constructs and returns a genetic map from the specified data.double
genPos(int chrom, int basePosition)
Returns the genetic map position of the specified genome coordinate.static double[]
genPos(GeneticMap genMap, double minGenDist, Markers markers)
Returns the an array of lengthmarkers.nMarkers()
whose whosej
-th element is the genetic map position of thej
-th marker.static double[]
genPos(GeneticMap genMap, Markers markers)
Returns the an array of lengthmarkers.nMarkers()
whose whosej
-th element is the genetic map position of thej
-th marker.double
genPos(Marker marker)
Returns the genetic map position of the specified marker.java.lang.String
toString()
Returns a string representation of this genetic map.
-
-
-
Method Detail
-
basePos
int basePos(int chrom, double geneticPosition)
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.- Parameters:
chrom
- the chromosome indexgeneticPosition
- the genetic position on the chromosome- Returns:
- the base position corresponding to the specified genetic map position
- Throws:
java.lang.IllegalArgumentException
- if the calculated base position exceedsInteger.MAX_VALUE
java.lang.IllegalArgumentException
- if this genetic map has no map positions for the specified chromosomejava.lang.IndexOutOfBoundsException
- ifchrom < 0 || chrom >= ChromIds.instance().size()
-
genPos
double genPos(Marker marker)
Returns the genetic map position of the specified marker. The genetic map position is estimated using linear interpolation.- Parameters:
marker
- a genetic marker- Returns:
- the genetic map position of the specified marker
- Throws:
java.lang.IllegalArgumentException
- if this genetic map has no map positions for the specified chromosomejava.lang.NullPointerException
- ifmarker == null
-
genPos
double genPos(int chrom, int basePosition)
Returns the genetic map position of the specified genome coordinate. The genetic map position is estimated using linear interpolation.- Parameters:
chrom
- the chromosome indexbasePosition
- the base coordinate on the chromosome- Returns:
- the genetic map position of the specified genome coordinate
- Throws:
java.lang.IllegalArgumentException
- if this genetic map has no map positions for the specified chromosomejava.lang.IndexOutOfBoundsException
- ifchrom < 0 || chrom >= ChromIds.instance().size()
-
toString
java.lang.String toString()
Returns a string representation of this genetic map. The exact details of the representation are unspecified and subject to change.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string representation of this genetic map
-
geneticMap
static GeneticMap geneticMap(java.io.File file, ChromInterval chromInt)
Constructs and returns a genetic map from the specified data. If the specified map file isnull
, the returned genetic map will convert genome coordinates to genetic units by dividing by 1,000,000. If(chromInt != null)
the genetic map will be restricted to chromosomechromInt.chrom()
.- Parameters:
file
- a PLINK-format genetic map file with cM unitschromInt
- a chromosome interval- Returns:
- a genetic map from the specified data.
- Throws:
java.lang.IllegalArgumentException
- if any map position is infinite orNaN
java.lang.NumberFormatException
- if the base position on any line of the map file is not a parsable integerjava.lang.NumberFormatException
- if the genetic map position on any line of the map file is not a parsable doublejava.lang.IllegalArgumentException
- if a non-empty line of the specified genetic map file does not contain 4 fieldsjava.lang.IllegalArgumentException
- if the map positions on each chromosome are not sorted in ascending orderjava.lang.IllegalArgumentException
- if there are duplicate base positions on a chromosomejava.lang.IllegalArgumentException
- if all base positions on a chromosome have the same genetic map position
-
genPos
static double[] genPos(GeneticMap genMap, Markers markers)
Returns the an array of lengthmarkers.nMarkers()
whose whosej
-th element is the genetic map position of thej
-th marker.- Parameters:
genMap
- the genetic mapmarkers
- the list of markers- Returns:
- an array of genetic map positions
- Throws:
java.lang.IllegalArgumentException
- ifmarkers.marker(0).chromIndex() != markers.marker(markers.nMarkers() - 1).chromIndex()
java.lang.IllegalArgumentException
- if the specified genetic map has no map positions for the specified chromosomejava.lang.NullPointerException
- ifgenMap == null || markers == null
-
genPos
static double[] genPos(GeneticMap genMap, double minGenDist, Markers markers)
Returns the an array of lengthmarkers.nMarkers()
whose whosej
-th element is the genetic map position of thej
-th marker.- Parameters:
genMap
- the genetic map in cM unitsminGenDist
- the required minimum cM distance between successive markersmarkers
- the list of markers- Returns:
- an array of genetic map positions
- Throws:
java.lang.IllegalArgumentException
- ifmarkers.marker(0).chromIndex() != markers.marker(markers.nMarkers() - 1).chromIndex()
java.lang.IllegalArgumentException
- if the specified genetic map has no map positions for the specified chromosomejava.lang.IllegalArgumentException
- ifDouble.isFinite(minDist) == false
java.lang.NullPointerException
- ifgenMap == null || markers == null
-
-