#9 SNPs #removing 507: 178, 270 #removing 508: 176,276 AncientG_imp <- matrix(c(177, 4017, 273, 5037), nrow = 2, dimnames = list(c("Ancient", "Modern"), c("Positive_all", "Negative_all"))) AncientG_imp ci.1=fisher.test(AncientG_imp, conf.level = 0.95) ci.1 #Fisher's test 162 (130) SNPs by Okbay et al. 2016 #removing 507: 3305,4001 #removing 508: 3292, 3994 #average 3298.5,3997.5 AncientG_162 <- matrix(c(3298.5, 61666, 3997.5, 69114), nrow = 2, dimnames = list(c("Ancient", "Modern"), c("Positive_all", "Negative_all"))) AncientG_162 ci.2=fisher.test(AncientG_162, conf.level = 0.95) ci.2 #Davies et al 2016 #removing 507: 267 285 #removing 508: 270 280 AncientG_Davies <- matrix(c(268.5, 5960, 282.5, 5106), nrow = 2, dimnames = list(c("Ancient", "Modern"), c("Positive_all", "Negative_all"))) AncientG_Davies fisher.test(AncientG_Davies, alternative = "less") fisher.test(AncientG_Davies, conf.int = FALSE) fisher.test(AncientG_Davies, conf.level = 0.95) #Chi Square test chisq.test(AncientG_162) chisq.test(AncientG_7) chisq.test(AncientG_imp) chisq.test(AncientG_Davies) #Barnard test library(Exact) exact.test(AncientG_imp, method="Boschloo", alternative="two.sided", model="Binomial",cond.row = TRUE) exact.test(AncientG_imp, method="csm approximate", alternative="two.sided") #Barnard #likelihood ratio (G2) # G-test library(DescTools) GTest(AncientG_162) GTest(AncientG_imp) GTest(AncientG_Davies) library(RVAideMemoire) G.test(AncientG_162) #genomic age and polygenic score 0)) ageps <- read_csv("~/ageps.csv") #compute correlation between age and PS cor(ageps$PS,ageps$Age,method="pearson",use="complete.obs") #C.I. of the corr. coefficient CIr(r=0.217,n=66,level=.95) #linear regression fitAGEPS <- lm(PS~Age, data=ageps) hist(residuals(fitAGEPS))#draw histogram library(ggplot2) library(ggrepel) ageps$AgeCE=2017-ageps$Age#transform data from BP into CE format #draw scatterplot with CI ggplot(ageps, aes(x=AgeCE, y=PS)) + geom_point(shape=1) + # Use hollow circles labs(x="Year", y="130 SNP POLYcog")+ geom_smooth(method=lm) #calculate skewness and kurtosis library(moments) skewness(ageps$PS) kurtosis(ageps$PS)