################################################################################ ################################# TA10 - HLA Typing ############################ ################################################################################ load("hladb.RData") samples = hladb$Sample hamming = data.frame() sample1 = hladb[which(hladb$Sample == "Recipient"),-1] for(i in 2:length(samples)) { sample2 = hladb[which(hladb$Sample == samples[i]),-1] hammingDistance = sum(sample1 != sample2) # This is how we ham hamming = rbind(hamming, data.frame(samples[i], hammingDistance)) } colnames(hamming) = c("Sample2", "Hamming") # We need at 10 matches so we say it's a match # But Hamming measures DISTANCE and not SIMILARITY # So let's calculate the maximum hamming distance for it to be a match: # We have 19 measurements, out of which we need 10 to match - meaning we can have # a maximum distance of 19-10 = 9 hamming$Sample2[hamming$Hamming <= 9]