Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ jobs:
run: python3 -m build

- name: Install AlphaImpute2
run: pip install dist/AlphaImpute2-0.0.3-py3-none-any.whl
run: pip install dist/alphaimpute2-0.0.2-py3-none-any.whl

# - name: Install pytest
# run: |
# pip install pytest
# pip install pytest-benchmark
- name: Install pytest
run: |
pip install pytest
pip install pytest-benchmark

# - name: Run pytest
# run: |
# pytest
- name: Run pytest
run: |
pytest
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ __pycache__/
*.py[cod]
*.DS_Store
*.egg-info/
build/
example/outputs
build
AlphaImpute2.zip
.env
tests/functional_tests/outputs
16 changes: 16 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.11"
jobs:
post_create_environment:
- pip install sphinx-rtd-theme

sphinx:
configuration: docs/source/conf.py

formats:
- pdf
- epub
Binary file removed AlphaImpute2.zip
Binary file not shown.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ AlphaImpute2

AlphaImpute2 is a phasing and imputation algorithm for massive livestock populations. The method uses a approximate version of multi-locus iterative peeling for pedigree based imputation, and a novel imputation algorithm that uses the Positional Burrows Wheeler Transform for population imputation. AlphaImpute2 has been successfully used to perform imputation in populations of hundreds of thousands of individuals. AlphaImpute2 was developed by Andrew Whalen, and is currently being supported by Andrew Whalen and Steve Thorn.

User guide
============

See [https://alphapeel.readthedocs.io/en/latest](https://alphaimpute2.readthedocs.io/en/latest/)

Installation
============

AlphaImpute2 is available on [PyPI](https://pypi.org/project/AlphaImpute2/):

pip install AlphaImpute2

Availability
============
Expand Down
12 changes: 12 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os
import shutil


def pytest_configure(config):
"""
Prepare path and report file for functional tests
"""
func_output_path = os.path.join("tests", "functional_tests", "outputs")
if os.path.exists(func_output_path):
shutil.rmtree(func_output_path)
os.mkdir(func_output_path)
131 changes: 125 additions & 6 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config

# -- Path setup --------------------------------------------------------------

Expand All @@ -21,34 +23,92 @@
copyright = "2020, Andrew Whalen"
author = "Andrew Whalen"

# The short X.Y version
version = ""
# The full version, including alpha/beta/rc tags
release = ""


# -- General configuration ---------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = []
extensions = [
"sphinx.ext.mathjax",
"sphinx.ext.ifconfig",
"sphinx.ext.viewcode",
"sphinx.ext.githubpages",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = ".rst"

# The master toctree document.
master_doc = "index"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = "python"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = None


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "alabaster"
html_theme = "sphinx_rtd_theme"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
html_static_path = []

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}


# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = "AlphaImpute2doc"


# -- Options for LaTeX output ------------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
Expand All @@ -65,3 +125,62 @@
# 'figure_align': 'htbp',
"extraclassoptions": "openany,oneside"
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(
master_doc,
"AlphaImpute2.tex",
"AlphaImpute2 Documentation",
"Andrew Whalen",
"manual",
),
]


# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, "alphaimpute2", "AlphaImpute2 Documentation", [author], 1)]


# -- Options for Texinfo output ----------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(
master_doc,
"AlphaPeel",
"AlphaPeel Documentation",
author,
"AlphaPeel",
"One line description of project.",
"Miscellaneous",
),
]


# -- Options for Epub output -------------------------------------------------

# Bibliographic Dublin Core info.
epub_title = project

# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''

# A unique identification for the text.
#
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ["search.html"]


# -- Extension configuration -------------------------------------------------
43 changes: 9 additions & 34 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,19 @@ Input Arguments
::

Input arguments:
-bfile [BFILE [BFILE ...]]
A file in plink (binary) format. Only stable on
Linux).
-genotypes [GENOTYPES [GENOTYPES ...]]
-bfile [BFILE ...] A file in plink (binary) format. Only stable on Linux).
-genotypes [GENOTYPES ...]
A file in AlphaGenes format.
-reference [REFERENCE [REFERENCE ...]]
-reference [REFERENCE ...]
A haplotype reference panel in AlphaGenes format.
-seqfile [SEQFILE [SEQFILE ...]]
-seqfile [SEQFILE ...]
A sequence data file.
-pedigree [PEDIGREE [PEDIGREE ...]]
-pedigree [PEDIGREE ...]
A pedigree file in AlphaGenes format.
-phasefile [PHASEFILE [PHASEFILE ...]]
-phasefile [PHASEFILE ...]
A phase file in AlphaGenes format.
-startsnp STARTSNP The first marker to consider. The first marker in the
file is marker "1".
-stopsnp STOPSNP The last marker to consider.
-startsnp STARTSNP The first marker to consider. The first marker in the file is marker '1'. Default: 1.
-stopsnp STOPSNP The last marker to consider. Default: all markers considered.
-seed SEED A random seed to use for debugging.

AlphaImpute2 requires a genotype file and an optional pedigree file to run the analysis.
Expand All @@ -94,29 +91,6 @@ Use the ``-startsnp`` and ``-stopsnp`` comands to run the analysis only on a sub

Binary plink files require the package ``alphaplinkpython``. This can be installed via ``pip`` but is only stable for Linux.

Output Arguments
----------------
::

Output options:
-writekey WRITEKEY Determines the order in which individuals are ordered
in the output file based on their order in the
corresponding input file. Animals not in the input
file are placed at the end of the file and sorted in
alphanumeric order. These animals can be suppressed
with the "-onlykeyed" option. Options: id, pedigree,
genotypes, sequence, segregation. Defualt: id.
-onlykeyed Flag to suppress the animals who are not present in
the file used with -writekey. Also suppresses "dummy"
animals.
-iothreads IOTHREADS Number of threads to use for io. Default: 1.


The order in which individuals are output can be changed by using the ``writekey`` option. This option changes the order in which individuals are written out to the order in which they were observed in the corresponding file. The ```-onlykeyed`` option suppresses the output of dummy individuals.

The parameter ``-iothreads`` controls the number of threads/processes used by AlphaImpute2. AlphaImpute2 uses additional threads to parse and format the input and output files. Setting this option to a value greater than 1 is only recommended for large files (i.e. >10,000 individuals).


Imputation arguments:
------------------------
::
Expand All @@ -127,6 +101,7 @@ Imputation arguments:
-binaryoutput Flag to write out the genotypes as a binary plink
output.
-phase_output Flag to write out the phase information.
-seg_output Flag to write out the segmentation information.
-pop_only Flag to run the population based imputation algorithm
only.
-ped_only Flag to run the pedigree based imputation algorithm
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ build-backend = "setuptools.build_meta"

[project]
name = "AlphaImpute2"
version = "0.0.3"
version = "0.0.2"
authors = [
{ name="Andrew Whalen", email="awhalen@roslin.ed.ac.uk" },
]
description = "An imputation software for massive livestock populations."
# readme corresponds to the long_description
# "*.md" specifies the long_description_content_type
readme = "README.md"
license = {file = "MIT_License.txt"}
license = "MIT"
classifiers = [
"Programming Language :: Python :: 3",
]
Expand All @@ -21,6 +21,7 @@ dependencies = [
"numpy>=1.19",
"numba>=0.49.0"
]
requires-python = "!= 3.12, !=3.14"

[project.scripts]
# correspond to entry_points
Expand Down
4 changes: 4 additions & 0 deletions src/alphaimpute2/Imputation/BurrowsWheelerLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ def removeMissingValues(self):
def setup_library(self, loci=None, create_reverse_library=False, create_a=False):
self.removeMissingValues()
self.haplotypes = np.array(self.haplotypes)

if self.haplotypes.size == 0:
return

if loci is not None:
bw_loci = np.array(loci, dtype=np.int64)
sub_library = self.haplotypes[:, bw_loci]
Expand Down
Loading