# This computes a reduced-dimension inverse of (G + I*theta) #Run as: julia PCIG.jl the filenames must be common to all chromsomes infile1=ARGS[1]; rhofile=ARGS[2]; chroms=parse(Int64,ARGS[3]); theta=parse(Float64,ARGS[4]); #Scalar added to diagonal of the genomic relationship matrix to make it positive definite Ct=[]; rho=0; N=0;# i=1 for i=1:chroms; C=readdlm("$(infile1).$i"); # Read in score data of chr i from file N=size(C,1); #no. of animal rho=rho+sum(readdlm("$(rhofile).$i")); # Trick to make only a number if i==1; Ct=C; else Ct=[Ct C]; end; end; invMatrix=inv(Ct'*Ct+eye(size(Ct,2))*rho*theta); IG=(1/theta)*(eye(N)-Ct*invMatrix*Ct'); # Computes the inverse, reduced-dimension GRM from the score matrix writedlm("IG.txt",IG,"\t")