Skip to content

Commit

Permalink
Constraint bug (#20)
Browse files Browse the repository at this point in the history
The bug about calculation of constraint was corrected.

Before (igrt+1) was used. This will result in too relaxed constraint
in the beginning of the directional selection.
  • Loading branch information
xijiang authored Oct 2, 2024
1 parent 0514690 commit 0679ce8
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "xyBnG"
uuid = "056de5cc-3822-4b22-85ae-bc65d3fbfd0e"
authors = ["Xijiang Yu <xijiang@users.noreply.github.com> and contributors"]
version = "1.3.1-1"
version = "1.3.2"

[deps]
CompatHelperLocal = "5224ae11-6099-4aaa-941d-3aab004bd678"
Expand Down
2 changes: 2 additions & 0 deletions src/brd/ocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function TM2024(ped, A, K)
DOSop(ped.idx, A, zeros(ncd), 1.0, K, [nsire, ndam], ped.sex .+ 1) / 2.0
end

#=
"""
konstraint(dF::Float64, k₀::Float64, igrt::Int; ong = false)
Calculate the constraint about inbreeding increase in the next generation. Note,
Expand All @@ -75,6 +76,7 @@ function konstraint(dF::Float64, k₀::Float64, igrt::Int; ong = false)
2(1 - (1 - k₀) * (1 - dF)^(igrt + 1))
end
end
=#

"""
OC_fixsex2(EBV, A, K, c2)
Expand Down
2 changes: 1 addition & 1 deletion src/brd/select.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function Select(
dat = select(ped[ID, :], "ebv_$(trt.name)" => :idx, :sex)
rev || (dat.idx .*= -1)

K = konstraint(dF, F0, igrt)
K = 2(1 - (1 - F0) * (1 - dF)^igrt) #konstraint(dF, F0, igrt)
c = ocs(dat, rs, K) # this is to select the highest, or equivalently rev = true
cs = ped.sex[ID] .== 1 # sire candidates
cd = ped.sex[ID] .== 0 # dam candidates
Expand Down
1 change: 1 addition & 0 deletions src/xps/schemes/file-irm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function fileIRM(
)
n = length(id)
if isfile(file) && filesize(file) == sizeof(Float64) * n * n
@info "Calculate intial IRM"
G = zeros(Float64, n, n)
read!(file, G)
return G
Expand Down
2 changes: 1 addition & 1 deletion src/xps/schemes/ocs-2sex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ See also [`randbrd`](@ref), [`aaocs`](@ref), [`iidos`](@ref), [`ggocs`](@ref),
[`agocs`](@ref), [`igocs`](@ref).
"""
function riocs(test, foo, bar, lmp, ngn, trait, fixed, plan, dF, F0; ε = 1e-6)
@info " - Directional selection IIOCS for $ngn generations"
@info " - Directional selection RIOCS for $ngn generations"
ped, xy = deserialize("$test/$foo.ped"), "$test/$bar.xy"
cp("$test/$foo.xy", xy, force = true)
G = fileIRM("$test/$foo.irm", xy, lmp.dark, 1:size(ped, 1); ε = ε)
Expand Down

0 comments on commit 0679ce8

Please sign in to comment.