1113 lines
42 KiB
R
Executable File
1113 lines
42 KiB
R
Executable File
|
|
|
|
|
|
|
|
|
|
source('r/library.r')
|
|
source('r/functions.r')
|
|
source('r/data.r')
|
|
source('r/graph.r')
|
|
|
|
|
|
|
|
|
|
|
|
##########
|
|
##########
|
|
########## 100 Average Salaries
|
|
##########
|
|
##########
|
|
|
|
#--------[ Smart Asset - Meta Data ]--------#
|
|
metaData <- c(
|
|
source='https://smartasset.com/retirement/the-average-salary-by-age',
|
|
file='data/SmartAsset-Salary.csv',
|
|
set='100-Salary',
|
|
id='100-SmartAsset-Salary-Raw',
|
|
title='Smart Asset - US Average Salary (Raw Data)',
|
|
xtitle='Age (years)',
|
|
ytitle='Average Salary',
|
|
ltitle='Data',
|
|
aspect=c(16,9),
|
|
lpos='br'
|
|
)
|
|
|
|
#--------[ Smart Asset - Load Data ]--------#
|
|
data100 <- loadData(metaData)
|
|
tmpData <- data100
|
|
|
|
#--------[ Smart Asset - Graph Salaries (Raw) ]--------#
|
|
tmpGraph <- createGraph(tmpData, metaData)
|
|
tmpGraph <- drawGraph(tmpGraph, tmpData, 'sa_salary', 'Average Salary', TRUE)
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
#--------[ Smart Asset - Graph Salaries (Normalised) ]--------#
|
|
metaData['id'] = '101-SmartAsset-Salary-Normalised'
|
|
metaData['title'] = 'Smart Asset - US Average Salary (Normalised)'
|
|
metaData['ytitle'] = 'Average Salary (Normalised)'
|
|
|
|
tmpData['sa_salary'] = normalize(tmpData$sa_salary)
|
|
|
|
tmpGraph <- createGraph(tmpData, metaData)
|
|
tmpGraph <- drawGraph(tmpGraph, tmpData, 'sa_salary', 'Average Salary')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##########
|
|
##########
|
|
########## 200 Female Fertility
|
|
##########
|
|
##########
|
|
|
|
#--------[ Blitz Results - Meta Data ]--------#
|
|
metaData <- c(
|
|
source='https://www.blitzresults.com/en/fertility-by-age/',
|
|
file='data/BlitzResults-Fertility-female.csv',
|
|
set='200-FemaleFertility',
|
|
id='200-BlitzResults-FemaleFertility-Raw',
|
|
title='Blitz Results - Female Fertility (Raw Data)',
|
|
xtitle='Maternal age (years)',
|
|
ytitle='Female Fertility',
|
|
ltitle='Data',
|
|
aspect=c(16,9),
|
|
lpos='tc'
|
|
)
|
|
|
|
#--------[ Blitz Results - Load Data ]--------#
|
|
data200 <- loadData(metaData)
|
|
tmpData <- data200
|
|
|
|
#--------[ Blitz Results - Graph Female Fertility (raw) ]--------#
|
|
tmpGraph <- createGraph(tmpData, metaData)
|
|
tmpGraph <- tmpGraph + geom_bar(aes(y=blitz_preg_per_year, color='Chances of Getting Pregnant Within One Year'),stat='identity')
|
|
tmpGraph <- drawGraph(tmpGraph, tmpData, 'blitz_infertility', 'Likelyhood to be Infertile')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
#--------[ Blitz Results - Graph Female Fertility (line) ]--------#
|
|
metaData['id'] = '201-BlitzResults-FemaleFertility-Line'
|
|
tmpGraph <- createGraph(tmpData, metaData)
|
|
tmpGraph <- drawGraph(tmpGraph, tmpData, 'blitz_preg_per_year', 'Chances of Getting Pregnant Within One Year')
|
|
tmpGraph <- drawGraph(tmpGraph, tmpData, 'blitz_infertility', 'Likelyhood to be Infertile')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
#--------[ Blitz Results - Graph Female Fertility (line) ]--------#
|
|
metaData['id'] = '202-BlitzResults-FemaleFertility-Normalised'
|
|
metaData['title'] = 'Blitz Results - Female Fertility (Inverted)'
|
|
metaData['lpos'] = 'tr'
|
|
|
|
tmpData['blitz_infertility'] = 1 - tmpData$blitz_infertility
|
|
|
|
tmpGraph <- createGraph(tmpData, metaData)
|
|
tmpGraph <- drawGraph(tmpGraph, tmpData, 'blitz_preg_per_year', 'Chances of Getting Pregnant Within One Year')
|
|
tmpGraph <- drawGraph(tmpGraph, tmpData, 'blitz_infertility', 'Likelyhood to be Infertile')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
|
|
|
|
##########
|
|
##########
|
|
########## 300 Advance Maternal Age
|
|
##########
|
|
##########
|
|
|
|
#--------[ 300 Down Syndrome Health Risks ]--------#
|
|
metaData <- c(
|
|
source='http://www.ds-health.com/risk.htm',
|
|
file='data/DSHealth-Risk-Female.csv',
|
|
set='300-AdvancedMaternalAge',
|
|
id='300-DSHR-Complications-Raw',
|
|
title='Down Syndrome Health - Frequency of Down Syndrome Per Maternal Age (Raw Data)',
|
|
xtitle='Maternal age (years)',
|
|
ytitle='Likelyhood of Complications',
|
|
ltitle='Data',
|
|
aspect=c(16,9),
|
|
lpos='tl'
|
|
)
|
|
|
|
#--------[ Down Syndrome Health - Load Data ]--------#
|
|
data300 <- loadData(metaData)
|
|
tmpData <- data300
|
|
|
|
#--------[ Down Syndrome Health - Graph Complications (Raw) ]--------#
|
|
tmpGraph <- createGraph(tmpData, metaData)
|
|
tmpGraph <- drawGraph(tmpGraph, tmpData, 'dsh_fetus', 'Frequency of Fetuses with Down Syndrome')
|
|
tmpGraph <- drawGraph(tmpGraph, tmpData, 'dsh_birth', 'Frequency of Live Births of Babies with Down Syndrome')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
|
|
|
|
#--------[ 310 O&G Magazine ]--------#
|
|
metaData <- c(
|
|
source='https://www.ogmagazine.org.au/22/3-22/complications-of-advanced-maternal-age/',
|
|
file='data/OGMag-AMA-Complications.csv',
|
|
set='300-AdvancedMaternalAge',
|
|
id='310-OGM-Pregnancy-Raw',
|
|
title='O&G Magazone - Complications of Advanced Maternal Age (Raw Data)',
|
|
xtitle='Maternal age (years)',
|
|
ytitle='Likelyhood of Complications',
|
|
ltitle='Data',
|
|
aspect=c(16,9),
|
|
lpos='tl'
|
|
)
|
|
|
|
#--------[ O&G Magazine - Load Data ]--------#
|
|
data310 <- loadData(metaData)
|
|
tmpData <- data310
|
|
|
|
#--------[ O&G Magazine - Graph Complications (Raw) ]--------#
|
|
tmpGraph <- createGraph(tmpData, metaData)
|
|
tmpGraph <- drawGraph(tmpGraph, tmpData, 'ama_ectopic', 'Ectopic Pregnancy')
|
|
tmpGraph <- drawGraph(tmpGraph, tmpData, 'ama_miscarriage', 'Spontaneous Miscarriage')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
|
|
|
|
#--------[ 320 Combined Problems ]--------#
|
|
metaData <- c(
|
|
source='Combined data from various sources',
|
|
file='NA',
|
|
set='300-AdvancedMaternalAge',
|
|
id='320-CombinedComplications-Raw',
|
|
title='Combined Complications of Advanced Maternal Age (Raw Data)',
|
|
xtitle='Maternal age (years)',
|
|
ytitle='Likelyhood of Complications',
|
|
ltitle='Data',
|
|
aspect=c(16,9),
|
|
lpos='ml'
|
|
)
|
|
|
|
tmpGraph <- createGraph(data200, metaData)
|
|
tmpGraph <- drawGraph(tmpGraph, data200, 'blitz_preg_per_year', 'Chances of Getting Pregnant Within One Year')
|
|
tmpGraph <- drawGraph(tmpGraph, data200, 'blitz_infertility', 'Likelyhood to be Infertile')
|
|
tmpGraph <- drawGraph(tmpGraph, data300, 'dsh_fetus', 'Frequency of Fetuses with Down Syndrome')
|
|
tmpGraph <- drawGraph(tmpGraph, data300, 'dsh_birth', 'Frequency of Live Births of Babies with Down Syndrome')
|
|
tmpGraph <- drawGraph(tmpGraph, data310, 'ama_ectopic', 'Ectopic Pregnancy')
|
|
tmpGraph <- drawGraph(tmpGraph, data310, 'ama_miscarriage', 'Spontaneous Miscarriage')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
data200['blitz_infertility'] = 1 - data200$blitz_infertility
|
|
data300['dsh_fetus'] = 1 - data300$dsh_fetus
|
|
data300['dsh_birth'] = 1 - data300$dsh_birth
|
|
data310['ama_ectopic'] = 1 - data310$ama_ectopic
|
|
data310['ama_miscarriage'] = 1 - data310$ama_miscarriage
|
|
|
|
metaData['id'] = '321-CombinedComplications-Flipped'
|
|
metaData['title'] = 'Combined Complications of Advanced Maternal Age (Inverted)'
|
|
metaData['ytitle'] = 'Inverse Likelyhood of Complications (SMV Proxy)'
|
|
metaData['lpos'] = 'bl'
|
|
tmpGraph <- createGraph(data200, metaData)
|
|
tmpGraph <- drawGraph(tmpGraph, data200, 'blitz_preg_per_year', 'Chances of Getting Pregnant Within One Year')
|
|
tmpGraph <- drawGraph(tmpGraph, data200, 'blitz_infertility', 'Likelyhood to be Infertile')
|
|
tmpGraph <- drawGraph(tmpGraph, data300, 'dsh_fetus', 'Frequency of Fetuses with Down Syndrome')
|
|
tmpGraph <- drawGraph(tmpGraph, data300, 'dsh_birth', 'Frequency of Live Births of Babies with Down Syndrome')
|
|
tmpGraph <- drawGraph(tmpGraph, data310, 'ama_ectopic', 'Ectopic Pregnancy')
|
|
tmpGraph <- drawGraph(tmpGraph, data310, 'ama_miscarriage', 'Spontaneous Miscarriage')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
data200['blitz_preg_per_year'] = normalize(data200$blitz_preg_per_year)
|
|
data200['blitz_infertility'] = normalize(data200$blitz_infertility)
|
|
data300['dsh_fetus'] = normalize(data300$dsh_fetus)
|
|
data300['dsh_birth'] = normalize(data300$dsh_birth)
|
|
data310['ama_ectopic'] = normalize(data310$ama_ectopic)
|
|
data310['ama_miscarriage'] = normalize(data310$ama_miscarriage)
|
|
|
|
metaData['id'] = '322-CombinedComplications-Normalised'
|
|
metaData['title'] = 'Combined Complications of Advanced Maternal Age (Normalised)'
|
|
metaData['ytitle'] = 'Inverse Likelyhood of Complications (SMV Proxy)'
|
|
tmpGraph <- createGraph(data200, metaData)
|
|
tmpGraph <- drawGraph(tmpGraph, data200, 'blitz_preg_per_year', 'Chances of Getting Pregnant Within One Year')
|
|
tmpGraph <- drawGraph(tmpGraph, data200, 'blitz_infertility', 'Likelyhood to be Infertile')
|
|
tmpGraph <- drawGraph(tmpGraph, data300, 'dsh_fetus', 'Frequency of Fetuses with Down Syndrome')
|
|
tmpGraph <- drawGraph(tmpGraph, data300, 'dsh_birth', 'Frequency of Live Births of Babies with Down Syndrome')
|
|
tmpGraph <- drawGraph(tmpGraph, data310, 'ama_ectopic', 'Ectopic Pregnancy')
|
|
tmpGraph <- drawGraph(tmpGraph, data310, 'ama_miscarriage', 'Spontaneous Miscarriage')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
metaData['id'] = '323-CombinedComplications-Normalised-Infertility'
|
|
metaData['title'] = 'Combined Complications of Advanced Maternal Age (Normalised)'
|
|
metaData['ytitle'] = 'Inverse Likelyhood of Complications (SMV Proxy)'
|
|
metaData['lpos'] = 'bl'
|
|
tmpGraph <- createGraph(data200, metaData)
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data200, 'blitz_preg_per_year', 'Chances of Getting Pregnant Within One Year')
|
|
tmpGraph <- drawGraph(tmpGraph, data200, 'blitz_infertility', 'Likelyhood to be Infertile')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data300, 'dsh_fetus', 'Frequency of Fetuses with Down Syndrome')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data300, 'dsh_birth', 'Frequency of Live Births of Babies with Down Syndrome')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data310, 'ama_ectopic', 'Ectopic Pregnancy')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data310, 'ama_miscarriage', 'Spontaneous Miscarriage')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
metaData['id'] = '324-CombinedComplications-Normalised-Pregnancy'
|
|
tmpGraph <- createGraph(data200, metaData)
|
|
tmpGraph <- drawGraph(tmpGraph, data200, 'blitz_preg_per_year', 'Chances of Getting Pregnant Within One Yeare')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data200, 'blitz_infertility', 'Likelyhood to be Infertile')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data300, 'dsh_fetus', 'Frequency of Fetuses with Down Syndrome')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data300, 'dsh_birth', 'Frequency of Live Births of Babies with Down Syndrome')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data310, 'ama_ectopic', 'Ectopic Pregnancy')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data310, 'ama_miscarriage', 'Spontaneous Miscarriage')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
metaData['id'] = '325-CombinedComplications-Normalised-DownSyndrome'
|
|
tmpGraph <- createGraph(data200, metaData)
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data200, 'blitz_preg_per_year', 'Chances of Getting Pregnant Within One Year')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data200, 'blitz_infertility', 'Likelyhood to be Infertile')
|
|
tmpGraph <- drawGraph(tmpGraph, data300, 'dsh_fetus', 'Frequency of Fetuses with Down Syndrome')
|
|
tmpGraph <- drawGraph(tmpGraph, data300, 'dsh_birth', 'Frequency of Live Births of Babies with Down Syndrome')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data310, 'ama_ectopic', 'Ectopic Pregnancy')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data310, 'ama_miscarriage', 'Spontaneous Miscarriage')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
metaData['id'] = '326-CombinedComplications-Normalised-Ectopic'
|
|
tmpGraph <- createGraph(data200, metaData)
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data200, 'blitz_preg_per_year', 'Chances of Getting Pregnant Within One Year')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data200, 'blitz_infertility', 'Likelyhood to be Infertile')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data300, 'dsh_fetus', 'Frequency of Fetuses with Down Syndrome')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data300, 'dsh_birth', 'Frequency of Live Births of Babies with Down Syndrome')
|
|
tmpGraph <- drawGraph(tmpGraph, data310, 'ama_ectopic', 'Ectopic Pregnancy')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data310, 'ama_miscarriage', 'Spontaneous Miscarriage')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
metaData['id'] = '327-CombinedComplications-Normalised-Miscarriage'
|
|
tmpGraph <- createGraph(data200, metaData)
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data200, 'blitz_preg_per_year', 'Chances of Getting Pregnant Within One Year')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data200, 'blitz_infertility', 'Likelyhood to be Infertile')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data300, 'dsh_fetus', 'Frequency of Fetuses with Down Syndrome')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data300, 'dsh_birth', 'Frequency of Live Births of Babies with Down Syndrome')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data310, 'ama_ectopic', 'Ectopic Pregnancy')
|
|
tmpGraph <- drawGraph(tmpGraph, data310, 'ama_miscarriage', 'Spontaneous Miscarriage')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
# Calculate average for all female complications
|
|
tmpMaster <- data.frame( age=c(20:50) )
|
|
tmpMaster <- combineMaster(tmpMaster, data200)
|
|
tmpMaster <- combineMaster(tmpMaster, data300)
|
|
tmpMaster <- combineMaster(tmpMaster, data310)
|
|
tmpMaster <- cleanMaster(tmpMaster)
|
|
tmpMaster$ama_average = (
|
|
tmpMaster$blitz_preg_per_year +
|
|
tmpMaster$blitz_infertility +
|
|
tmpMaster$dsh_fetus +
|
|
tmpMaster$ama_ectopic +
|
|
tmpMaster$ama_miscarriage
|
|
)/6
|
|
tmpMaster$ama_average <- normalize(tmpMaster$ama_average)
|
|
|
|
metaData['id'] = '328-AdvancedMaternalAge-Average'
|
|
metaData['title'] = 'Combined Average of All Advanced Maternal Age Complications'
|
|
tmpGraph <- createGraph(tmpMaster, metaData)
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, tmpMaster, 'blitz_preg_per_year', 'Chances of Getting Pregnant Within One Year')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, tmpMaster, 'blitz_infertility', 'Likelyhood to be Infertile')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, tmpMaster, 'dsh_fetus', 'Frequency of Fetuses with Down Syndrome')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, tmpMaster, 'ama_ectopic', 'Ectopic Pregnancy')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, tmpMaster, 'ama_miscarriage', 'Spontaneous Miscarriage')
|
|
tmpGraph <- drawGraph(tmpGraph, tmpMaster, 'ama_average', 'Combined Average')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
|
|
##########
|
|
##########
|
|
########## 400 Male Fertility
|
|
##########
|
|
##########
|
|
|
|
#--------[ 400 Sperm Quality ]--------#
|
|
metaData <- c(
|
|
source='https://pubmed.ncbi.nlm.nih.gov/17430422/',
|
|
file='data/NCBI-SpermQuality.csv',
|
|
set='400-MaleFertility',
|
|
id='400-NCBI-MaleFertility-Raw',
|
|
title='NCBI PubMed - Relationship between age and semen parameters (Raw Data)',
|
|
xtitle='Paternal age (years)',
|
|
ytitle='Sperm Quality',
|
|
ltitle='Data',
|
|
aspect=c(16,9),
|
|
lpos='tl'
|
|
)
|
|
|
|
#--------[ Sperm Quality - Load Data ]--------#
|
|
data400 <- loadData(metaData)
|
|
tmpData <- data400
|
|
|
|
#--------[ Sperm Quality - Graph (raw) ]--------#
|
|
tmpGraph <- createGraph(tmpData, metaData)
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, tmpData, 'sperm_volume', 'Volume')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, tmpData, 'sperm_concentration', 'Concentration')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, tmpData, 'sperm_motility', 'Motility')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, tmpData, 'sperm_count', 'Total Count')
|
|
tmpGraph <- drawGraph(tmpGraph, tmpData, 'sperm_motility_tot', 'Total Motility')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
|
|
|
|
#--------[ 401 Sperm Quality ]--------#
|
|
metaData <- c(
|
|
source='https://pubmed.ncbi.nlm.nih.gov/17430422/',
|
|
file='data/NCBI-SpermQuality.csv',
|
|
set='400-MaleFertility',
|
|
id='401-NCBI-MaleFertility-Normalised',
|
|
title='NCBI PubMed - Relationship between age and semen parameters (Normalised)',
|
|
xtitle='Paternal age (years)',
|
|
ytitle='Sperm Quality',
|
|
ltitle='Data',
|
|
aspect=c(16,9),
|
|
lpos='bl'
|
|
)
|
|
|
|
tmpData['sperm_volume'] = normalize(data400$sperm_volume)
|
|
tmpData['sperm_concentration'] = normalize(data400$sperm_concentration)
|
|
tmpData['sperm_motility'] = normalize(data400$sperm_motility)
|
|
tmpData['sperm_count'] = normalize(data400$sperm_count)
|
|
tmpData['sperm_motility_tot'] = normalize(data400$sperm_motility_tot)
|
|
|
|
|
|
#--------[ Sperm Quality - Graph (raw) ]--------#
|
|
tmpGraph <- createGraph(tmpData, metaData)
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, tmpData, 'sperm_volume', 'Volume')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, tmpData, 'sperm_concentration', 'Concentration')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, tmpData, 'sperm_motility', 'Motility')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, tmpData, 'sperm_count', 'Total Count')
|
|
tmpGraph <- drawGraph(tmpGraph, tmpData, 'sperm_motility_tot', 'Total Motility')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
|
|
|
|
##########
|
|
##########
|
|
########## 500 Advanced Paternal Age
|
|
##########
|
|
##########
|
|
|
|
#--------[ 520 APA Combined ]--------#
|
|
metaData <- c(
|
|
source='Combined data from various sources',
|
|
file='NA',
|
|
set='500-AdvancedPaternalAge',
|
|
id='500-APA-Combined',
|
|
title='Combined Complications of Advanced Paternal Age (Normalised)',
|
|
xtitle='Paternal age (years)',
|
|
ytitle='Likelyhood of Complications',
|
|
ltitle='Data',
|
|
aspect=c(16,9),
|
|
lpos='br'
|
|
)
|
|
|
|
metaData['file'] = 'data/APA-Bipolar.csv'
|
|
data500 <- loadData(metaData)
|
|
|
|
metaData['file'] = 'data/APA-Autism.csv'
|
|
data501 <- loadData(metaData)
|
|
|
|
metaData['file'] = 'data/APA-Schizophrenia.csv'
|
|
data502 <- loadData(metaData)
|
|
|
|
metaData['file'] = 'data/APA-Intelligence.csv'
|
|
data503 <- loadData(metaData)
|
|
|
|
|
|
#--------[ Normalise APA Data ]--------#
|
|
data500$apa_bpd = normalize(data500$apa_bpd)
|
|
data501$apa_autism = normalize(data501$apa_autism)
|
|
data502$apa_schizophrenia = normalize(data502$apa_schizophrenia)
|
|
data503$apa_iq = 1 - normalize(data503$apa_iq)
|
|
|
|
|
|
#--------[ Calculate APA Average ]--------#
|
|
tmpMaster <- data.frame( age=c(20:50) )
|
|
tmpMaster <- combineMaster(tmpMaster, data500)
|
|
tmpMaster <- combineMaster(tmpMaster, data501)
|
|
tmpMaster <- combineMaster(tmpMaster, data502)
|
|
tmpMaster <- combineMaster(tmpMaster, data503)
|
|
tmpMaster <- cleanMaster(tmpMaster)
|
|
tmpMaster$apa_average = (
|
|
tmpMaster$apa_autism +
|
|
tmpMaster$apa_bpd +
|
|
tmpMaster$apa_schizophrenia +
|
|
tmpMaster$apa_iq
|
|
)/4
|
|
tmpMaster$apa_average <- normalize(tmpMaster$apa_average)
|
|
|
|
metaData['id'] = '500-APA-All'
|
|
metaData['title'] = 'Combined Average of All Advanced Paternal Age Complications (Normalised)'
|
|
tmpGraph <- createGraph(tmpMaster, metaData)
|
|
tmpGraph <- drawGraphClean(tmpGraph, data501, 'apa_autism', 'Autism Spectrum Disorder')
|
|
tmpGraph <- drawGraphClean(tmpGraph, data500, 'apa_bpd', 'Bipolar Disorder')
|
|
tmpGraph <- drawGraphClean(tmpGraph, data502, 'apa_schizophrenia', 'Schizophrenia')
|
|
tmpGraph <- drawGraphClean(tmpGraph, data503, 'apa_iq', 'WISC Full Scale IQ (Inverted)')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
metaData['id'] = '501-APA-Autism'
|
|
metaData['title'] = 'Combined Average of All Advanced Paternal Age Complications (Normalised)'
|
|
tmpGraph <- createGraph(tmpMaster, metaData)
|
|
tmpGraph <- drawGraph(tmpGraph, data501, 'apa_autism', 'Autism Spectrum Disorder')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data500, 'apa_bpd', 'Bipolar Disorder')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data502, 'apa_schizophrenia', 'Schizophrenia')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data503, 'apa_iq', 'WISC Full Scale IQ (Inverted)')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
metaData['id'] = '502-APA-BipolarDisorder'
|
|
metaData['title'] = 'Combined Average of All Advanced Paternal Age Complications (Normalised)'
|
|
tmpGraph <- createGraph(tmpMaster, metaData)
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data501, 'apa_autism', 'Autism Spectrum Disorder')
|
|
tmpGraph <- drawGraph(tmpGraph, data500, 'apa_bpd', 'Bipolar Disorder')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data502, 'apa_schizophrenia', 'Schizophrenia')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data503, 'apa_iq', 'WISC Full Scale IQ (Inverted)')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
metaData['id'] = '503-APA-Schizophrenia'
|
|
metaData['title'] = 'Combined Average of All Advanced Paternal Age Complications (Normalised)'
|
|
tmpGraph <- createGraph(tmpMaster, metaData)
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data501, 'apa_autism', 'Autism Spectrum Disorder')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data500, 'apa_bpd', 'Bipolar Disorder')
|
|
tmpGraph <- drawGraph(tmpGraph, data502, 'apa_schizophrenia', 'Schizophrenia')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data503, 'apa_iq', 'WISC Full Scale IQ (Inverted)')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
metaData['id'] = '504-APA-Intelligence'
|
|
metaData['title'] = 'Combined Average of All Advanced Paternal Age Complications (Normalised)'
|
|
tmpGraph <- createGraph(tmpMaster, metaData)
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data501, 'apa_autism', 'Autism Spectrum Disorder')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data500, 'apa_bpd', 'Bipolar Disorder')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data502, 'apa_schizophrenia', 'Schizophrenia')
|
|
tmpGraph <- drawGraph(tmpGraph, data503, 'apa_iq', 'WISC Full Scale IQ (Inverted)')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
metaData['id'] = '510-APA-Average'
|
|
metaData['title'] = 'Combined Average of All Advanced Paternal Age Complications (Normalised)'
|
|
tmpGraph <- createGraph(tmpMaster, metaData)
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data501, 'apa_autism', 'Autism Spectrum Disorder')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data500, 'apa_bpd', 'Bipolar Disorder')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data502, 'apa_schizophrenia', 'Schizophrenia')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data503, 'apa_iq', 'WISC Full Scale IQ (Inverted)')
|
|
tmpGraph <- drawGraph(tmpGraph, tmpMaster, 'apa_average', 'Combined Average')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
|
|
data500$apa_bpd = 1 - data500$apa_bpd
|
|
data501$apa_autism = 1 - data501$apa_autism
|
|
data502$apa_schizophrenia = 1 - data502$apa_schizophrenia
|
|
data503$apa_iq = 1 - data503$apa_iq
|
|
tmpMaster$apa_average = 1 - tmpMaster$apa_average
|
|
|
|
metaData['id'] = '521-APA-Average'
|
|
metaData['title'] = 'Combined Average of All Advanced Paternal Age Complications (Inverted)'
|
|
metaData['lpos'] = 'tr'
|
|
metaData['ytitle'] = 'Inverse Likelyhood of Complications (SMV Proxy)'
|
|
tmpGraph <- createGraph(tmpMaster, metaData)
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data500, 'apa_bpd', 'Bipolar Disorder (Inverted)')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data501, 'apa_autism', 'Autism Spectrum Disorder (Inverted)')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data502, 'apa_schizophrenia', 'Schizophrenia (Inverted)')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data503, 'apa_iq', 'WISC Full Scale IQ')
|
|
tmpGraph <- drawGraph(tmpGraph, tmpMaster, 'apa_average', 'Combined Average')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##########
|
|
##########
|
|
########## 600 Science Of Aging
|
|
##########
|
|
##########
|
|
|
|
#--------[ 600 Science Of Aging ]--------#
|
|
metaData <- c(
|
|
source='https://onlinelibrary.wiley.com/doi/full/10.1002/ajpa.23878',
|
|
file='data/Wiley-FacialAgingTrajectories-Female.csv',
|
|
set='600-Aging',
|
|
id='600-Wiley-FacialAgingTrajectories-Raw',
|
|
title='Facial Aging Trajectories (Raw Data)',
|
|
xtitle='Mean age (years)',
|
|
ytitle='Facial aging rate (Proc.dist/year)',
|
|
ltitle='Gender',
|
|
aspect=c(16,9),
|
|
lpos='tl'
|
|
)
|
|
|
|
#--------[ Aging - Load Female Data ]--------#
|
|
metaData['file'] = 'data/Wiley-FacialAgingTrajectories-Female.csv'
|
|
data600 <- loadData(metaData)
|
|
tmpData <- data600
|
|
|
|
#--------[ Aging - Load Male Data ]--------#
|
|
metaData['file'] = 'data/Wiley-FacialAgingTrajectories-Male.csv'
|
|
data601 <- loadData(metaData)
|
|
tmpData <- data601
|
|
|
|
#--------[ Aging - Graph (Raw) ]--------#
|
|
tmpGraph <- createGraph(tmpData, metaData)
|
|
tmpGraph <- drawGraph(tmpGraph, data600, 'wfat_female', 'Female')
|
|
tmpGraph <- drawGraph(tmpGraph, data601, 'wfat_male', 'Male')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
#--------[ 601 Science Of Aging Intermediate ]--------#
|
|
metaData <- c(
|
|
source='https://onlinelibrary.wiley.com/doi/full/10.1002/ajpa.23878',
|
|
file='data/Wiley-FacialAgingTrajectories-Female.csv',
|
|
set='600-Aging',
|
|
id='601-Wiley-FacialAgingTrajectories-Intermediate',
|
|
title='Facial Aging Trajectories (Intermediate Data)',
|
|
xtitle='Age (years)',
|
|
ytitle='Facial aging rate (Proc.dist/year)',
|
|
ltitle='Gender',
|
|
aspect=c(16,9),
|
|
lpos='tl'
|
|
)
|
|
|
|
#--------[ Create Master Dataframe ]--------#
|
|
tmpMaster <- data.frame( age=c(40:70) )
|
|
tmpMaster <- combineMaster(tmpMaster, data600)
|
|
tmpMaster <- combineMaster(tmpMaster, data601)
|
|
|
|
# Approximate missing NA data
|
|
tmpMaster <- as.data.frame(na.approx(tmpMaster))
|
|
|
|
# Delete Rows with NA
|
|
tmpMaster <- tmpMaster[complete.cases(tmpMaster),]
|
|
|
|
#--------[ Aging - Graph (Intermediate) ]--------#
|
|
tmpGraph <- createGraph(tmpMaster, metaData)
|
|
tmpGraph <- drawGraph(tmpGraph, tmpMaster, 'wfat_female', 'Female')
|
|
tmpGraph <- drawGraph(tmpGraph, tmpMaster, 'wfat_male', 'Male')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
#--------[ 601 Science Of Aging Intermediate ]--------#
|
|
metaData <- c(
|
|
source='https://onlinelibrary.wiley.com/doi/full/10.1002/ajpa.23878',
|
|
file='data/Wiley-FacialAgingTrajectories-Female.csv',
|
|
set='600-Aging',
|
|
id='602-Wiley-FacialAgingTrajectories-Cumulative',
|
|
title='Facial Aging Trajectories (Cumulative Data)',
|
|
xtitle='Age (years)',
|
|
ytitle='Facial aging total (cumulated per/year)',
|
|
ltitle='Gender',
|
|
aspect=c(16,9),
|
|
lpos='tl'
|
|
)
|
|
|
|
#--------[ Aging - Cumulate Data ]--------#
|
|
tmpMaster$wfat_female_cumulative = cumsum(tmpMaster$wfat_female)
|
|
tmpMaster$wfat_male_cumulative = cumsum(tmpMaster$wfat_male)
|
|
|
|
#--------[ Aging - Graph (Cumulative) ]--------#
|
|
tmpGraph <- createGraph(tmpMaster, metaData)
|
|
tmpGraph <- drawGraph(tmpGraph, tmpMaster, 'wfat_female_cumulative', 'Female')
|
|
tmpGraph <- drawGraph(tmpGraph, tmpMaster, 'wfat_male_cumulative', 'Male')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
#--------[ Aging - Graph (Cumulative Inverted) ]--------#
|
|
tmpMaster$wfat_male_cumulative = max(tmpMaster$wfat_female_cumulative) - tmpMaster$wfat_male_cumulative
|
|
tmpMaster$wfat_female_cumulative = max(tmpMaster$wfat_female_cumulative) - tmpMaster$wfat_female_cumulative
|
|
|
|
metaData['id'] = '603-Wiley-FacialAgingTrajectories-Cumulative-Inverted'
|
|
metaData['title'] = 'Facial Aging Trajectories SMV Proxy (Cumulative Data Inverted)'
|
|
metaData['lpos'] = 'bl'
|
|
tmpGraph <- createGraph(tmpMaster, metaData)
|
|
tmpGraph <- drawGraph(tmpGraph, tmpMaster, 'wfat_female_cumulative', 'Female')
|
|
tmpGraph <- drawGraph(tmpGraph, tmpMaster, 'wfat_male_cumulative', 'Male')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
|
|
|
|
##########
|
|
##########
|
|
########## 700 OKCupid Looks
|
|
##########
|
|
##########
|
|
|
|
#--------[ 700 OKCupid Looks ]--------#
|
|
metaData <- c(
|
|
source='https://www.dailymail.co.uk/femail/article-2751179/Are-girl-22-Then-don-t-bother-online-dating-Alarming-graph-shows-ages-attractive-opposite-sex.html',
|
|
file='data/OKCupid-Aging-Both.csv',
|
|
set='700-OKCupidLooks',
|
|
id='700-OKCupidLooks-Raw',
|
|
title='OKCupid Survey: Looks By Age (Raw Data)',
|
|
xtitle='Age (of test subject)',
|
|
ytitle='Age (of their ideal partner by looks)',
|
|
ltitle='Gender',
|
|
aspect=c(10,10),
|
|
lpos='tl'
|
|
)
|
|
|
|
#--------[ OKCupid Looks - Load Data ]--------#
|
|
data700 <- loadData(metaData)
|
|
tmpData <- data700
|
|
|
|
#--------[ OKCupid Looks - Graph (Raw) ]--------#
|
|
tmpGraph <- createGraph(tmpData, metaData)
|
|
tmpGraph <- tmpGraph + geom_abline(intercept = 0, slope = 1, linetype=2, alpha=0.4)
|
|
tmpGraph <- drawGraph(tmpGraph, data700, 'okc_male', 'Male Ideal', TRUE)
|
|
tmpGraph <- drawGraph(tmpGraph, data700, 'okc_female', 'Female Ideal', TRUE)
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
#--------[ 701 OKCupid Looks Distance ]--------#
|
|
metaData <- c(
|
|
source='https://www.dailymail.co.uk/femail/article-2751179/Are-girl-22-Then-don-t-bother-online-dating-Alarming-graph-shows-ages-attractive-opposite-sex.html',
|
|
file='data/OKCupid-Aging-Both.csv',
|
|
set='700-OKCupidLooks',
|
|
id='701-OKCupidLooks-Distance',
|
|
title='OKCupid Survey: Looks By Age (Distance)',
|
|
xtitle='Age of individual (years)',
|
|
ytitle='Distance from opposite gender\'s ideal (in years)',
|
|
ltitle='Gender',
|
|
aspect=c(10,10),
|
|
lpos='tl'
|
|
)
|
|
|
|
#--------[ OKCupid Looks - Calculate Distance ]--------#
|
|
data700['okc_female_dist'] = abs(data700$age-data700$okc_male)
|
|
data700['okc_male_dist'] = abs(data700$age-data700$okc_female)
|
|
|
|
#--------[ OKCupid Looks - Graph (Raw) ]--------#
|
|
tmpGraph <- createGraph(tmpData, metaData)
|
|
tmpGraph <- tmpGraph + geom_abline(intercept = -20, slope = 1, linetype=2, alpha=0.4)
|
|
tmpGraph <- drawGraph(tmpGraph, data700, 'okc_male_dist', 'Male Distance', TRUE)
|
|
tmpGraph <- drawGraph(tmpGraph, data700, 'okc_female_dist', 'Female Distance', TRUE)
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
#--------[ 702 OKCupid Looks Distance Inverted ]--------#
|
|
metaData <- c(
|
|
source='https://www.dailymail.co.uk/femail/article-2751179/Are-girl-22-Then-don-t-bother-online-dating-Alarming-graph-shows-ages-attractive-opposite-sex.html',
|
|
file='data/OKCupid-Aging-Both.csv',
|
|
set='700-OKCupidLooks',
|
|
id='702-OKCupidLooks-Distance-Inverted-NonNormal',
|
|
title='OKCupid Survey: Looks By Age (Distance Inverted)',
|
|
xtitle='Age of individual (years)',
|
|
ytitle='Distance from opposite gender\'s ideal (Normalised Inverted)',
|
|
ltitle='Gender',
|
|
aspect=c(10,10),
|
|
lpos='bl'
|
|
)
|
|
|
|
#--------[ OKCupid Looks - Calculate Distance ]--------#
|
|
data700['okc_male_dist'] = 1 - normalize2(data700$okc_male_dist, max(data700$okc_female_dist))
|
|
data700['okc_female_dist'] = 1 - normalize(data700$okc_female_dist)
|
|
|
|
#--------[ OKCupid Looks - Graph (Raw) ]--------#
|
|
tmpGraph <- createGraph(tmpData, metaData)
|
|
tmpGraph <- drawGraph(tmpGraph, data700, 'okc_male_dist', 'Male Distance')
|
|
tmpGraph <- drawGraph(tmpGraph, data700, 'okc_female_dist', 'Female Distance')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
#--------[ 702 OKCupid Looks Distance Inverted ]--------#
|
|
metaData <- c(
|
|
source='https://www.dailymail.co.uk/femail/article-2751179/Are-girl-22-Then-don-t-bother-online-dating-Alarming-graph-shows-ages-attractive-opposite-sex.html',
|
|
file='data/OKCupid-Aging-Both.csv',
|
|
set='700-OKCupidLooks',
|
|
id='702-OKCupidLooks-Distance-Inverted',
|
|
title='OKCupid Survey: Looks By Age (Distance Inverted)',
|
|
xtitle='Age of individual (years)',
|
|
ytitle='Distance from opposite gender\'s ideal (Normalised Inverted)',
|
|
ltitle='Gender',
|
|
aspect=c(10,10),
|
|
lpos='bl'
|
|
)
|
|
|
|
#--------[ OKCupid Looks - Calculate Distance ]--------#
|
|
data700['okc_female_dist'] = normalize(data700$okc_female_dist)
|
|
data700['okc_male_dist'] = normalize(data700$okc_male_dist)
|
|
|
|
#--------[ OKCupid Looks - Graph (Raw) ]--------#
|
|
tmpGraph <- createGraph(tmpData, metaData)
|
|
tmpGraph <- drawGraph(tmpGraph, data700, 'okc_male_dist', 'Male Distance')
|
|
tmpGraph <- drawGraph(tmpGraph, data700, 'okc_female_dist', 'Female Distance')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
|
|
#--------[ 703 OKCupid Looks Distance Inverted ]--------#
|
|
metaData <- c(
|
|
source='https://www.dailymail.co.uk/femail/article-2751179/Are-girl-22-Then-don-t-bother-online-dating-Alarming-graph-shows-ages-attractive-opposite-sex.html',
|
|
file='data/OKCupid-Aging-Both.csv',
|
|
set='700-OKCupidLooks',
|
|
id='703-OKCupidLooks-Distance-Inverted',
|
|
title='OKCupid Survey: Looks By Age (Distance Inverted)',
|
|
xtitle='Age of individual (years)',
|
|
ytitle='Distance from opposite gender\'s ideal (Normalised and Inverted)',
|
|
ltitle='Data',
|
|
aspect=c(10,10),
|
|
lpos='bl'
|
|
)
|
|
|
|
#--------[ OKCupid Looks - Graph (Raw) ]--------#
|
|
tmpGraph <- createGraph(tmpData, metaData)
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, data700, 'okc_male_dist', 'OKCupid - Male Distance')
|
|
tmpGraph <- drawGraph(tmpGraph, data700, 'okc_female_dist', 'OKCupid - Female Distance')
|
|
tmpGraph <- drawGraph(tmpGraph, data200, 'blitz_preg_per_year', 'Bliz Results - Chances of Getting Pregnant Within One Year')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##########
|
|
##########
|
|
########## 800 Master SMV Model
|
|
##########
|
|
##########
|
|
|
|
metaData <- c(
|
|
source='Combined Data',
|
|
file='NA',
|
|
set='800-MasterSMV',
|
|
id='800-MasterSMV',
|
|
title='Sexual Marketplace Value: Final Model',
|
|
xtitle='Age (years)',
|
|
ytitle='Sexual Marketplace Value',
|
|
ltitle='Data',
|
|
aspect=c(16,9),
|
|
lpos='tr'
|
|
)
|
|
dataMaster <- data.frame( age=c(15:70) )
|
|
|
|
# Salary
|
|
data100$sa_salary <- normalize(data100$sa_salary)
|
|
dataMaster <- combineMaster(dataMaster, data100)
|
|
|
|
# Female Fertility
|
|
data200$blitz_infertility <- normalize(data200$blitz_infertility)
|
|
data200$blitz_preg_per_year <- normalize(data200$blitz_preg_per_year)
|
|
dataMaster <- combineMaster(dataMaster, data200)
|
|
|
|
# Advanced Maternal Age
|
|
data300$dsh_fetus <- normalize(data300$dsh_fetus)
|
|
data300$dsh_birth <- normalize(data300$dsh_birth)
|
|
dataMaster <- combineMaster(dataMaster, data300)
|
|
|
|
data310$ama_ectopic <- normalize(data310$ama_ectopic)
|
|
data310$ama_miscarriage <- normalize(data310$ama_miscarriage)
|
|
dataMaster <- combineMaster(dataMaster, data310)
|
|
|
|
# Male Fertility
|
|
data400$sperm_volume <- normalize(data400$sperm_volume)
|
|
data400$sperm_concentration <- normalize(data400$sperm_concentration)
|
|
data400$sperm_motility <- normalize(data400$sperm_motility)
|
|
data400$sperm_count <- normalize(data400$sperm_count)
|
|
data400$sperm_motility_tot <- normalize(data400$sperm_motility_tot)
|
|
dataMaster <- combineMaster(dataMaster, data400)
|
|
|
|
# Advanced Paternal Age
|
|
data500$apa_bpd <- normalize(data500$apa_bpd)
|
|
dataMaster <- combineMaster(dataMaster, data500)
|
|
|
|
data501$apa_autism <- normalize(data501$apa_autism)
|
|
dataMaster <- combineMaster(dataMaster, data501)
|
|
|
|
data502$apa_schizophrenia <- normalize(data502$apa_schizophrenia)
|
|
dataMaster <- combineMaster(dataMaster, data502)
|
|
|
|
data503$apa_iq <- normalize(data503$apa_iq)
|
|
dataMaster <- combineMaster(dataMaster, data503)
|
|
|
|
# OKCupid Looks by Age
|
|
data700$okc_male <- 1 - normalize(data700$okc_male)
|
|
data700$okc_female <- 1 - normalize(data700$okc_female)
|
|
data700$okc_female_dist <- normalize(data700$okc_female_dist)
|
|
data700$okc_male_dist <- normalize(data700$okc_male_dist)
|
|
dataMaster <- combineMaster(dataMaster, data700)
|
|
|
|
# Clean model
|
|
dataMaster <- cleanMaster(dataMaster)
|
|
|
|
|
|
|
|
#--------[ Master SMV Model - Generate Combined Variables ]--------#
|
|
|
|
# Advanced Maternal Age - Average
|
|
dataMaster$ama_average <- (
|
|
dataMaster$dsh_fetus +
|
|
dataMaster$ama_ectopic +
|
|
dataMaster$ama_miscarriage
|
|
)/3
|
|
dataMaster$ama_average <- normalize(dataMaster$ama_average)
|
|
|
|
|
|
# Advanced Paternal Age - Average
|
|
dataMaster$apa_average <- (
|
|
dataMaster$apa_bpd +
|
|
dataMaster$apa_autism +
|
|
dataMaster$apa_schizophrenia +
|
|
dataMaster$apa_iq
|
|
)/4
|
|
dataMaster$apa_average <- normalize(dataMaster$apa_average)
|
|
|
|
|
|
|
|
#--------[ Master SMV Model - Final SMV ]--------#
|
|
|
|
# Male Sexual Market Value (simplified)
|
|
dataMaster$smv_male_simp <-(
|
|
dataMaster$sa_salary +
|
|
dataMaster$sperm_motility_tot +
|
|
dataMaster$apa_average
|
|
)/3
|
|
dataMaster$smv_male_simp <- normalize(dataMaster$smv_male_simp)
|
|
|
|
# Male Sexual Market Value
|
|
dataMaster$smv_male <-(
|
|
dataMaster$sa_salary +
|
|
dataMaster$sperm_motility_tot +
|
|
dataMaster$apa_average +
|
|
dataMaster$okc_male_dist
|
|
)/4
|
|
dataMaster$smv_male <- normalize(dataMaster$smv_male)
|
|
|
|
# Female Sexual Market Value
|
|
dataMaster$smv_female <-(
|
|
dataMaster$blitz_preg_per_year +
|
|
dataMaster$blitz_infertility +
|
|
dataMaster$ama_average +
|
|
dataMaster$okc_female_dist
|
|
)/4
|
|
dataMaster$smv_female <- normalize(dataMaster$smv_female)
|
|
|
|
|
|
|
|
|
|
#--------[ Master SMV Model - Data ]--------#
|
|
metaData <- c(
|
|
source='Combined data from various sources',
|
|
file='NA',
|
|
set='800-MasterSMV',
|
|
id='800-MasterSMV-Data',
|
|
title='Sexual Marketplace Value: Complete Dataset',
|
|
xtitle='Age (years)',
|
|
ytitle='Normalised Values',
|
|
ltitle='Data',
|
|
aspect=c(16,9),
|
|
lpos='mr'
|
|
)
|
|
tmpGraph <- createGraph(dataMaster, metaData)
|
|
tmpGraph <- drawGraphClean(tmpGraph, dataMaster, 'sa_salary', 'Average Salary')
|
|
tmpGraph <- drawGraphClean(tmpGraph, dataMaster, 'blitz_preg_per_year', 'Female Fertility - Chances of Getting Pregnant Within One Year')
|
|
tmpGraph <- drawGraphClean(tmpGraph, dataMaster, 'blitz_infertility', 'Female Fertility - Likelyhood to be Infertile')
|
|
tmpGraph <- drawGraphClean(tmpGraph, dataMaster, 'dsh_fetus', 'AMA Frequency of Fetuses with Down Syndrome')
|
|
tmpGraph <- drawGraphClean(tmpGraph, dataMaster, 'dsh_birth', 'AMA Frequency of Live Births of Babies with Down Syndrome')
|
|
tmpGraph <- drawGraphClean(tmpGraph, dataMaster, 'ama_ectopic', 'AMA Ectopic Pregnancy')
|
|
tmpGraph <- drawGraphClean(tmpGraph, dataMaster, 'ama_miscarriage', 'AMA Spontaneous Miscarriage')
|
|
tmpGraph <- drawGraphClean(tmpGraph, dataMaster, 'sperm_motility_tot', 'Male Fertility - Total Sperm Motility')
|
|
tmpGraph <- drawGraphClean(tmpGraph, dataMaster, 'apa_bpd', 'APA Bipolar Disorder')
|
|
tmpGraph <- drawGraphClean(tmpGraph, dataMaster, 'apa_autism', 'APA Autism Spectrum Disorder')
|
|
tmpGraph <- drawGraphClean(tmpGraph, dataMaster, 'apa_schizophrenia', 'APA Schizophrenia')
|
|
tmpGraph <- drawGraphClean(tmpGraph, dataMaster, 'apa_iq', 'APA WISC Full Scale IQ')
|
|
tmpGraph <- drawGraphClean(tmpGraph, dataMaster, 'apa_average', 'Advanced Paternal Age Complications (Average)')
|
|
tmpGraph <- drawGraphClean(tmpGraph, dataMaster, 'okc_male_dist', 'OKCupid - Male looks by age (Distance)')
|
|
tmpGraph <- drawGraphClean(tmpGraph, dataMaster, 'okc_female_dist', 'OKCupid - Female looks by age (Distance)')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
|
|
|
|
#--------[ Master SMV Model - Old SMV ]--------#
|
|
metaData <- c(
|
|
source='Combined data from various sources',
|
|
file='NA',
|
|
set='800-MasterSMV',
|
|
id='801-MasterSMV-Revisited',
|
|
title='Sexual Marketplace Value: Simplified Model',
|
|
xtitle='Age (years)',
|
|
ytitle='Sexual Marketplace Value',
|
|
ltitle='Data',
|
|
aspect=c(16,9),
|
|
lpos='mr'
|
|
)
|
|
tmpGraph <- createGraph(dataMaster, metaData)
|
|
tmpGraph <- drawGraphClean(tmpGraph, dataMaster, 'sa_salary', 'Male Average Salary')
|
|
tmpGraph <- drawGraphClean(tmpGraph, dataMaster, 'blitz_preg_per_year', 'Female Chances of Getting Pregnant Within One Year')
|
|
tmpGraph <- tmpGraph + geom_vline(aes(xintercept=32.25), linetype=2, alpha=0.5)
|
|
#tmpGraph <- drawGraphClean(tmpGraph, dataMaster, 'blitz_infertility', 'Female Likelyhood to be Infertile')
|
|
#tmpGraph <- tmpGraph + geom_vline(aes(xintercept=36.75), linetype=2, alpha=0.5)
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
|
|
|
|
#--------[ Master SMV Model - Female SMV ]--------#
|
|
|
|
metaData <- c(
|
|
source='Combined data from various sources',
|
|
file='NA',
|
|
set='800-MasterSMV',
|
|
id='802-MasterSMV-Female',
|
|
title='Sexual Marketplace Value: Female Model',
|
|
xtitle='Age (years)',
|
|
ytitle='Sexual Marketplace Value',
|
|
ltitle='Data',
|
|
aspect=c(16,9),
|
|
lpos='mr'
|
|
)
|
|
tmpGraph <- createGraph(dataMaster, metaData)
|
|
tmpGraph <- drawGraphAlphaMid(tmpGraph, dataMaster, 'blitz_preg_per_year', 'Female Fertility - Chances of Getting Pregnant Within One Year')
|
|
tmpGraph <- drawGraphAlphaMid(tmpGraph, dataMaster, 'blitz_infertility', 'Female Fertility - Likelyhood to be Infertile')
|
|
tmpGraph <- drawGraphAlphaMid(tmpGraph, dataMaster, 'ama_average', 'Advanced Maternal Age Complications (Average)')
|
|
tmpGraph <- drawGraphAlphaMid(tmpGraph, dataMaster, 'okc_female_dist', 'OKCupid - Female looks by age (Distance)')
|
|
tmpGraph <- drawGraphMaster(tmpGraph, dataMaster, 'smv_female', 'Female Sexual Market Value')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
|
|
|
|
#--------[ Master SMV Model - Male SMV (Simplified)]--------#
|
|
|
|
metaData <- c(
|
|
source='Combined data from various sources',
|
|
file='NA',
|
|
set='800-MasterSMV',
|
|
id='803-MasterSMV-Male-Simplified',
|
|
title='Sexual Marketplace Value: Male Model',
|
|
xtitle='Age (years)',
|
|
ytitle='Sexual Marketplace Value',
|
|
ltitle='Data',
|
|
aspect=c(16,9),
|
|
lpos='mr'
|
|
)
|
|
tmpGraph <- createGraph(dataMaster, metaData)
|
|
tmpGraph <- drawGraphAlphaMid(tmpGraph, dataMaster, 'sa_salary', 'Average Salary')
|
|
tmpGraph <- drawGraphAlphaMid(tmpGraph, dataMaster, 'sperm_motility_tot', 'Male Fertility - Total Sperm Motility')
|
|
tmpGraph <- drawGraphAlphaMid(tmpGraph, dataMaster, 'apa_average', 'Advanced Paternal Age Complications (Average)')
|
|
tmpGraph <- drawGraphMaster(tmpGraph, dataMaster, 'smv_male_simp', 'Male Sexual Market Value')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
|
|
#--------[ Master SMV Model - Male SMV ]--------#
|
|
|
|
metaData <- c(
|
|
source='Combined data from various sources',
|
|
file='NA',
|
|
set='800-MasterSMV',
|
|
id='804-MasterSMV-Male',
|
|
title='Sexual Marketplace Value: Male Model',
|
|
xtitle='Age (years)',
|
|
ytitle='Sexual Marketplace Value',
|
|
ltitle='Data',
|
|
aspect=c(16,9),
|
|
lpos='mr'
|
|
)
|
|
tmpGraph <- createGraph(dataMaster, metaData)
|
|
tmpGraph <- drawGraphAlphaMid(tmpGraph, dataMaster, 'sa_salary', 'Average Salary')
|
|
tmpGraph <- drawGraphAlphaMid(tmpGraph, dataMaster, 'sperm_motility_tot', 'Male Fertility - Total Sperm Motility')
|
|
tmpGraph <- drawGraphAlphaMid(tmpGraph, dataMaster, 'apa_average', 'Advanced Paternal Age Complications (Average)')
|
|
tmpGraph <- drawGraphAlphaMid(tmpGraph, dataMaster, 'okc_male_dist', 'OKCupid - Male looks by age (Distance)')
|
|
tmpGraph <- drawGraphMaster(tmpGraph, dataMaster, 'smv_male', 'Male Sexual Market Value')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
|
|
#--------[ Master SMV Model - Final SMV ]--------#
|
|
metaData <- c(
|
|
source='Combined data from various sources',
|
|
file='NA',
|
|
set='800-MasterSMV',
|
|
id='805-MasterSMV-Final',
|
|
title='Sexual Marketplace Value: Final Model',
|
|
xtitle='Age (years)',
|
|
ytitle='Sexual Marketplace Value',
|
|
ltitle='Data',
|
|
aspect=c(16,9),
|
|
lpos='mr'
|
|
)
|
|
|
|
tmpGraph <- createGraph(dataMaster, metaData)
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, dataMaster, 'sa_salary', 'Average Salary')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, dataMaster, 'blitz_preg_per_year', 'Female Fertility - Chances of Getting Pregnant Within One Year')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, dataMaster, 'blitz_infertility', 'Female Fertility - Likelyhood to be Infertile')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, dataMaster, 'ama_average', 'Advanced Maternal Age Complications (Average)')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, dataMaster, 'sperm_motility_tot', 'Male Fertility - Total Sperm Motility')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, dataMaster, 'apa_average', 'Advanced Paternal Age Complications (Average)')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, dataMaster, 'okc_male_dist', 'OKCupid - Male looks by age (Distance)')
|
|
tmpGraph <- drawGraphAlpha(tmpGraph, dataMaster, 'okc_female_dist', 'OKCupid - Female looks by age (Distance)')
|
|
|
|
tmpGraph <- drawGraphMaster(tmpGraph, dataMaster, 'smv_male', 'Male Sexual Market Value')
|
|
tmpGraph <- drawGraphMaster(tmpGraph, dataMaster, 'smv_female', 'Female Sexual Market Value')
|
|
|
|
tmpGraph <- tmpGraph + geom_vline(aes(xintercept=34), linetype=2, alpha=0.5)
|
|
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
|
|
|
|
#--------[ Master SMV Model - Male SMV (Alternative Average) ]--------#
|
|
|
|
metaData <- c(
|
|
source='Combined data from various sources',
|
|
file='NA',
|
|
set='800-MasterSMV',
|
|
id='810-MasterSMV-Male-Alternate-10',
|
|
title='Sexual Marketplace Value: Male Model',
|
|
xtitle='Age (years)',
|
|
ytitle='Sexual Marketplace Value',
|
|
ltitle='Data',
|
|
aspect=c(16,9),
|
|
lpos='mr'
|
|
)
|
|
|
|
dataMaster$smv_male <-(
|
|
(dataMaster$sa_salary * 0.30) +
|
|
(dataMaster$sperm_motility_tot * 0.30) +
|
|
(dataMaster$apa_average * 0.30) +
|
|
(dataMaster$okc_male_dist * 0.1)
|
|
)
|
|
dataMaster$smv_male <- normalize(dataMaster$smv_male)
|
|
|
|
tmpGraph <- createGraph(dataMaster, metaData)
|
|
tmpGraph <- drawGraphClean(tmpGraph, dataMaster, 'smv_male', 'Male Sexual Market Value')
|
|
saveGraph(tmpGraph, metaData)
|
|
|
|
|
|
metaData['id']='811-MasterSMV-Male-Alternate-50'
|
|
dataMaster$smv_male <-(
|
|
(dataMaster$sa_salary * 0.16666) +
|
|
(dataMaster$sperm_motility_tot * 0.16666) +
|
|
(dataMaster$apa_average * 0.16666) +
|
|
(dataMaster$okc_male_dist * 0.5)
|
|
)
|
|
dataMaster$smv_male <- normalize(dataMaster$smv_male)
|
|
|
|
tmpGraph <- createGraph(dataMaster, metaData)
|
|
tmpGraph <- drawGraphClean(tmpGraph, dataMaster, 'smv_male', 'Male Sexual Market Value')
|
|
saveGraph(tmpGraph, metaData)
|