Internals

Internal functions

Documentation for JWAS.jl's internal (private) interface, which are not available to general users. These internal functions are small blocks that public function build on.

Index

Internal interface

JWAS.add_genotypesMethod.
add_genotypes(mme::MME,file,G;separator=' ',header=true,center=true,G_is_marker_variance=false,df=4.0)
  • Get marker informtion from a genotype file (same order as the phenotype file).

  • G defaults to the genetic variance with degree of freedom df=4.0.

  • File format:

Animal,marker1,marker2,marker3,marker4,marker5
S1,1,0,1,1,1
D1,2,0,2,2,1
O1,1,2,0,1,0
O3,0,0,2,1,1
source
JWAS.add_markersMethod.
same to add_genotypes
source
JWAS.build_modelMethod.
build_model(model_equations::AbstractString,R;df::Float64=4.0)
  • Build models from model equations with residual varainces R and degree of freedom for residual variance df defaulting to 4.0.

  • By default, all variabels in model_equations are fixed and factors. Set variables to be covariates or random using functions set_covariate() or set_random().

#single-trait
model_equations = "BW = intercept + age + sex"
R               = 6.72
models          = build_model(model_equations,R);

#multi-trait
model_equations = "BW = intercept + age + sex
                   CW = intercept + litter";
R               = [6.72   24.84
                   24.84  708.41]
models          = build_model(model_equations,R);
source
JWAS.get_pedigreeMethod.
get_pedigree(pedfile::AbstractString;header=false,separator=' ')
  • Get pedigree informtion from a pedigree file.

  • File format:

a 0 0
b 0 0
c a b
d a c
source
outputMCMCsamples(mme::MME,trmStr::AbstractString...)

Get samples for specific variables.

source
JWAS.runMCMCMethod.
runMCMC(mme,df;Pi=0.0,estimatePi=false,chain_length=1000,starting_value=false,printout_frequency=100,missing_phenotypes=false,constraint=false,methods="conventional (no markers)",output_samples_frequency::Int64 = 0)

Run MCMC (marker information included or not) with sampling of variance components.

  • available methods include "conventional (no markers)", "BayesC0", "BayesC", "BayesCC","BayesB".

  • missing_phenotypes

  • Pi for single-trait analyses is a number; Pi for multi-trait analyses is a dictionary such as Pi=Dict([1.0; 1.0]=>0.7,[1.0; 0.0]=>0.1,[0.0; 1.0]=>0.1,[0.0; 0.0]=>0.1),

    • if Pi (Π) is not provided in multi-trait analysis, it will be generated assuming all markers have effects on all traits.

  • save MCMC samples every output_samples_frequency iterations

  • starting_value can be provided as a vector for all location parameteres except marker effects.

  • print out the monte carlo mean in REPL with printout_frequency

  • constraint=true if constrain residual covariances between traits to be zero.

source
JWAS.set_covariateMethod.
set_covariate(mme::MME,variables::AbstractString...)
  • set variables as covariates; mme is the output of function build_model().

#After running build_model, variabels age and year can be set to be covariates as
set_covariate(models,"age","year")
#or
set_covariate(models,"age year")
source
JWAS.set_randomMethod.
set_random(mme::MME,randomStr::AbstractString,G;df=4)
  • set variables as i.i.d random effects with variances G whose degree of freedom df defaults to 4.0.

#single-trait (example 1)
model_equation  = "y = intercept + litter + sex"
model           = build_model(model_equation,R)
G               = 0.6
set_random(model,"litter",G)

#multi-trait
model_equations = "BW = intercept + litter + sex
                   CW = intercept + litter + sex"
model           = build_model(model_equations,R);
G               = [3.72  1.84
                   1.84  3.41]
set_random(model,"litter",G)
source
JWAS.set_randomMethod.
set_random(mme::MME,randomStr::AbstractString,ped::Pedigree, G;df=4)
  • set variables as random polygenic effects with pedigree information ped, variances G whose degree of freedom df defaults to 4.0.

#single-trait (example 1)
model_equation  = "y = intercept + Age + Animal"
model           = build_model(model_equation,R)
ped             = get_pedigree(pedfile)
G               = 1.6
set_random(model,"Animal Animal*Age", ped,G)

#single-trait (example 2)
model_equation  = "y = intercept + Age + Animal + Animal*Age"
model           = build_model(model_equation,R)
ped             = get_pedigree(pedfile)
G               = [1.6   0.2
                   0.2  1.0]
set_random(model,"Animal Animal*Age", ped,G)

#multi-trait
model_equations = "BW = intercept + age + sex + Animal
                   CW = intercept + age + sex + Animal"
model           = build_model(model_equations,R);
ped             = get_pedigree(pedfile);
G               = [6.72   2.84
                   2.84  8.41]
set_random(model,"Animal", ped,G)
source
JWAS.showMMEMethod.
showMME(mme::MME,df::DataFrame)
  • Show left-hand side and right-hand side of mixed model equations (no markers).

source
JWAS.solveMethod.
solve(mme::MME,df::DataFrame;solver="default",printout_frequency=100,tolerance = 0.000001,maxiter = 5000)
  • Solve the mixed model equations (no marker information) without estimating variance components.

Available solvers includes default,Jacobi,GaussSeidel,Gibbs sampler.

source
JWAS.getMMEMethod.

Construct mixed model equations with

incidence matrix: X ; response : ySparse; left-hand side : mmeLhs ; right-hand side : mmeLhs ;

source