-
Notifications
You must be signed in to change notification settings - Fork 0
Code overview
This page goes through the broad steps of the pipeline and where the code can be found. The general workflow of the pipeline is to run either stoat graph or stoat vcf to produce an intermediate genotype file, then run stoat stats to do the statistics on it.
-
SnarlDataCollection: used to store per-snarl information. Both
stoat graphandstoat vcfuseSnarlDataCollection.fill_in_snarl_info()for going through snarls, storing allele and genotype information, and writing the snarls and genotypes to an intermediate file. - VCFParser: parse a VCF and optionally resolve conflicting calls.
- EdgeBySampleMatrix: used to keep track of which edges in the graph are traversed by which samples, according to the VCF. Can be queried to find which samples are on a given path.
- FeatureBySampleTable: generic class for storing per-sample information
- PathTraversal: represents a path through the graph/netgraph. Contains the walk and the minimum and maximum lengths of the path (the length could be different depending on paths through nested snarls).
- SnarlAnalyzer: put all the data together and test it
- Classes for doing statistics
- Writer: Write the output
stoat graph takes as input a graph with embedded haplotypes and for each snarl, partitions them based on the path they take through the snarl's netgraph. This is done by calling partition_embedded_paths_in_snarl() for each snarl in the SnarlDataCollection. It then writes an intermediate snarl file containing the genotype for each embedded path.
stoat vcf runs through the snarls twice: once to find all possible paths through every snarl (the potential alleles), and a second time to match the samples in the VCF to the alleles found in the snarls. An intermediate snarl file can be written after each of these steps. The general algorithm is:
- Fill in the
SnarlDataCollectionwith all possible walks through each snarl (the alleles for the snarl). This is done using theget_all_walks_through_snarl()function. The intermediate snarls file can be written here containing the walks but not genotypes. - Find the genotypes of samples in the VCF by calling
genotype_snarls_by_chr_from_vcf(). Per chromosome (or chunk of VCF, as long as chunks are non-overlapping along the top-level chain), this does:- Parse the VCF with a
VCFParser, optionally resolving contradictions in the calls. - Build an
EdgeBySampleMatrixfor the chromosome. For each sample, the matrix stores a boolean for whether or not the sample traverses each edge. The edges found from the VCF are added to theEdgeBySampleMatrixby callingload_vcf_chunk(). - Assign an allele to each sample by calling
add_alleles_by_sample()with a function that matches the alleles found in step 1 with the sample's path stored in the edge matrix.
- Parse the VCF with a
- Write the SnarlDataCollection to an intermediate file containing genotypes.
This is where all the statistics happens. It takes as input a phenotype file and the intermediate genotype file from either stoat graph or stoat vcf.
- The genotypes file is loaded as a
SnarlDataCollection - The phenotype file is loaded as the appropriate type of
FeatureBySampleTable - A
SnarlAnalyzerputs all the data together with some additional stats functions and does statistics. - The final output is written using a
Writer