sink(file = "CorPopRes.txt", append = FALSE) names1=c("AFR","AMR","ASN","EUR") names=c("AFRICAN","AD MIX AMERICAN","ASIAN","EUROPEAN") print("###############################") print(paste("####DENISOVA###########",sep="")) print("###############################") for (pop in 6:9) { # pop <- 9 #6 = "AFR" 7= "AMR" 8 = "ASN" 9 = "EUR" print("###############################") print(paste("####",names[pop-5],"###########",sep="")) print("###############################") t <- cor.test(PopulationMat[,pop],DenisovaMat[,12],method ="pearson") print(t) print(paste("==========",t$p.value,"=============",sep="")) t <- cor.test(PopulationMat[,pop],DenisovaMat[,12],method ="spearman") print(t) print(paste("==========",t$p.value,"=============",sep="")) thres1 <- 0.2 thres2 <- 0.3 L <- length(PopulationMat[,pop]) pa <- which(PopulationMat[,pop]>thres1) pb <- which(DenisovaMat[,12]>thres2) ab <- intersect(pa,pb) lab <- length(ab) la <- length(pa) lb <- length(pb) laB <- la-lab lAb <- lb-lab lAB <- L - lab - laB - lAb conf <- matrix(c(lab,laB,lAb,lAB),nrow=2,ncol=2) t <- fisher.test(conf) print(t) print(paste("==========",t$p.value,"=============",sep="")) print("###############################") } ######################################################### ######################################################### ######################################################### ######################################################### ######################################################### names1=c("AFR","AMR","ASN","EUR") names=c("AFRICAN","AD MIX AMERICAN","ASIAN","EUROPEAN") print("###############################") print(paste("####NEANDERTAL###########",sep="")) print("###############################") for (pop in 6:9) { # pop <- 9 #6 = "AFR" 7= "AMR" 8 = "ASN" 9 = "EUR" print("###############################") print(paste("####",names[pop-5],"###########",sep="")) print("###############################") t <- cor.test(PopulationMat[,pop],NeanderMat[,12],method ="pearson") print(t) print(paste("==========",t$p.value,"=============",sep="")) t <- cor.test(PopulationMat[,pop],NeanderMat[,12],method ="spearman") print(t) print(paste("==========",t$p.value,"=============",sep="")) thres1 <- 0.2 thres2 <- 0.3 L <- length(PopulationMat[,pop]) pa <- which(PopulationMat[,pop]>thres1) pb <- which(NeanderMat[,12]>thres2) ab <- intersect(pa,pb) lab <- length(ab) la <- length(pa) lb <- length(pb) laB <- la-lab lAb <- lb-lab lAB <- L - lab - laB - lAb conf <- matrix(c(lab,laB,lAb,lAB),nrow=2,ncol=2) t <- fisher.test(conf) print(t) print(paste("==========",t$p.value,"=============",sep="")) print("###############################") } ######################################################### ######################################################### ######################################################### ######################################################### ######################################################### names1=c("AFR","AMR","ASN","EUR") names=c("AFRICAN","AD MIX AMERICAN","ASIAN","EUROPEAN") print("###############################") print(paste("####ANCESTOR###########",sep="")) print("###############################") for (pop in 6:9) { # pop <- 9 #6 = "AFR" 7= "AMR" 8 = "ASN" 9 = "EUR" print("###############################") print(paste("####",names[pop-5],"###########",sep="")) print("###############################") t <- cor.test(PopulationMat[,pop],AncestMat[,12],method ="pearson") print(t) print(paste("==========",t$p.value,"=============",sep="")) t <- cor.test(PopulationMat[,pop],AncestMat[,12],method ="spearman") print(t) print(paste("==========",t$p.value,"=============",sep="")) thres1 <- 0.2 thres2 <- 0.3 L <- length(PopulationMat[,pop]) pa <- which(PopulationMat[,pop]>thres1) pb <- which(AncestMat[,12]>thres2) ab <- intersect(pa,pb) lab <- length(ab) la <- length(pa) lb <- length(pb) laB <- la-lab lAb <- lb-lab lAB <- L - lab - laB - lAb conf <- matrix(c(lab,laB,lAb,lAB),nrow=2,ncol=2) t <- fisher.test(conf) print(t) print(paste("==========",t$p.value,"=============",sep="")) print("###############################") } ######################################################### ############################################################### print("###############################") print(paste("####DENISOVA 2###########",sep="")) print("###############################") for (pop in 6:9) { # pop <- 9 #6 = "AFR" 7= "AMR" 8 = "ASN" 9 = "EUR" print("###############################") print(paste("####",names[pop-5],"###########",sep="")) print("###############################") thres1 <- 0.2 thres2 <- 0.5 L <- length(PopulationMat[,pop]) pa <- which(PopulationMat[,pop]>thres1) pb <- which(DenisovaMat[,12]>thres2) ab <- intersect(pa,pb) lab <- length(ab) la <- length(pa) lb <- length(pb) laB <- la-lab lAb <- lb-lab lAB <- L - lab - laB - lAb conf <- matrix(c(lab,laB,lAb,lAB),nrow=2,ncol=2) t <- fisher.test(conf) print(t) print(paste("==========",t$p.value,"=============",sep="")) print("###############################") } print("###############################") print(paste("####DENISOVA 3###########",sep="")) print("###############################") for (pop in 6:9) { # pop <- 9 #6 = "AFR" 7= "AMR" 8 = "ASN" 9 = "EUR" print("###############################") print(paste("####",names[pop-5],"###########",sep="")) print("###############################") thres1 <- 0.4 thres2 <- 0.5 L <- length(PopulationMat[,pop]) pa <- which(PopulationMat[,pop]>thres1) pb <- which(DenisovaMat[,12]>thres2) ab <- intersect(pa,pb) lab <- length(ab) la <- length(pa) lb <- length(pb) laB <- la-lab lAb <- lb-lab lAB <- L - lab - laB - lAb conf <- matrix(c(lab,laB,lAb,lAB),nrow=2,ncol=2) t <- fisher.test(conf) print(t) print(paste("==========",t$p.value,"=============",sep="")) print("###############################") } sink()