Package: py-graph-imputation
py-graph-imputationGraph ImputationDevelopmentRunning A Minimal Example ImputationGraph Imputationpy-graph-imputationis the successor ofGRIMMwritten in Python and based onNetworkXUsepy-graph-imputationInstallpy-graph-imputationfrom PyPipip install py-graph-imputationGet Frequency Data and Subject Data and Configuration FileFor an example, getexample-conf-data.zipUnzip the folder so it appears as:conf
|-- README.md
`-- minimal-configuration.json
data
|-- freqs
|   `-- CAU.freqs.gz
`-- subjects
    `-- donor.csvModify the configuration.json to suit your needProduce HPF csv file from Frequency Data>>> from graph_generation.generate_hpf import produce_hpf
>>> produce_hpf(conf_file='conf/minimal-configuration.json')
****************************************************************************************************
Conversion to HPF file based on following configuration:
	Population: ['CAU']
	Frequency File Directory: data/freqs
	Output File: output/hpf.csv
****************************************************************************************************
Reading Frequency File:	 data/freqs/CAU.freqs.gz
Writing hpf File:	 output/hpf.csvThis will produce the files which will be used for graph generation:output
|-- hpf.csv                         # CSV file of Haplotype, Populatio, Freq
`-- pop_counts_file.txt             # Size of each populationGenerate the Graph (nodes and edges) files>>> from grim.grim import graph_freqs

>>> graph_freqs(conf_file='conf/minimal-configuration.json')
****************************************************************************************************
Performing graph generation based on following configuration:
	Population: ['CAU']
	Freq File: output/hpf.csv
	Freq Trim Threshold: 1e-05
****************************************************************************************************This will produce the following files:output
`-- csv
    |-- edges.csv
    |-- info_node.csv
    |-- nodes.csv
    `-- top_links.csvProduce Imputation Results for Subjects>>> from grim.grim import impute
>>> impute(conf_file='conf/minimal-configuration.json')
****************************************************************************************************
Performing imputation based on:
	Population: ['CAU']
	Priority: {'alpha': 0.4999999, 'eta': 0, 'beta': 1e-07, 'gamma': 1e-07, 'delta': 0.4999999}
	UNK priority: SR
	Epsilon: 0.001
	Plan B: True
	Number of Results: 10
	Number of Population Results: 100
	Nodes File: output/csv/nodes.csv
	Top Links File: output/csv/edges.csv
	Input File: data/subjects/donor.csv
	Output UMUG Format: True
	Output UMUG Freq Filename: output/don.umug
	Output UMUG Pops Filename: output/don.umug.pops
	Output Haplotype Format: True
	Output HAP Freq Filename: output/don.pmug
	Output HAP Pops Filename: output/don.pmug.pops
	Output Miss Filename: output/don.miss
	Output Problem Filename: output/don.problem
	Factor Missing Data: 0.0001
	Loci Map: {'A': 1, 'B': 2, 'C': 3, 'DQB1': 4, 'DRB1': 5}
	Plan B Matrix: [[[1, 2, 3, 4, 5]], [[1, 2, 3], [4, 5]], [[1], [2, 3], [4, 5]], [[1, 2, 3], [4], [5]], [[1], [2, 3], [4], [5]], [[1], [2], [3], [4], [5]]]
	Pops Count File: output/pop_counts_file.txt
	Use Pops Count File: output/pop_counts_file.txt
	Number of Options Threshold: 100000
	Max Number of haplotypes in phase: 100
	Save space mode: False
****************************************************************************************************
0 Subject: D1 8400 haplotypes
0 Subject: D1 6028 haplotypes
0.09946062499999186This will produce files inoutputdirectory as:├── output
│ ├── don.miss                # Cases that failed imputation (e.g. incorrect typing etc.)
│ ├── don.pmug                # Phased imputation as PMUG GL String
│ ├── don.pmug.pops           # Population for Phased Imputation
│ ├── don.problem             # List of errors
│ ├── don.umug                # Unphased imputation as UMUG GL String
│ ├── don.umug.pops           # Population for Phased ImputationDevelopmentHow to develop on the project locally.Make sure the following pre-requites are installed.gitpython >= 3.8build tools egmakeClone the repository locallygitclonegit@github.com:nmdp-bioinformatics/py-graph-imputation.gitcdpy-graph-imputationMake a virtual environment and activate it, runmake venv>makevenvpython3-mvenvvenv--promptpy-graph-imputation-venv=====================================================================Toactivatethenewvirtualenvironment,executethefollowingfromyourshellsourcevenv/bin/activateSource the virtual environmentsourcevenv/bin/activateDevelopment workflow is driven throughMakefile. Usemaketo list show all targets.> make
 clean                remove all build, test, coverage and Python artifacts
 clean-build          remove build artifacts
 clean-pyc            remove Python file artifacts
 clean-test           remove test and coverage artifacts
 lint                 check style with flake8
 behave               run the behave tests, generate and serve report
 pytest               run tests quickly with the default Python
 test                 run all(BDD and unit) tests
 coverage             check code coverage quickly with the default Python
 dist                 builds source and wheel package
 docker-build         build a docker image for the service
 docker               build a docker image for the service
 install              install the package to the active Python's site-packages
 venv                 creates a Python3 virtualenv environment in venv
 activate             activate a virtual environment. Run `make venv` before activating.Install all the development dependencies. Will install packages from allrequirements-*.txtfiles.makeinstallPackage Module files go in thegrimdirectory.grim
|-- __init__.py
|-- grim.py
`-- imputation
    |-- __init__.py
    |-- cutils.pyx
    |-- cypher_plan_b.py
    |-- cypher_query.py
    |-- impute.py
    `-- networkx_graph.pyRun all tests withmake testor different tests withmake behaveormake pytest.Runmake lintto run the linter and black formatter.Usepython app.pyto run the Flask service app in debug mode. Service will be available athttp://localhost:8080/Usemake docker-buildto build a docker image using the currentDockerfile.make dockerwill build and run the docker image with the service.  Service will be available athttp://localhost:8080/Running a minimal configuration exampleFrom the main directory of the repo run:scripts/build-imputation-validation.shThis will prepare and load frequency data into the graph and run imputation on a sample set of subjects.The execution is driven by the configuration file:conf/minimal-configuration.jsonIt takes input from this file:data/subjects/donor.csvAnd generates anoutputdirectory with these contents:output
├── don.miss
├── don.pmug
├── don.pmug.pops
├── don.problem
├── don.umug
└── don.umug.popsThe.problemfile contains cases that failed due to serious errors (e.g., invalid HLA).The.missfile contains cases where there was no output possible given the input, frequencies and configuration options.The.pmugfile contains the Phased Multi-locus Unambiguous Genotypes.The.umugfile contains the Un-phased Multi-locus Unambiguous Genotypes.The format of both files is (csv):idgenotype - in glstring formatfrequencyrankThe.pmug.popsand.umug.popscontain the corresponding population assignments.The format of the.popsfiles is (csv):idpop1pop2frequencyrank=======
History0.0.1 (2021-08-25)First release on PyPI.