#To run this code you need to read an IBD-matrix (which is symmetric and has equal number of rows and columns) into R #The IBD-matrix should be defined as a matrix and given the variable name: IBD.mat #Code written by Lars Ronnegard 2008-07-08 #The following function calculates the eigenvalues and eigenvectors of the IBD-matrix eigen.IBD<-eigen(IBD.mat,only.values=FALSE) #This is my suggested threshold given in the Genetics note threshold=0.8 #Get the size of the IBD-matrix dim.IBD=dim(IBD.mat) n.rows=dim.IBD[1] #Number of eigenvalues and eigenvectors to be included in the reduced form is calculated here. cnt=0 for (j in 1:n.rows) { if (sum(eigen.IBD$values[1:j])