<commit_before># Graphtyper
Graphtyper is a highly scalable genotyping software. It represents a reference genome and known variants of a genomic region using an acyclic mathematical graph structure (a "pangenome reference"), which high-throughput sequence reads are re-aligned to for the purpose of discovering and genotyping SNPs and small indels.

First author and software maintainer: <NAME> (<EMAIL>)

## Citation
<NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>. Graphtyper enables population-scale genotyping using pangenome graphs. *Nature Genetics*. [doi:10.1038/ng.3964](http://dx.doi.org/10.1038/ng.3964) (2017)

## Getting started
### Dependencies
Before installing Graphtyper you'll need the following:
* C++ compiler with C++11 supported (we mostly use gcc 4.8.5, gcc 5.4.0, and the latest gcc 6 and 7 releases)
* Boost>=1.57.0
* zlib>=1.2.8
* libbz2
* liblzma
* Autotools, Automake, libtool, Make, and CMake>=2.8.8 (if you want to use our build system)

All other dependencies are submodules of this repository.

### Installation
Make sure have the `CXX` environment variable set as the same compiler as `which g++` returns (because some of the submodules use the compiler directed by the `CXX` variable while other ignore it). Also set the `BOOST_ROOT` variable to the root of BOOST which should already be compiled with the same compiler. Graphtyper is linked with BOOST dynamically, but other libraries statically.

For the purpose of demonstration, we assume you want to clone Graphtyper to `~/git/graphtyper` and build it in `~/git/graphtyper/release-build`.

```sh
mkdir -p ~/git && cd ~/git
git clone --recursive https://github.com/DecodeGenetics/graphtyper.git graphtyper && cd graphtyper
mkdir -p release-build && cd release-build
cmake ..
make -j4 graphtyper # The 'j' argument specifies how many compilation threads to use, you can change this if you have more threads available. Also, the compilation will take awhile... consider getting coffee at this point.
bin/graphtyper # Will run Graphtyper for the very first time!
```
And that's all. If you are lucky enough to have administrative access, you can run `sudo make install` to install Graphtyper system-wide.

### Testing Graphtyper
To make sure you have a good release and everything compiled as expected, you can run Graphtyper's unit tests with:
```sh
make -j4 # Will compile everything, including tests
make test # Will run the unit tests
```

## Usage
Please use the [recommended pipeline](https://github.com/DecodeGenetics/graphtyper-pipelines).

## Variant filtering
Graphtyper is designed to have high specificity. That also means it often has many false positive sequence variant calls, in particular when genotyping large datasets. If you want to reduce false positives, you can post-process the VCF files using a tool called `vcffilter` which is a part of [vcflib](https://github.com/vcflib/vcflib).

In our manuscript we used the following commands to filter:
* Single sample filtering: `vcffilter -f "ABHet < 0.0 | ABHet > 0.30" -f "MQ > 30" -f "QD > 6.0" <VCF>`
* Multi sample filtering: `vcffilter -f "ABHet < 0.0 | ABHet > 0.33" -f "ABHom < 0.0 | ABHom > 0.97" -f "MaxAASR > 0.4" -f "MQ > 30" <VCF>`

## Graphtyper commands (advanced)
All Graphtyper commands are in the following format:
```sh
graphtyper <COMMAND> [OPTIONS]
```
Run `graphtyper` to get a list of commands and running `graphtyper <COMMAND> --help` to get all available options for that command.

### Graph construction
Assuming you have variants in file 'variants.vcf' (not required) and your reference genome in 'genome.fa'. then you can create a graph of the region chr22:35,000,000-35,005,000 using
```sh
samtools faidx index genome.fa # Only required if the FASTA file is not already indexed<commit_msg>[minor] README fix<commit_after># Graphtyper
Graphtyper is a highly scalable genotyping software. It represents a reference genome and known variants of a genomic region using an acyclic mathematical graph structure (a "pangenome reference"), which high-throughput sequence reads are re-aligned to for the purpose of discovering and genotyping SNPs and small indels.

First author and software maintainer: <NAME> (<EMAIL>)

## Citation
<NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>. Graphtyper enables population-scale genotyping using pangenome graphs. *Nature Genetics*. [doi:10.1038/ng.3964](http://dx.doi.org/10.1038/ng.3964) (2017)

## Getting started
### Dependencies
Before installing Graphtyper you'll need the following:
* C++ compiler with C++11 supported (we mostly use gcc 4.8.5, gcc 5.4.0, and the latest gcc 6 and 7 releases)
* Boost>=1.57.0
* zlib>=1.2.8
* libbz2
* liblzma
* Autotools, Automake, libtool, Make, and CMake>=2.8.8 (if you want to use our build system)

All other dependencies are submodules of this repository.

### Installation
Make sure have the `CXX` environment variable set as the same compiler as `which g++` returns (because some of the submodules use the compiler directed by the `CXX` variable while other ignore it). Also set the `BOOST_ROOT` variable to the root of BOOST which should already be compiled with the same compiler. Graphtyper is linked with BOOST dynamically, but other libraries statically.

For the purpose of demonstration, we assume you want to clone Graphtyper to `~/git/graphtyper` and build it in `~/git/graphtyper/release-build`.

```sh
mkdir -p ~/git && cd ~/git
git clone --recursive https://github.com/DecodeGenetics/graphtyper.git graphtyper && cd graphtyper
mkdir -p release-build && cd release-build
cmake ..
make -j4 graphtyper # The 'j' argument specifies how many compilation threads to use, you can change this if you have more threads available. Also, the compilation will take awhile... consider getting coffee at this point.
bin/graphtyper # Will run Graphtyper for the very first time!
```
And that's all. If you are lucky enough to have administrative access, you can run `sudo make install` to install Graphtyper system-wide.

### Testing Graphtyper
To make sure you have a good release and everything compiled as expected, you can run Graphtyper's unit tests with:
```sh
make -j4 # Will compile everything, including tests
make test # Will run the unit tests
```

## Usage
Please use the [recommended pipeline](https://github.com/DecodeGenetics/graphtyper-pipelines).

## Variant filtering
Graphtyper is designed to be highly sensitive. That also means it often has many false positive sequence variant calls, in particular when genotyping large datasets. If you want to reduce false positives, you can post-process the VCF files using a tool called `vcffilter` which is a part of [vcflib](https://github.com/vcflib/vcflib).

In our manuscript we used the following commands to filter:
* Single sample filtering: `vcffilter -f "ABHet < 0.0 | ABHet > 0.30" -f "MQ > 30" -f "QD > 6.0" <VCF>`
* Multi sample filtering: `vcffilter -f "ABHet < 0.0 | ABHet > 0.33" -f "ABHom < 0.0 | ABHom > 0.97" -f "MaxAASR > 0.4" -f "MQ > 30" <VCF>`

## Graphtyper commands (advanced)
All Graphtyper commands are in the following format:
```sh
graphtyper <COMMAND> [OPTIONS]
```
Run `graphtyper` to get a list of commands and running `graphtyper <COMMAND> --help` to get all available options for that command.

### Graph construction
Assuming you have variants in file 'variants.vcf' (not required) and your reference genome in 'genome.fa'. then you can create a graph of the region chr22:35,000,000-35,005,000 using
```sh
samtools faidx index genome.fa # Only required if the FASTA file is not already indexed
{'fraction_non_alphanumeric': 0.0970722186076773, 'fraction_numerical': 0.022901756668835392, 'mean_word_length': 4.59796067006555, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 65, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1605744', 'n_tokens_mistral': 2508, 'n_tokens_neox': 2266, 'n_words': 1051}