pyGenClean.FlagHW package

For more information about how to use this module, refer to the Hardy Weinberg Equilibrium Module.

Module contents

Submodules

pyGenClean.FlagHW.flag_hw module

class pyGenClean.FlagHW.flag_hw.Dummy[source]

Bases: object

exception pyGenClean.FlagHW.flag_hw.ProgramError(msg)[source]

Bases: exceptions.Exception

An Exception raised in case of a problem.

Parameters:msg (str) – the message to print to the user before exiting.
pyGenClean.FlagHW.flag_hw.checkArgs(args)[source]

Checks the arguments and options.

Parameters:args (argparse.Namespace) – a argparse.Namespace object containing the options of the program.
Returns:True if everything was OK.

If there is a problem with an option, an exception is raised using the ProgramError class, a message is printed to the sys.stderr and the program exists with code 1.

pyGenClean.FlagHW.flag_hw.compareBIMfiles(beforeFileName, afterFileName, outputFileName)[source]

Compare two BIM files for differences.

Parameters:
  • beforeFileName (str) – the name of the file before modification.
  • afterFileName (str) – the name of the file after modification.
  • outputFileName (str) – the name of the output file (containing the differences between the before and the after files.
Returns:

the number of differences between the two files.

The bim files contain the list of markers in a given dataset. The before file should have more markers than the after file. The after file should be a subset of the markers in the before file.

pyGenClean.FlagHW.flag_hw.computeHWE(prefix, threshold, outPrefix)[source]

Compute the Hardy Weinberg test using Plink.

Parameters:
  • prefix (str) – the prefix of all the files.
  • threshold (str) – the Hardy Weinberg threshold.
  • outPrefix (str) – the prefix of the output file.

Uses Plink to exclude markers that failed the Hardy-Weinberg test at a specified significance threshold.

pyGenClean.FlagHW.flag_hw.computeNumberOfMarkers(inputFileName)[source]

Count the number of marker (line) in a BIM file.

Parameters:inputFileName (str) – the name of the bim file.
Returns:the number of marker in the bim file.
pyGenClean.FlagHW.flag_hw.main(argString=None)[source]

The main function.

Parameters:argString (list) – the options.

These are the steps performed by this module:

  1. Prints the options of the module.
  2. Computes the number of markers in the input file (computeNumberOfMarkers()).
  3. If there are no markers, the module stops.
  4. Computes the Bonferroni therhold (\(0.05 / \textrm{nbMarkers}\)).
  5. Runs Plink to find failed markers with the Bonferroni threshold.
  6. Runs Plink to find failed markers with the default threshold.
  7. Compares the bim files for the Bonferroni threshold.
  8. Compares the bim files for the default threshold.
  9. Computes the “in between” marker list, which is the markers from the default threshold and the Bonferroni threshold.
pyGenClean.FlagHW.flag_hw.parseArgs(argString=None)[source]

Parses the command line options and arguments.

Parameters:argString (list) – the options.
Returns:A argparse.Namespace object created by the argparse module. It contains the values of the different options.
Options Type Description
--bfile string The input file prefix (binary Plink file).
--hwe float The Hardy-Weinberg equilibrium threshold.
--out string The prefix of the output files.

Note

No option check is done here (except for the one automatically done by argparse). Those need to be done elsewhere (see checkArgs()).

pyGenClean.FlagHW.flag_hw.runCommand(command)[source]

Run a command.

Parameters:command (list) – the command to run.

Tries to run a command. If it fails, raise a ProgramError. This function uses the subprocess module.

Warning

The variable command should be a list of stings (no other type).

pyGenClean.FlagHW.flag_hw.safe_main()[source]

A safe version of the main function (that catches ProgramError).