phylotree

package
v0.0.0-...-6e28759 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package phylotree implements a phylogenetic tree based on SNP and Y-STR mutations.

Index

Constants

View Source
const Uncertain = -1

Uncertain is used for uncertain or unknown values.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clade

type Clade struct {
	Element
	Samples   []Sample
	Subclades []Clade
	// AgeSTR shows when this Clade has formed ybp
	// according to a calculation using Y-STR mutations.
	AgeSTR float64
	// STRCountDownstream is the average number of downstream STR mutations.
	STRCountDownstream float64
	// Sigma2 is the squared standard deviation of STRCountDownstream.
	Sigma2 float64
	// TMRCA_STR is the time to the most recent common Ancestor
	// for all downstream samples.
	TMRCA_STR float64
	// TMRCAlower and TMRCAupper are the lower and upper bounds
	// of the 95% confidence interval.
	TMRCAlower float64
	TMRCAupper float64
}

Clade models a haplogroup or subclade. A clade represents a node of the phylogenetic tree.

func NewFromFile

func NewFromFile(filename string) (*Clade, error)

NewFromFile parses a text file to create a tree. The return value Clade is the root node of the tree.

func (*Clade) AddSample

func (c *Clade) AddSample(sample Sample)

func (*Clade) AddSubclade

func (c *Clade) AddSubclade(clade Clade)

func (*Clade) CalculateAge

func (c *Clade) CalculateAge(gentime, calibration, offset float64)

CalculateAge calculates the age and TMRCA for this Clade. It fills the following variables insise Clade: TMRCA_STR, AgeSTR, STRCountDownstream. gentime is the generation time in years. calibration is a calibration factor that is multiplied to the result. offset is added to all calculated ages to account for the ages of living persons. YFull currently uses an offset of 60 years.

func (*Clade) CalculateDistances

func (c *Clade) CalculateDistances(mutationRates genetic.YstrMarkers, distance genetic.DistanceFunc)

CalculateDistances calculated the genetic distances between the modal haplotype of this clade and it's downstream members.

func (*Clade) CalculateModalHaplotypes

func (c *Clade) CalculateModalHaplotypes()

CalculateModalHaplotypes calculates the modal haplotype for this clade and all subclades.

func (*Clade) CalculateModalHaplotypesParsimony

func (c *Clade) CalculateModalHaplotypesParsimony(statistics *genetic.MarkerStatistics, processingStage int, isInfiniteAlleles bool)

CalculateModalHaplotypesParsimony calculates all modal haplotypes for this clade, using a method of maximum parsimony.

Processing stages:

 0: Return without doing anything.

 1: Calculate haplotypes that satisfy the maximum
		parsimony criterion.

 2: Calculate average haplotypes using real numbers.

 3: Mark results that do not have a nearest neighbor among
    real mutation values as Uncertain.
    This stage is only for visualization and debugging.

 4: Replace uncertain values in the top node by using the
    nearest and smallest real mutation neighbor.
    Recalculate the tree top down to find values for previously
    uncertain values.

func (*Clade) InsertPersons

func (c *Clade) InsertPersons(persons []*genetic.Person)

InsertPersons traverses the tree and adds the appropriate person to a leaf if the ID of the sample and the person's ID are identical.

func (*Clade) Inspect

func (c *Clade) Inspect(searchTerms []string) string

Inspect looks at this clade and all subclades. If any of the tree nodes' SNPs match one of the search terms, a string representation of the element is added to the result.

func (*Clade) Persons

func (c *Clade) Persons() []*genetic.Person

Persons returns a list of all persons who belong to this clade. This includes the calculated modal haplotypes.

func (*Clade) RecalculateAge

func (c *Clade) RecalculateAge(gentime, calibration, offset float64)

RecalculateAge performs a top town recalculation for the age and TMRCA values of this clade's subclades. The recalculation calculates a new calibration factor for each subclade so that the age of the subclade equals the TMRCA value of it's parent. This way a sublcade can never be older than it's parent.

func (*Clade) String

func (c *Clade) String() string

func (*Clade) Subclade

func (c *Clade) Subclade(cladeName string) *Clade

Subclade returns the subclade that contains searchTerm.

func (*Clade) Trace

func (c *Clade) Trace(STRs []string) string

Trace returns a nicely formatted tree containing information (names and values) about the Y-STR markers specified by STRs.

type Element

type Element struct {
	SNPs []string
	// STRCount is the number of unique STR mutations for this element.
	STRCount float64
	// Person may be a real person from sample data
	// or a virtual ancestor (modal haplotype).
	// This may be nil.
	Person *genetic.Person
}

Element is a node or leaf of the tree.

func (*Element) AddSNP

func (e *Element) AddSNP(name string)

func (*Element) Contains

func (e *Element) Contains(searchTerm string) bool

Contains checks if one of this element's SNPs equals searchTerm.

func (*Element) Details

func (e *Element) Details() string

Details returns a detailed string representation of this element.

func (*Element) String

func (e *Element) String() string

type Sample

type Sample struct {
	Element
	// ID od this sample, usually the kit number.
	ID string
}

Sample represents the genetic sample of an individual. This is a leaf of the phylogenetic tree.

func (*Sample) Contains

func (s *Sample) Contains(searchTerm string) bool

Contains checks if one of this sample's SNPs or the ID equals searchTerm.

func (*Sample) Details

func (s *Sample) Details() string

func (*Sample) String

func (s *Sample) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL