2024-06-02 10:43:39 +02:00
|
|
|
|
|
|
|
// geneticAnalysis implements the geneticAnalysis objects
|
|
|
|
// There are 2 geneticAnalysis types: Person and Couple
|
|
|
|
|
|
|
|
package geneticAnalysis
|
|
|
|
|
|
|
|
import "seekia/internal/genetics/locusValue"
|
|
|
|
|
|
|
|
|
|
|
|
type PersonAnalysis struct{
|
|
|
|
|
|
|
|
AnalysisVersion int
|
|
|
|
|
|
|
|
// This is a list of each raw genome identifier (not including combined genomes)
|
|
|
|
AllRawGenomeIdentifiersList [][16]byte
|
|
|
|
|
|
|
|
// This is true if there is more than 1 raw genome
|
|
|
|
CombinedGenomesExist bool
|
|
|
|
|
|
|
|
// These are the identifiers for the combined genomes
|
|
|
|
// These only exist if CombinedGenomesExist == true
|
|
|
|
OnlyIncludeSharedGenomeIdentifier [16]byte
|
|
|
|
OnlyExcludeConflictsGenomeIdentifier [16]byte
|
|
|
|
|
|
|
|
// Map Structure: Disease Name -> PersonMonogenicDiseaseInfo
|
|
|
|
MonogenicDiseasesMap map[string]PersonMonogenicDiseaseInfo
|
|
|
|
|
|
|
|
// Map Structure: Disease Name -> PersonPolygenicDiseaseInfo
|
|
|
|
PolygenicDiseasesMap map[string]PersonPolygenicDiseaseInfo
|
|
|
|
|
|
|
|
// Map Structure: Trait Name -> Trait Info Object
|
|
|
|
TraitsMap map[string]PersonTraitInfo
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type PersonMonogenicDiseaseInfo struct{
|
|
|
|
|
|
|
|
// This map gives information about each genome's monogenic disease risk
|
|
|
|
// If no map entries exist, then no disease info is known
|
|
|
|
// Map Structure: Genome Identifier -> PersonGenomeMonogenicDiseaseInfo
|
|
|
|
MonogenicDiseaseInfoMap map[[16]byte]PersonGenomeMonogenicDiseaseInfo
|
|
|
|
|
|
|
|
// This is true if there are multiple genomes and the results for each genome differ
|
|
|
|
ConflictExists bool
|
|
|
|
}
|
|
|
|
|
|
|
|
type PersonGenomeMonogenicDiseaseInfo struct{
|
|
|
|
|
|
|
|
// This describes if the person has the disease
|
|
|
|
PersonHasDisease bool
|
|
|
|
|
|
|
|
// This describes the number of variants that were tested for this disease
|
|
|
|
NumberOfVariantsTested int
|
|
|
|
|
|
|
|
// This describes the number of loci that were tested for this disease
|
|
|
|
// 1 locus can have multiple potential variants
|
|
|
|
NumberOfLociTested int
|
|
|
|
|
|
|
|
// This describes the number of loci which are phased
|
|
|
|
// This number will always be <= NumberOfLociTested
|
|
|
|
NumberOfPhasedLoci int
|
|
|
|
|
|
|
|
// This describes the probability that the person will pass a disease variant
|
|
|
|
// It is a value that represents a percentage between 0-100
|
|
|
|
ProbabilityOfPassingADiseaseVariant int
|
|
|
|
|
|
|
|
// This map contains info about all tested monogenic disease variants for the genome
|
|
|
|
// If the map does not contain an item for a disease variant, then the genome does not contain information for that variant
|
|
|
|
// Map Structure: Variant Identifier -> PersonGenomeMonogenicDiseaseVariantInfo
|
|
|
|
VariantsInfoMap map[[3]byte]PersonGenomeMonogenicDiseaseVariantInfo
|
|
|
|
}
|
|
|
|
|
|
|
|
type PersonGenomeMonogenicDiseaseVariantInfo struct{
|
|
|
|
|
|
|
|
// These bools describe if each base has the variant at the variant's locus
|
|
|
|
Base1HasVariant bool
|
|
|
|
Base2HasVariant bool
|
|
|
|
|
|
|
|
// This bool describes if the bases are phased or not
|
|
|
|
// If they are not phased, then Base1/2 are the same, the number carries no meaning
|
|
|
|
// If they are phased, then Base1 is inherited from the father? and Base2 was inherited from the mother?
|
|
|
|
LocusIsPhased bool
|
|
|
|
}
|
|
|
|
|
|
|
|
type PersonPolygenicDiseaseInfo struct{
|
|
|
|
|
|
|
|
// If no map entries exist, then no disease info is known
|
|
|
|
// Map Structure: Genome Identifier -> PersonGenomePolygenicDiseaseInfo
|
|
|
|
PolygenicDiseaseInfoMap map[[16]byte]PersonGenomePolygenicDiseaseInfo
|
|
|
|
|
|
|
|
// This is true if there are multiple genomes and the results from each genome differ
|
|
|
|
ConflictExists bool
|
|
|
|
}
|
|
|
|
|
|
|
|
type PersonGenomePolygenicDiseaseInfo struct{
|
|
|
|
|
|
|
|
// This describes the number of loci tested for this disease
|
|
|
|
// This should be len(LociInfoList)
|
|
|
|
NumberOfLociTested int
|
|
|
|
|
2024-06-07 02:04:13 +02:00
|
|
|
// This map contains the locus values for the genome for this trait
|
|
|
|
// If an locus's entry doesn't exist, its value is unknown
|
|
|
|
// Map Structure: Locus rsID -> Locus Value
|
|
|
|
LocusValuesMap map[int64]locusValue.LocusValue
|
|
|
|
|
2024-06-02 10:43:39 +02:00
|
|
|
// This is total risk score for this disease for the person's genome
|
|
|
|
// This is a number between 1-10
|
|
|
|
RiskScore int
|
|
|
|
|
|
|
|
// This map contains info about all tested polygenic disease loci for this genome
|
|
|
|
// If a locus does not exist in the map, its values are unknown
|
|
|
|
// Map Structure: Locus Identifier -> PersonGenomePolygenicDiseaseLocusInfo
|
|
|
|
LociInfoMap map[[3]byte]PersonGenomePolygenicDiseaseLocusInfo
|
|
|
|
}
|
|
|
|
|
|
|
|
type PersonGenomePolygenicDiseaseLocusInfo struct{
|
|
|
|
|
|
|
|
// This is the risk weight that this person's genome has for this variant
|
|
|
|
// A higher risk weight means more risk of getting the disease
|
|
|
|
RiskWeight int
|
|
|
|
|
|
|
|
// This is valse if the odds ratio is not known
|
|
|
|
OddsRatioIsKnown bool
|
|
|
|
|
|
|
|
// This is the person's genome odds ratio value for this variant's locus
|
|
|
|
// A ratio >1 means their risk is increased, a ratio <1 means their risk is decreased
|
|
|
|
OddsRatio float64
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type PersonTraitInfo struct{
|
|
|
|
|
|
|
|
// This map contains the person's trait info for each genome
|
|
|
|
// If no map entries exist, then no trait info is known
|
|
|
|
// Map Structure: Genome Identifier -> PersonGenomeTraitInfo
|
|
|
|
TraitInfoMap map[[16]byte]PersonGenomeTraitInfo
|
|
|
|
|
|
|
|
// This is true if there are multiple genomes and the results from each genome differ
|
|
|
|
ConflictExists bool
|
|
|
|
}
|
|
|
|
|
|
|
|
type PersonGenomeTraitInfo struct{
|
|
|
|
|
2024-06-07 02:04:13 +02:00
|
|
|
// This should be len(GenomePassesRulesMap)
|
2024-06-02 10:43:39 +02:00
|
|
|
NumberOfRulesTested int
|
|
|
|
|
2024-06-07 02:04:13 +02:00
|
|
|
// This map contains the locus values for the genome for this trait
|
2024-06-02 10:43:39 +02:00
|
|
|
// If an locus's entry doesn't exist, its value is unknown
|
|
|
|
// Map Structure: Locus rsID -> Locus Value
|
|
|
|
LocusValuesMap map[int64]locusValue.LocusValue
|
|
|
|
|
|
|
|
// This map contains the outcome scores for the genome
|
|
|
|
// Map Structure: Outcome Name -> Score
|
|
|
|
// Example: "Intolerant" -> 5
|
|
|
|
OutcomeScoresMap map[string]int
|
|
|
|
|
|
|
|
// Map Structure: Rule Identifier -> Genome Passes rule (true if the genome passes the rule)
|
|
|
|
GenomePassesRulesMap map[[3]byte]bool
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type CoupleAnalysis struct{
|
|
|
|
|
|
|
|
AnalysisVersion int
|
|
|
|
|
|
|
|
Pair1Person1GenomeIdentifier [16]byte
|
|
|
|
Pair1Person2GenomeIdentifier [16]byte
|
|
|
|
|
|
|
|
// This is only true if at least 1 person has more than 1 genome
|
|
|
|
SecondPairExists bool
|
|
|
|
|
|
|
|
// These are empty unless SecondPairExists == true
|
|
|
|
Pair2Person1GenomeIdentifier [16]byte
|
|
|
|
Pair2Person2GenomeIdentifier [16]byte
|
|
|
|
|
|
|
|
Person1HasMultipleGenomes bool
|
|
|
|
Person2HasMultipleGenomes bool
|
|
|
|
|
|
|
|
// These are empty unless Person1HasMultipleGenomes == true
|
|
|
|
Person1OnlyExcludeConflictsGenomeIdentifier [16]byte
|
|
|
|
Person1OnlyIncludeSharedGenomeIdentifier [16]byte
|
|
|
|
|
|
|
|
// These are empty unless Person2HasMultipleGenomes == true
|
|
|
|
Person2OnlyExcludeConflictsGenomeIdentifier [16]byte
|
|
|
|
Person2OnlyIncludeSharedGenomeIdentifier [16]byte
|
|
|
|
|
|
|
|
// Map Structure: Disease Name -> OffspringMonogenicDiseaseInfo
|
|
|
|
MonogenicDiseasesMap map[string]OffspringMonogenicDiseaseInfo
|
|
|
|
|
|
|
|
// Map Structure: Disease Name -> OffspringPolygenicDiseaseInfo
|
|
|
|
PolygenicDiseasesMap map[string]OffspringPolygenicDiseaseInfo
|
|
|
|
|
|
|
|
// Map Structure: Trait Name -> Trait Info Object
|
|
|
|
TraitsMap map[string]OffspringTraitInfo
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type OffspringMonogenicDiseaseInfo struct{
|
|
|
|
|
|
|
|
// This map stores the number of variants tested in each person's genome
|
|
|
|
// Map Structure: Genome Identifier -> Number of variants tested
|
|
|
|
NumberOfVariantsTestedMap map[[16]byte]int
|
|
|
|
|
|
|
|
// This map stores the offspring disease probabilities for each genome pair.
|
|
|
|
// A genome pair is a concatenation of two genome identifiers
|
|
|
|
// If a map entry doesn't exist, the probabilities are unknown for that genome pair
|
|
|
|
// Map Structure: Genome Pair Identifier -> OffspringGenomePairMonogenicDiseaseInfo
|
|
|
|
MonogenicDiseaseInfoMap map[[32]byte]OffspringGenomePairMonogenicDiseaseInfo
|
|
|
|
|
|
|
|
// This is true if there is more than 1 genome pair and the results from each genome pair differ
|
|
|
|
ConflictExists bool
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type OffspringGenomePairMonogenicDiseaseInfo struct{
|
|
|
|
|
|
|
|
// At least 1 variant's information is needed from either person to include the diseaseInfo object in the MonogenicDiseaseInfoMap
|
|
|
|
|
|
|
|
ProbabilityOffspringHasDiseaseIsKnown bool
|
|
|
|
|
|
|
|
// This is the probability that the offspring will have the disease
|
|
|
|
// Is a number between 0-100%
|
|
|
|
ProbabilityOffspringHasDisease int
|
|
|
|
|
|
|
|
ProbabilityOffspringHasVariantIsKnown bool
|
|
|
|
|
|
|
|
// This is the probability that the offspring will have a variant
|
|
|
|
// Is a number between 0-100%
|
|
|
|
ProbabilityOffspringHasVariant int
|
|
|
|
|
|
|
|
// Map Structure: Variant Identifier -> OffspringMonogenicDiseaseVariantInfo
|
|
|
|
VariantsInfoMap map[[3]byte]OffspringMonogenicDiseaseVariantInfo
|
|
|
|
}
|
|
|
|
|
|
|
|
type OffspringMonogenicDiseaseVariantInfo struct{
|
|
|
|
|
|
|
|
// These are all numbers between 0-100%
|
|
|
|
ProbabilityOf0MutationsLowerBound int
|
|
|
|
ProbabilityOf0MutationsUpperBound int
|
|
|
|
|
|
|
|
ProbabilityOf1MutationLowerBound int
|
|
|
|
ProbabilityOf1MutationUpperBound int
|
|
|
|
|
|
|
|
ProbabilityOf2MutationsLowerBound int
|
|
|
|
ProbabilityOf2MutationsUpperBound int
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type OffspringPolygenicDiseaseInfo struct{
|
|
|
|
|
|
|
|
// This map stores the polygenic disease info for each genome pair
|
|
|
|
// Map Structure: Genome Pair Identifier -> OffspringGenomePairPolygenicDiseaseInfo
|
|
|
|
PolygenicDiseaseInfoMap map[[32]byte]OffspringGenomePairPolygenicDiseaseInfo
|
|
|
|
|
|
|
|
// This is true if there is more than 1 genome pair and the results from each genome pair differ
|
|
|
|
ConflictExists bool
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type OffspringGenomePairPolygenicDiseaseInfo struct{
|
|
|
|
|
|
|
|
// This should be len(DiseaseLociList)
|
|
|
|
NumberOfLociTested int
|
|
|
|
|
2024-06-07 02:04:13 +02:00
|
|
|
// A number between 1-10 representing the offspring's average risk score
|
2024-06-02 10:43:39 +02:00
|
|
|
// 1 == lowest risk, 10 == highest risk
|
2024-06-07 02:04:13 +02:00
|
|
|
OffspringAverageRiskScore int
|
2024-06-02 10:43:39 +02:00
|
|
|
|
|
|
|
// A map of the offspring's locus information
|
|
|
|
// Map Structure: Locus Identifier -> OffspringPolygenicDiseaseLocusInfo
|
|
|
|
LociInfoMap map[[3]byte]OffspringPolygenicDiseaseLocusInfo
|
2024-06-07 02:04:13 +02:00
|
|
|
|
|
|
|
// This is a list of prospective offspring risk scores
|
|
|
|
// This is useful for plotting on a graph to understand the standard deviation of risk
|
|
|
|
SampleOffspringRiskScoresList []int
|
2024-06-02 10:43:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type OffspringPolygenicDiseaseLocusInfo struct{
|
|
|
|
|
2024-06-07 02:04:13 +02:00
|
|
|
// This is the offspring's average risk weight for this locus value
|
2024-06-02 10:43:39 +02:00
|
|
|
// A higher weight means a higher risk of the disease
|
2024-06-07 02:04:13 +02:00
|
|
|
OffspringAverageRiskWeight int
|
2024-06-02 10:43:39 +02:00
|
|
|
|
2024-06-07 02:04:13 +02:00
|
|
|
// This is true if any of the 100 prospective offspring had a known odds ratio for this locus
|
2024-06-02 10:43:39 +02:00
|
|
|
OffspringOddsRatioIsKnown bool
|
|
|
|
|
|
|
|
// This value represent's the offspring's average odds ratio for the disease locus
|
|
|
|
// A value <1 denotes a lesser risk, a value >1 denotes an increased risk
|
2024-06-07 02:04:13 +02:00
|
|
|
OffspringAverageOddsRatio float64
|
2024-06-02 10:43:39 +02:00
|
|
|
|
2024-06-07 02:04:13 +02:00
|
|
|
// This is the average of the sum of weights for the loci which have no odds ratios for each prospective offspring
|
2024-06-02 10:43:39 +02:00
|
|
|
// We do this to understand what effect those loci are having on the odds ratio
|
|
|
|
// If the sum is <0, we say the ratio is probably lower
|
|
|
|
// If the sum is >0, we say the ratio is probably higher
|
2024-06-07 02:04:13 +02:00
|
|
|
OffspringAverageUnknownOddsRatiosWeightSum int
|
2024-06-02 10:43:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type OffspringTraitInfo struct{
|
|
|
|
|
|
|
|
// This map stores the trait info for each genome pair
|
|
|
|
// Map Structure: Genome Pair Identifier -> OffspringGenomePairTraitInfo
|
|
|
|
TraitInfoMap map[[32]byte]OffspringGenomePairTraitInfo
|
|
|
|
|
|
|
|
ConflictExists bool
|
|
|
|
}
|
|
|
|
|
|
|
|
type OffspringGenomePairTraitInfo struct{
|
|
|
|
|
|
|
|
// This should be len(TraitRulesList)
|
|
|
|
NumberOfRulesTested int
|
|
|
|
|
|
|
|
// Map Structure: Outcome Name -> Outcome Score
|
|
|
|
// Example: "Intolerant" -> 2.5
|
|
|
|
OffspringAverageOutcomeScoresMap map[string]float64
|
|
|
|
|
|
|
|
// Map Structure: Rule Identifier -> Offspring Probability Of Passing Rule
|
|
|
|
// The value stores the probability that the offspring will pass the rule
|
|
|
|
// This is a number between 0-100%
|
|
|
|
ProbabilityOfPassingRulesMap map[[3]byte]int
|
|
|
|
}
|
|
|
|
|