Skip to content

Commit

Permalink
update user-defined prediction equation
Browse files Browse the repository at this point in the history
  • Loading branch information
reworkhow committed Jul 22, 2021
1 parent 01e3092 commit 474f7db
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/1.JWAS/src/JWAS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export dataset
* If `causal_structure` is provided, e.g., causal_structure = [0.0 0.0 0.0;1.0 0.0 0.0;1.0 0.0 0.0] for
trait 2 -> trait 1 and trait 3 -> trait 1 (row index affacts column index), phenotypic causal networks will be incorporated using structure equation models.
* Genomic Prediction
* Predicted values for individuals of interest can be obtained based on an user-defined prediction equation `prediction_equation`, e.g., "y1:animal + y1:geno + y1:age".
* Predicted values for individuals of interest can be obtained based on an user-defined prediction equation `prediction_equation`, e.g., "y1:animal + y1:age".
For now, genomic data is always included. Genetic values including effects defined with genotype and pedigre information are returned if `prediction_equation`= false, defaulting to `false`.
* Individual estimted genetic values and prediction error variances (PEVs) are returned if `outputEBV`=true, defaulting to `true`. Heritability and genetic
variances are returned if `output_heritability`=`true`, defaulting to `true`. Note that estimation of heritability is computaionally intensive.
Expand Down
15 changes: 13 additions & 2 deletions src/1.JWAS/src/output.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,20 @@ function prediction_setup(model)
end
else
prediction_equation = string.(strip.(split(model.MCMCinfo.prediction_equation,"+")))
if mme.MCMCinfo.output_heritability != false
if model.MCMCinfo.output_heritability != false
printstyled("User-defined prediction equation is provided. ","The heritability is the ",
"proportion of phenotypic variance explained by the value defined by the prediction equation.\n",
bold=false,color=:green)
end
for i in prediction_equation
term_symbol = Symbol(split(i,":")[end])
if !(haskey(model.modelTermDict,i) || (isdefined(Main,term_symbol) && typeof(getfield(Main,term_symbol)) == Genotypes))
error("Terms $i in the prediction equation is not found.")
end
end
end
printstyled("Predicted values for individuals of interest will be obtained as the summation of ",
prediction_equation, " (Note that genomic data is always included for now).",bold=false,color=:green)
if length(prediction_equation) == 0 && model.M == false
println("Default or user-defined prediction equation are not available.")
model.MCMCinfo.outputEBV = false
Expand Down Expand Up @@ -221,10 +229,13 @@ function getEBV(mme,traiti)
mytrait, effect = split(term,':')
if mytrait == traiti_name
sol_term = map(Float64,location_parameters[(location_parameters[!,:Effect].==effect).&(location_parameters[!,:Trait].==traiti_name),:Estimate])
if length(sol_term) == 1 #1-element Array{Float64,1} doesn't work below; convert it to a scalar
if VERSION < v"1.6" && length(sol_term) == 1 #1-element Array{Float64,1} doesn't work below; Will be deleted
sol_term = sol_term[1]
end
EBV_term = mme.output_X[term]*sol_term
if VERSION < v"1.6" && length(sol_term) == 1 #1-element Array{Float64,1} doesn't work below; Will be deleted
EBV_term = vec(EBV_term)
end
EBV += EBV_term
end
end
Expand Down

0 comments on commit 474f7db

Please sign in to comment.