Package Files
Class PlinkPed
- java.lang.Object
-
- Files.PlinkPed
-
public class PlinkPed extends java.lang.Object
Class for dealing with data in the plink .ped format.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[][]
asArray()
Get the genotypes as an array.byte[][]
asArrayTransposed()
Get the genotypes as an array.PlinkPed
changeData(byte[][] newData)
Create a new instance similar to this one but with different genotype datajava.lang.String[]
getMeta(java.lang.String sample)
Returns the meta data associated with a samplejava.util.List<java.lang.String>
getSamples()
Returns the samples associated with this Plink objectvoid
writeToFastPhase(java.io.File f)
Writes this object to file in fastPhase formatvoid
writeToFile(java.io.File f)
Writes this object to file in Plink format
-
-
-
Constructor Detail
-
PlinkPed
public PlinkPed(java.io.File f) throws java.io.IOException, InvalidGenotypeException, RepeatedSNPException, RepeatedSampleException, WrongNumberOfSNPsException
Constructor. Loads data from a file. Defaults to assuming there are six columns of meta data before the genotype data- Parameters:
f
- File to load data from- Throws:
java.io.IOException
- If there is a problem reading from the fileInvalidGenotypeException
- If there is an invalid genotype in the fileRepeatedSNPException
- If a SNP name is repeatedRepeatedSampleException
- If a Sample name is repeatedWrongNumberOfSNPsException
- If a sample has the wrong number of SNPs
-
PlinkPed
public PlinkPed(java.io.File f, int metacolumns) throws java.io.IOException, InvalidGenotypeException, RepeatedSNPException, RepeatedSampleException, WrongNumberOfSNPsException
Constructor. Loads data from a file. Allows for a variable number of meta columns.- Parameters:
f
- File to load data frommetacolumns
- The number of meta columns before genotype data begins- Throws:
java.io.IOException
- If there is a problem reading from the fileInvalidGenotypeException
- If there is an invalid genotype in the fileRepeatedSNPException
- If a SNP name is repeatedRepeatedSampleException
- If a Sample name is repeatedWrongNumberOfSNPsException
- If a sample has the wrong number of SNPs
-
-
Method Detail
-
asArray
public byte[][] asArray()
Get the genotypes as an array. Missing data is coded as -1.- Returns:
- A 2D byte array of genotypes index by byte[sample][snp]
-
asArrayTransposed
public byte[][] asArrayTransposed()
Get the genotypes as an array. Missing data is coded as -1.- Returns:
- A 2D byte array of genotypes index by byte[snp][sample]
-
getSamples
public java.util.List<java.lang.String> getSamples()
Returns the samples associated with this Plink object- Returns:
- List of samples
-
getMeta
public java.lang.String[] getMeta(java.lang.String sample)
Returns the meta data associated with a sample- Parameters:
sample
- The sample to return meta data for- Returns:
- An array of strings representing the meta data in the order they appeared in the file.
-
writeToFile
public void writeToFile(java.io.File f) throws java.io.IOException
Writes this object to file in Plink format- Parameters:
f
- File to write to- Throws:
java.io.IOException
- Thrown if there is a problem writing the file
-
writeToFastPhase
public void writeToFastPhase(java.io.File f) throws java.io.IOException
Writes this object to file in fastPhase format- Parameters:
f
- File to write to- Throws:
java.io.IOException
- Thrown if there is a problem writing the file
-
changeData
public PlinkPed changeData(byte[][] newData)
Create a new instance similar to this one but with different genotype data- Parameters:
newData
- Byte array of the new data indexed by byte[sample][snp]- Returns:
- New PlinkNumeric instance with the new data
-
-