411 REFERENCE · Wikibooks
Scientific Calculations with Julia/Analyze your genome
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Scientific Calculations with Julia Analyze your genome Investing in options Analyze your genome
The California-based company 23andMe provides a worldwide dataset containing your genotype data, obtained by analyzing a saliva sample submitted by the customer by mail.
This data may be used for research, educational, and informational purposes, but not for medical purposes.
Each row in the dataset corresponds to a single SNP containing 4 columns:
the unique identifier (rsid) of the SNP
the chromosome containing the SNP
the numerical position within the DNA of the chromosome
the genotype, consisting of two of the following letters: adenine (A), cytosine (C), guanine (G), and thymine (T).
A man has made his SNP dataset provided by 23andME public, along with that of his entire family (children and parents). It can be downloaded here: https://www.kaggle.com/zusmani/mygenome
The GWAS dataset of links to scientific publications relating to SNPs containing the allele risk allele associated with a certain disease or predisposition can be downloaded here: https://www.ebi.ac.uk/gwas/downloads. For example, in the SNP rs533123, the risk allele could be A, so it's necessary to investigate whether your genotype for that SNP contains it. Therefore, by combining the two datasets, it will be possible to determine whether one's genotype contains that particular risk allele related to a specific trait or disease. However, the GWAS dataset needs to be cleaned, so in this study, we consider the following clean dataset ('gwas_health_clean.csv') relating to the main diseases and addictions with the SNPs we are interested in:
rsid,trait,category,risk_allele,odds_ratio,pvalue
rs429358,Alzheimer's,Neurological,A,3.2,1e-50
rs7412,Alzheimer's,Neurological,T,0.6,1e-20
rs6733839,Alzheimer's,Neurological,T,1.2,1e-15
rs7903146,Type 2 Diabetes,Metabolic,T,1.4,1e-30
rs12255372, Type 2 Diabetes, Metabolic, T, 1.3, 1e-25
rs5219, Type 2 Diabetes, Metabolic, T, 1.2, 1e-12
rs1333049, Coronary Heart Disease, Cardiovascular, C, 1.2, 1e-40
rs10757278, Coronary Heart Disease, Cardiovascular, G, 1.2, 1e-38
rs17465637, Coronary Heart Disease, Cardiovascular, C, 1.15, 1e-20
rs6025, Thrombophilia, Cardiovascular, T, 5.0, 1e-200
rs1799963, Thrombophilia, Cardiovascular, A, 2.5, 1e-100
rs9939609,Obesity,Metabolic,A,1.3,1e-35
rs1421085,Obesity,Metabolic,C,1.25,1e-30
rs3751812,Obesity,Metabolic,T,1.2,1e-25
rs1801133,Homocysteine,Blood,T,1.3,1e-12
rs1801131,Homocysteine,Blood,C,1.2,1e-10
rs855791,Iron (Levels),Blood,T,1.3,1e-50
rs1799945,Ferritin,Blood,G,1.2,1e-20
rs738409,Hepatic Steatosis,Liver,G,1.5,1e-40
rs58542926, Hepatic Steatosis, Liver, T, 1.4, 1e-35
rs671, Alcohol Metabolism, Addictions, A, 2.5, 1e-60
rs1229984, Alcohol Metabolism, Addictions, A, 0.3, 1e-50
rs1799971, Opioid Dependence, Addictions, G, 1.2, 1e-10
rs4680, Dopamine (COMT), Neurotransmitters, A, 1.2, 1e-15
rs1800497, Dopamine (DRD2), Neurotransmitters, T, 1.3, 1e-20
rs6265, BDNF (Brain Plasticity), Neurotransmitters, A, 1.2, 1e-25
rs6311, Serotonin (HTR2A),Psychiatric,A,1.2,1e-12
rs7997012,Depression,Psychiatric,A,1.15,1e-10
rs1006737,Bipolar Disorder,Psychiatric,A,1.2,1e-20
rs1344706,Schizophrenia,Psychiatric,A,1.2,1e-30
rs165599,Schizophrenia,Psychiatric,G,1.15,1e-15
rs762551,Caffeine Metabolism,Addictions,A,1.3,1e-25
rs2472297,Caffeine Consumption,Addictions,T,1.2,1e-20
rs4988235,Intolerance Lactose, Metabolic, G, 0.2, 1e-100
rs1815739, Muscle Fibers, Performance, C, 1.3, 1e-30
In any case, it is possible to search the SNPs related to a certain disease or trait on the website https://www.snpedia.com/ and find them in the individual's genome.
In the clean GWAS dataset, the SNP's odds ratio is used, which measures how much the risk of a disease changes if a certain genetic variant is present. In practice, it compares those who have the SNP to those who do not.
| OR | Significance |
| ------ | ------------------ |
| OR = 1 | no effect |
| OR > 1 | increases risk |
| OR < 1 | protective effect |
Therefore, for the following odds ratios, the risk is:
1.0 → neutral
1.2 → small increase
2.0 → large increase
0.7 → protective
The odds ratio measures the PRS (Polygenic Risk Score), which is a numerical measure that summarizes the combined effect of many SNPs on the risk of a disease. In practice, each SNP has a small effect, while many SNPs have a significant combined effect. The PRS is the sum of the genetic effects obtained by adding the logarithms of the odds ratios of the various SNPs multiplied by the number of times (0, 1, 2) the allele is present in the genotype corresponding to the disease, for which the following table applies:
| PRS | Significance |
| -------- | ---------------------- |
| negative | below-average risk |
| ~0 | average risk |
| positive | Above-average risk |
Implementation in Julia
First, let's install the necessary libraries:
using Pkg
Pkg.add([ "CSV", "DataFrames", "Statistics", "StatsBase"])
Let's upload the lord's DNA:
using CSV, DataFrames, Statistics, StatsBase
function load_23andme(file)
df = CSV.read(file, DataFrame)
rename!(df, [:rsid, :chromosome, :position, :genotype])
return df
end
dna = load_23andme("genome_zeeshan_usmani.csv")
The 2 datasets are combined: the one relating to the gentleman's SNPs and the clean gwas:
gwas = CSV.read("gwas_health_clean.csv", DataFrame)
merged = innerjoin(dna, gwas, on=:rsid)
The PRS relating to all diseases and addictions considered in the person's GWAS and DNA is calculated:
# count alleles
function allele_count(genotype, allele)
genotype == "--" && return 0
return count(c -> string(c) == allele, genotype)
end
# PRS calculation
function prs(df)
sum(
log(row.odds_ratio) * allele_count(row.genotype, row.risk_allele)
for row in each row(df)
)
end
prs_scores = combine(groupby(merged, :trait)) do df
(PRS = prs(df),
SNP_count = nrow(df))
end
println(prs_scores)
22×3 DataFrame
Row │ trait PRS SNP_count
│ String31 Float64 Int64
──────────────────────────────────────────────────────────────────────────────────
1 │ Homocysteine 0.0 2
2 │ Thrombophilia 0.0 1
3 │ Coronary artery disease 0.644167 3
4 │ Lactose intolerance -1.60944 1
5 │ Schizophrenia 0.504405 2
6 │ Alcohol metabolism 0.0 2
7 │ Ferritin 0.0 1
8 │ Opioid dependence 0.182322 1
9 │ Type 2 diabetes 0.598837 3
10 │ BDNF (brain plasticity)0.0 1
11 │ Muscle fibers 0.262364 1
12 │ Dopamine (DRD2) 0.0 1
13 │ Bipolar disorder 0.364643 1
14 │ Depression 0.0 1
15 │ Serotonin (HTR2A) 0.0 1
16 │ Caffeine consumption 0.0 1
17 │ Caffeine metabolism 0.262364 1
18 │ Obesity 0.667829 3
19 │ Alzheimer's 0.0 2
20 │ Dopamine (COMT) 0.182322 1
21 │ Iron (levels) 0.0 1
22 │ Fatty liver disease 0.0 1
Calculate the PRS for all disease and addiction categories considered in the GWAS and the person's DNA:
combine(groupby(merged, :category)) do df
(PRS = prs(df),
SNP_count = nrow(df))
end
9×3 DataFrame
Row category PRS SNP_count
String31 Float64 Int64
1 Blood 0.0 4
2 Cardiovascular 0.644167 4
3 Metabolic -0.342772 7
4 Psychiatric 0.869048 5
5 Addictions 0.444686 5
6 Neurotransmitters 0.182322 3
7 Performance 0.262364 1
8 Neurological 0.0 2
9 Liver 0.0 1