Skip to content

Commit

Permalink
Merge pull request #102 from reworkhow/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
reworkhow authored Nov 7, 2021
2 parents 2cb6da5 + 1f6ff7e commit 540644b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/1.JWAS/src/markers/readgenotypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function get_genotypes(file::Union{AbstractString,Array{Float64,2},Array{Float32
@warn "genotype scores out of the range 0 to 2 are found."
end
end
printstyled("Missing values are replaced by column means.\n",bold=true)
printstyled("Missing values ($missing_value) are replaced by column means.\n",bold=true)
end

markerMeans = center==true ? center!(genotypes) : mean(genotypes,dims=1) #centering genotypes or not
Expand Down Expand Up @@ -198,7 +198,7 @@ function get_genotypes(file::Union{AbstractString,Array{Float64,2},Array{Float32
genotypes = genotypes + I*0.00001
add_small_value_count += 1
if add_small_value_count > 10
error("Please provide a positive-definite realtionship matrix.")
error("Please provide a positive-definite relationship matrix.")
end
end
end
Expand Down
22 changes: 12 additions & 10 deletions src/1.JWAS/src/single_step/SSGBLUP.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function get_Hi(pedigree,genotypes)
#http://nce.ads.uga.edu/wiki/lib/exe/fetch.php?media=singlestepblupf90.pdf
function get_Hi(pedigree,genotypes;weight_for_G::Float64 = 1.0)
#***********************************************************************
#Hi = Ai + [0 0;0 inv(G)- inv(A_gg)]
#***********************************************************************
Expand All @@ -15,15 +16,16 @@ function get_Hi(pedigree,genotypes)
M,p,freq = genotypes.genotypes, genotypes.nMarkers, genotypes.alleleFreq #already centered
M = M ./ sqrt.(2*freq.*(1 .- freq))
G = (M*M'+ I*0.00001)/p
add_small_value_count = 0
while isposdef(G) == false
println("The relationship matrix is not positive definite. A very small number is added to the diagonal.")
G += I*0.00001
add_small_value_count += 1
if add_small_value_count > 10
error("Please provide a positive-definite realtionship matrix.")
end
end
end
if 0.0 <= weight_for_G <= 1.0
weight_for_G = round(weight_for_G, digits=3)
weight_for_A = round(1-weight_for_G, digits=3)
G = weight_for_G*G + weight_for_A*A_gg
println("The genomic relationship matrix is calculated as
G = $weight_for_G G + $weight_for_A A.")
end
if isposdef(G) == false
error("Please provide a positive-definite relationship matrix.")
end

IDs = pedigree.IDs
Expand Down

0 comments on commit 540644b

Please sign in to comment.