Skip to content

Commit

Permalink
riocs (#19)
Browse files Browse the repository at this point in the history
Using reference SNP IRM for constrant. Using chip snp IRM for EBV.
  • Loading branch information
xijiang authored Sep 30, 2024
1 parent 2292e97 commit 0514690
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/fdr/xybase.jl
Original file line number Diff line number Diff line change
@@ -1 +1 @@

function xybase() end
2 changes: 1 addition & 1 deletion src/xps/schemes/file-irm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function fileIRM(
xy::AbstractString,
chp::AbstractVector{Bool},
id::AbstractVector{Int64};
ε = 0.0
ε = 0.0,
)
n = length(id)
if isfile(file) && filesize(file) == sizeof(Float64) * n * n
Expand Down
41 changes: 41 additions & 0 deletions src/xps/schemes/ocs-2sex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,47 @@ function iiocs(test, foo, bar, lmp, ngn, trait, fixed, plan, dF, F0; ε = 1e-6)
serialize("$test/$bar.ped", ped)
end

"""
riocs(test, foo, bar, lmp, ngn, trait, fixed, plan, dF, F0; ε = 1e-6)
Optimal contribution selection with `IBD` relationship matrix for both EBV and
constraint on `foo`.xy and `foo`.ped in directory `test` for `ngn` generations.
For constraint, the IRM is from the reference SNP loci. The EBV are estimated
with IRM from chip SNPs. SNP linkage information are in DataFrame `lmp`. The
results are saved in `bar`.xy, `bar`.ped in directory `test`. The selection is
on a single trait `trait` with fixed effects `fixed`, which is a column name
vector in pedigree DataFrame. Parents are sampled according to `plan`. The
constraint ΔF is `dF`. `F0` is the inbreeding coefficient of the `foo`
population.
This function uses the TM1997 algorithm for OCS.
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"
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); ε = ε)
for ign = 1:ngn
print(" $ign")
ids = view(ped, ped.grt .== ped.grt[end], :id)
phenotype!(ids, ped, trait)
giv = inv(G)
Predict!(ids, ped, fixed, giv, trait)
g22 = G[ids, ids]
mid = size(ped, 1)
ng = Select(ids, plan, ped, g22, trait, dF, ign; F0 = F0)
reproduce!(ng, ped, xy, lmp, trait)
G = xirm(G, xy, lmp.dark, mid, size(ped, 1))
for i = mid+1:size(G, 1)
G[i, i] += ε
end
end
println()
serialize("$test/$bar.ped", ped)
end

"""
iidos(test, foo, bar, lmp, ngn, trait, fixed, plan, dF, F0)
Optimal contribution selection with `IBD` relationship matrix for both EBV and
Expand Down

0 comments on commit 0514690

Please sign in to comment.