Package Files

Class PlinkNumeric


  • public class PlinkNumeric
    extends java.lang.Object
    Class for dealing with data in the plink .raw format. This data is generated using the -recodeA option of Plink
    • Constructor Summary

      Constructors 
      Constructor Description
      PlinkNumeric​(java.io.File f)
      Constructor.
      PlinkNumeric​(java.io.File f, boolean baseincluded)
      Constructor.
      PlinkNumeric​(java.io.File f, int metacolumns)
      Constructor.
      PlinkNumeric​(java.io.File f, int metacolumns, boolean baseincluded)
      Constructor.
    • 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.
      PlinkNumeric changeData​(byte[][] newData)
      Create a new instance similar to this one but with different genotype data
      PlinkNumeric changeData​(byte[][] newData, java.util.List<java.lang.String> samples, java.util.List<java.lang.String> SNPs)
      Creates a new PlinkNumeric instance with the same meta information as this instance but different data
      java.lang.String[] getMeta​(java.lang.String sample)
      Returns the meta data associated with a sample
      java.lang.String[] getMetaHead()
      Returns the meta header data - i.e.
      java.util.List<java.lang.String> getSamples()
      Returns the samples associated with this Plink object
      java.util.List<java.lang.String> getSNPs()
      Returns the SNPs associated with this Plink object
      void writeToFastPhase​(java.io.File f)
      Writes this object to file in fastPhase format
      void writeToFile​(java.io.File f)
      Writes this object to file in Plink format
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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]
      • getSNPs

        public java.util.List<java.lang.String> getSNPs()
        Returns the SNPs associated with this Plink object
        Returns:
        List of SNPs
      • 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.
      • getMetaHead

        public java.lang.String[] getMetaHead()
        Returns the meta header data - i.e. the column headings of the meta data
        Returns:
        An array of strings representing the meta header 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 PlinkNumeric 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
      • changeData

        public PlinkNumeric changeData​(byte[][] newData,
                                       java.util.List<java.lang.String> samples,
                                       java.util.List<java.lang.String> SNPs)
        Creates a new PlinkNumeric instance with the same meta information as this instance but different data
        Parameters:
        newData - Byte array of the new genotype data indexed by byte[sample][snp]
        samples - The new list of samples (in the order they appear in newData)
        SNPs - The new list of SNPs (in the order they appear in newData)
        Returns:
        New PlinkNumeric instance with the new data