#Set working directory setwd("~/Desktop/Analysis") library(Rhh) #Save MHC genotypes (from excel sheet) as a tab delimited txt file in working directory and delete header row #Do the same for the Non-MHC genotypes (from excel sheet) #Analyse MHC Genotypes h <- mlh("MHC Genotypes.txt", "MHC-Hs.txt", "NA", 4) #Saves results in working directory r <- h_cor("MHC Genotypes.txt", "0", 1000, "sh") mean(r) quantile(r, probs=c(0.025, 0.975)) hist(r) #Analyse Non-MHC Genotypes h <- mlh("Non-MHC Genotypes.txt", "Non-MHC-Hs.txt", "NA", 4) #Saves results in working directory r <- h_cor("Non-MHC Genotypes.txt", "0", 1000, "sh") mean(r) quantile(r, probs=c(0.025, 0.975)) hist(r) # Determine correlation between Hs at MHC vs Non-MHC loci MHC <- read.table("MHC-Hs.txt", header = TRUE) Non-MHC <- read.table("Non-MHC-Hs.txt", header = TRUE) cor.test(MHC$SH, Non-MHC$SH, method = "spearman", continuity = FALSE, conf.level = 0.95) library(RVAideMemoire) library(vegan) spearman.ci(MHC$SH, Non-MHC$SH, nrep = 1000, conf.level = 0.95) plot(MHC$SH, Non-MHC$SH)