Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated RRM_new branch merged with up-to-date RRM master branch #100

Merged
merged 117 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
69042ae
modify build_MME() for partial connection
zhaotianjing Apr 8, 2021
83a4343
update zigui ford indication
justinwang97 Apr 13, 2021
af3e034
update zigui jwas
justinwang97 Apr 13, 2021
30235a9
zigui first commit
justinwang97 Apr 14, 2021
ddd95df
add the function that generate the indirect marker effect samples
justinwang97 Apr 14, 2021
27f4c3d
fix typos
justinwang97 Apr 14, 2021
6014306
Update example.jl
justinwang97 Apr 14, 2021
7b424b4
allow user-defined activation function
zhaotianjing Apr 14, 2021
c3c23c9
merge the sample generating function into runMCMC
justinwang97 Apr 16, 2021
739fcfc
Merge branch 'master' of https://github.com/justinwang97/JWAS.jl
justinwang97 Apr 16, 2021
d6c0ab5
remove "zigui"
justinwang97 Apr 16, 2021
267319b
add ForwardDiff dependency
zhaotianjing May 5, 2021
cad06b3
tanh to activation_function
zhaotianjing May 5, 2021
2160dd7
Merge branch 'BayesNN'ab to allow different activation function
reworkhow May 25, 2021
19c3a30
Update Project.toml
reworkhow May 25, 2021
b007364
Merge branch 'master' into BayesNN
zhaotianjing May 26, 2021
d54eaf7
fixed Project.toml
zhaotianjing May 26, 2021
17b6b92
debug RRM_new branch
Jiayi-Qu May 27, 2021
36038ec
make GBLUP work for repeated measures
reworkhow May 28, 2021
cfbda7f
add comments
reworkhow May 28, 2021
0993f2b
remove example.jl
justinwang97 May 31, 2021
31c463f
Merge branch 'SEM2' into master
reworkhow May 31, 2021
a7d2c81
Merge pull request #90 from justinwang97/master
reworkhow May 31, 2021
02697c4
update comments
reworkhow May 31, 2021
1d81729
update comments
reworkhow May 31, 2021
abd005f
Merge pull request #91 from reworkhow/SEM2
reworkhow May 31, 2021
65ceaca
update comments
reworkhow May 31, 2021
35c62b2
update comments
reworkhow May 31, 2021
380bfac
update SEM
reworkhow May 31, 2021
9a7983e
update tests
reworkhow May 31, 2021
c58fe33
update tests (remove GBLUP in deprecated add_genotypes)
reworkhow May 31, 2021
b6f0ca8
Merge branch 'master' into BayesNN
zhaotianjing Jun 1, 2021
2db73fd
allow dataframe for get_pedigree as the input
reworkhow Jun 2, 2021
4a2d8e7
Merge branch 'master' into BayesNN
zhaotianjing Jun 2, 2021
8500256
Update README.md
zhaotianjing Jun 4, 2021
5c573c6
Update README.md
zhaotianjing Jun 4, 2021
7abcd92
Update workflow.md
zhaotianjing Jun 8, 2021
6817c09
Update workflow.md
zhaotianjing Jun 8, 2021
b0f7fd0
Update workflow.md
reworkhow Jun 9, 2021
670693a
Merge branch 'master' into BayesNN
zhaotianjing Jun 14, 2021
89de4cc
write external functions to build model in NNBayes
zhaotianjing Jun 15, 2021
0a06bd8
allow dataframes as input for get_genotypes
reworkhow Jun 16, 2021
cb260ae
add error messages for non-numbers in data for covariate (continuous …
reworkhow Jun 17, 2021
082b76b
not allow single-precision for BayesB for coding ease
reworkhow Jun 17, 2021
e7ba1f8
support partial connected NN
zhaotianjing Jun 17, 2021
8c18dc1
trait_name to trait_names
zhaotianjing Jun 18, 2021
915c3d1
simplify EBV output for NNBayes-partial
zhaotianjing Jun 18, 2021
0405567
simplify code in build_MME for partial NNBayes
zhaotianjing Jun 18, 2021
4a76da2
modification
zhaotianjing Jun 18, 2021
b529ba8
Merge pull request #92 from reworkhow/BayesNN
reworkhow Jun 18, 2021
bb6e3b2
add new argument nnbayes_partial in build_MME
zhaotianjing Jun 20, 2021
9fe37e3
randomly split genotypes into 3 groups for partial nn
zhaotianjing Jun 20, 2021
c629ac2
upload image for wiki example
zhaotianjing Jun 20, 2021
3290992
set mega-trait=true as default in NNBayes
zhaotianjing Jun 21, 2021
49129d1
updated interface for nnbayes
zhaotianjing Jun 22, 2021
2b63238
update wiki figure
zhaotianjing Jun 22, 2021
96a5d3c
upload wiki figure
zhaotianjing Jun 22, 2021
8e8376e
incorrect to invalid
zhaotianjing Jun 22, 2021
f9bc82f
Merge pull request #93 from reworkhow/BayesNN
reworkhow Jun 22, 2021
fa11ba3
simplify argument name
zhaotianjing Jun 23, 2021
acbf186
simplify argument names
zhaotianjing Jun 23, 2021
d5e840b
update wiki figure
zhaotianjing Jun 23, 2021
8e52757
Merge pull request #94 from reworkhow/BayesNN
reworkhow Jun 23, 2021
ed5f21b
fix output format
zhaotianjing Jul 6, 2021
bfc633e
Update README.md
reworkhow Jul 6, 2021
d159be5
fixed the output file for function add_genotypes
zhaotianjing Jul 7, 2021
557b9b2
Merge pull request #95 from reworkhow/BayesNN
reworkhow Jul 8, 2021
323cf6d
update comments
reworkhow Jul 9, 2021
215f4cc
update comments
reworkhow Jul 13, 2021
09a06a0
update project.toml
reworkhow Jul 14, 2021
37d3cbd
update Project.toml
reworkhow Jul 14, 2021
d3ed715
fix a error in censored trait analysis when not all phenotypes are used
reworkhow Jul 15, 2021
290e5b9
fix a bug treating a vector as a 1 column matrix in GBLUP for categor…
reworkhow Jul 15, 2021
222eb4a
Update Project.toml
reworkhow Jul 15, 2021
824230a
update GWAS
reworkhow Jul 21, 2021
5c74aeb
update GWAS for window size
reworkhow Jul 21, 2021
01e3092
update Project.toml
reworkhow Jul 21, 2021
474f7db
update user-defined prediction equation
reworkhow Jul 22, 2021
ecb02aa
update prediction equation
reworkhow Jul 22, 2021
3a83e2e
Update Project.toml
reworkhow Jul 23, 2021
ab5c69c
update make_dataframe
reworkhow Jul 23, 2021
5fa7542
Update JWAS.jl
reworkhow Aug 24, 2021
03e5ba3
Update JWAS.jl
reworkhow Aug 26, 2021
cc530ad
update SEM
justinwang97 Aug 30, 2021
f6048ad
Merge pull request #96 from justinwang97/master
reworkhow Aug 31, 2021
634ce8d
fix a bug in matrix multiplication
reworkhow Aug 31, 2021
9f721b0
Update Project.toml
reworkhow Aug 31, 2021
7965641
allow intermediate omics data in neural networks
reworkhow Sep 1, 2021
f059c0d
add log
reworkhow Sep 1, 2021
fab847e
add log
reworkhow Sep 1, 2021
6a25115
set starting value of missing omics data as elements in yobs
zhaotianjing Sep 7, 2021
b46e356
add @time to debug out of mem
zhaotianjing Sep 7, 2021
e481971
try to debug
zhaotianjing Sep 7, 2021
8502c29
test
zhaotianjing Sep 8, 2021
4dead95
multi-threaded parallel
zhaotianjing Sep 8, 2021
e0e9bc0
print info for parallel single traits
zhaotianjing Sep 8, 2021
1cc9d0d
Update README.md
reworkhow Sep 8, 2021
6715c37
change parallel to multithread
zhaotianjing Sep 9, 2021
5120cf3
update doc
reworkhow Sep 10, 2021
38623f4
update rng for multithread
zhaotianjing Sep 11, 2021
b3043ab
support multithread for bayesl and rrblup
zhaotianjing Sep 11, 2021
45e05a9
minor update
zhaotianjing Sep 13, 2021
1cac6a2
update Ri for multiple single trait
zhaotianjing Sep 13, 2021
654c315
make multi-thread as default
zhaotianjing Sep 13, 2021
67bdb60
minor format update
zhaotianjing Sep 13, 2021
17fcd84
Merge pull request #99 from reworkhow/omics
reworkhow Sep 13, 2021
df2dda3
Update README.md
reworkhow Sep 14, 2021
95c91f2
update
Jiayi-Qu Sep 14, 2021
615c0cf
change conflict file with master
Jiayi-Qu Sep 14, 2021
bab6be8
updated
Jiayi-Qu Sep 14, 2021
0ce107e
updated
Jiayi-Qu Sep 14, 2021
8c7d7f1
updated
Jiayi-Qu Sep 14, 2021
7101eb9
update calculating Hi in SSGBLUP
reworkhow Sep 17, 2021
e9b0a68
allow saving local EBV for each window
reworkhow Sep 17, 2021
4455412
Merge branch 'master' into RRM_new
Jiayi-Qu Sep 23, 2021
6055a3d
updated RRM_new branch
Jiayi-Qu Sep 23, 2021
2f8358d
RR test with whole data
Jiayi-Qu Feb 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
435 changes: 435 additions & 0 deletions Manifest.toml

Large diffs are not rendered by default.

19 changes: 11 additions & 8 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
name = "JWAS"
uuid = "c9a035f4-d403-5e6b-8649-6be755bc4798"
version = "0.13.0"
authors = ["Hao Cheng <qtlcheng@ucdavis.edu>"]
version = "0.14.4"

[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
CSV = "0.5, 0.6, 0.7, 0.8"
DataFrames = "0.19, 0.20, 0.21, 0.22"
Distributions = "0.21, 0.22, 0.23, 0.24"
ForwardDiff = "0.10"
ProgressMeter = "1.0, 1.1, 1.2"
CSV = "0.5, 0.6, 0.7, 0.8"
StatsBase = "0.30, 0.31, 0.32, 0.33"
julia = "1"
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# JWAS.jl

[![Build Status](https://travis-ci.org/reworkhow/JWAS.jl.svg?branch=master)](https://travis-ci.org/reworkhow/JWAS.jl)
[![Build Status](https://travis-ci.com/reworkhow/JWAS.jl.svg?branch=master)](https://travis-ci.org/reworkhow/JWAS.jl)
[![](https://img.shields.io/badge/docs-latest-blue.svg)](https://reworkhow.github.io/JWAS.jl/latest)
<!---[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://reworkhow.github.io/JWAS.jl/stable)--->

Expand Down Expand Up @@ -37,3 +37,21 @@ JWAS.jl
1. Show this README file in REPL or notebook using `?JWAS`
2. For help on a specific function above, type ? followed by its name, e.g. `?runMCMC` and press enter.
3. Run `Pkg.add(PackageSpec(name="JWAS", rev="master"))` to get the newest unofficial JWAS. Run `Pkg.free("JWAS")` to go back to the official one.

### Examples [available here](https://github.com/reworkhow/JWAS.jl/wiki)

* Single Trait Analysis
* Multiple Trait Analysis
* Repeated Measures
* Single Step Analysis
* Categorical Trait Analysis
* Censored Trait Analysis
* Multi-class Bayesian Analysis
* Neural Networks
* Cross Validation
* Genome Wide Association Study
* Integrating Phenotypic Causal Networks in GWAS
* single trait and multiple trait GBLUP by providing the relationship matrix directly
* Description of Mixed Effects Model
* Quality Control of Genotypes

17 changes: 17 additions & 0 deletions docs/src/log.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#allow intermediate omics data in neural networks (8/31/2021)

1. add an argument "latent_traits" in build_model() to allow users to provide
which columns in the phenotypic data will be used as the observed values for
intermediate traits. Add latent_traits as a member in the struct mme.

2. Because multi-trait models with latent traits as responses will be used in neural
network (between input layer and hidden layer), we reassign column names of latent
traits to mme.lhsVec, which will be used to make the matrices in the multi-trait models.
In this case, we still need a variable to save the (empirical) phenotypes (i.e., output),
so mme.yobs is made to save it. Add yobs as a member in the struct mme.

3. mme.ySparse is used to same values for latent traits. In intermediate omics data,
because some/many elements in mme.ySparse are observed, only missing values in mme.ySparse
are sampled.

# add neural network
47 changes: 40 additions & 7 deletions docs/src/manual/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Several steps above can be skipped if no related information is available, e.g.,

## check results

Posterior means and standard deviations of location parameters, most variance components, and marker effects are saved as the variable `out` and in text files.
Posterior means (estimate) and standard deviations (SD) of location parameters, most variance components, and marker effects are saved as the variable `out` and in text files.
They can be listed and obtained as
```julia
keys(out)
Expand Down Expand Up @@ -316,9 +316,42 @@ out["residual variance"]

```

MCMC samples for marker effects, location parameters specified in step 7, and all variance components are saved to text
files in your working directory. They can be obtained as

```julia
res=readdlm("MCMC_samples_marker_effects_y1.txt",',',header=true)
```
In addition, MCMC samples from posterior distributions of marker effects, all variance components, and location parameters specified in step 7, are saved to text
files in your working directory. Users can compute the posterior distributions of parameters of interest using these MCMC samples files. A list of output files are shown below.

### Output files:

Below is a list of files containing estimates and standard deviations for variables of interest.

| file name | description |
| ----------- | ----------- |
| EBV_y1.txt | estimated breeding values for trait named "y1" |
| EBV_y2.txt | estimated breeding values for trait named "y2" |
| EBV_y3.txt | estimated breeding values for trait named "y3" |
|genetic_variance.txt | estimated genetic variance-covariance for all traits |
|heritability.txt | estimated heritability |
|location_parameters.txt | estimated non-genetic effects |
|pi_genotypes.txt | estimated pi |
|polygenic_effects_covariance_matrix.txt| estimated variance-covariance between polygenic effects (y1_ID, y2_ID, y3_ID, y1_dam)|
|marker_effects_genotypes.txt | estimated marker effects for all traits |
|residual_variance.txt | estimated residual variance-covariance for all traits|

Below is a list of files containing MCMC samples for variables of interest.

| file name | description |
| ----------- | ----------- |
| MCMC_samples_EBV_y1.txt | MCMC samples from the posterior distribution of breeding values for trait named "y1" |
| MCMC_samples_EBV_y2.txt | MCMC samples from the posterior distribution of breeding values for trait named "y2" |
| MCMC_samples_EBV_y3.txt | MCMC samples from the posterior distribution of breeding values for trait named "y3" |
|MCMC_samples_genetic_variance.txt | MCMC samples from the posterior distribution of genetic variance-covariance for all traits |
|MCMC_samples_heritability.txt | MCMC samples from the posterior distribution of heritability |
|MCMC_samples_marker_effects_genotypes_y1 |MCMC samples from the posterior distribution of marker effects for trait named "y1" |
|MCMC_samples_marker_effects_genotypes_y2 |MCMC samples from the posterior distribution of marker effects for trait named "y2" |
|MCMC_samples_marker_effects_genotypes_y3 |MCMC samples from the posterior distribution of marker effects for trait named "y3" |
|MCMC_samples_marker_effects_variances_genotypes.txt | MCMC samples from the posterior distribution of marker effect variance for all traits |
|MCMC_samples_pi_genotypes.txt | MCMC samples from the posterior distribution of pi |
|MCMC_samples_polygenic_effects_variance.txt | MCMC samples from the posterior distribution of variance-covariance between y1_ID, y2_ID, y3_ID, y1_dam|
|MCMC_samples_residual_variance.txt | MCMC samples from the posterior distribution of residual variance-covariance for all traits |
|MCMC_samples_y1.dam.txt | MCMC samples from the posterior distribution of dam effect for y1|
|MCMC_samples_y1.ID_y2.ID_y3.ID_y1.dam_variances.txt | MCMC samples from the posterior distribution of variance-covariance between y1_ID, y2_ID, y3_ID, y1_dam|
|MCMC_samples_y2.x2_y3.x2_variances.txt | MCMC samples from the posterior distribution of variance-covariance between y2_x2 and y3_x2|
103 changes: 65 additions & 38 deletions src/1.JWAS/src/JWAS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ using SparseArrays
using LinearAlgebra
using ProgressMeter
using .PedModule
using ForwardDiff

import StatsBase: describe #a new describe is exported

Expand Down Expand Up @@ -48,6 +49,7 @@ include("structure_equation_model/SEM.jl")
#Latent Traits
include("Nonlinear/nonlinear.jl")
include("Nonlinear/bnn_hmc.jl")
include("Nonlinear/nnbayes_check.jl")

#input
include("input_data_validation.jl")
Expand Down Expand Up @@ -139,10 +141,10 @@ export dataset
* Censored traits are allowed if the upper bounds are provided in `censored_trait` as an array, and lower bounds are provided as phenotypes.
* If `constraint`=true, defaulting to `false`, constrain residual covariances between traits to be zeros.
* 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, phenotypic causal networks will be incorporated using structure equation models.
trait 1 -> trait 2 and trait 1 -> trait 3 (column index affacts row index, and a lower triangular matrix is required), 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".
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`.
* Predicted values for individuals of interest can be obtained based on a 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 pedigree 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.
* Miscellaneous Options
Expand All @@ -168,10 +170,10 @@ function runMCMC(mme::MME,df;
categorical_trait = false,
censored_trait = false,
causal_structure = false,
mega_trait = false,
RRM = false,
mega_trait = mme.nonlinear_function == false ? false : true, #NNBayes -> default mega_trait=true
missing_phenotypes = true,
constraint = false,
RRM = false,
#Genomic Prediction
outputEBV = true,
output_heritability = true,
Expand All @@ -191,9 +193,11 @@ function runMCMC(mme::MME,df;
estimatePi = false,
estimateScale = false)

#Nonlinear
if mme.latent_traits == true
yobs = df[!,Symbol(string(Symbol(mme.lhsVec[1]))[1:(end-1)])]

#Neural Network
is_nnbayes_partial = (mme.nonlinear_function != false && mme.is_fully_connected==false)
if mme.nonlinear_function != false #modify data to add phenotypes for hidden nodes
yobs = df[!,Symbol(string(Symbol(mme.lhsVec[1]))[1:(end-1)])]#a number label is added to original trait name in nnbayes_model_equation()
for i in mme.lhsVec
df[!,i]= yobs
end
Expand All @@ -216,6 +220,13 @@ function runMCMC(mme::MME,df;
if seed != false
Random.seed!(seed)
end
#when using multi-thread, make sure the results are reproducible for users
nThread = Threads.nthreads()
if nThread>1
Threads.@threads for i = 1:nThread
Random.seed!(seed+i)
end
end
############################################################################
# Create an folder to save outputs
############################################################################
Expand Down Expand Up @@ -270,14 +281,11 @@ function runMCMC(mme::MME,df;
mme.causal_structure = causal_structure
if causal_structure != false
#no missing phenotypes and residual covariance for identifiability
missing_phenotypes, constraint = false, true
mme.MCMCinfo.missing_phenotypes, mme.MCMCinfo.constraint = false, true
if !istril(causal_structure)
error("The causal structue needs to be a lower triangular matrix.")
end
end



# Double Precision
if double_precision == true
if mme.M != 0
Expand All @@ -295,21 +303,19 @@ function runMCMC(mme::MME,df;
end
mme.Gi = map(Float64,mme.Gi)
end
#mega_trait
if mme.MCMCinfo.mega_trait == true || mme.MCMCinfo.constraint == true
if mme.nModels == 1
error("more than 1 trait is required for MegaLMM analysis.")
end
mme.MCMCinfo.constraint = true
##sample from scale-inv-⁠χ2, not InverseWishart
mme.df.residual = mme.df.residual - mme.nModels
mme.scaleR = diag(mme.scaleR/(mme.df.residual - 1))*(mme.df.residual-2)/mme.df.residual #diag(R_prior_mean)*(ν-2)/ν
if mme.M != 0
for Mi in mme.M
Mi.df = Mi.df - mme.nModels
Mi.scale = diag(Mi.scale/(Mi.df - 1))*(Mi.df-2)/Mi.df
end
end

# NNBayes mega trait: from multi-trait to multiple single-trait
if mme.MCMCinfo.mega_trait == true
printstyled(" - Bayesian Alphabet: multiple independent single-trait Bayesian models are used to sample marker effect. \n",bold=false,color=:green)
printstyled(" - Multi-threaded parallelism: $nThread threads are used to run single-trait models in parallel. \n",bold=false,color=:green)
nnbayes_mega_trait(mme)
elseif mme.nonlinear_function != false #only print for NNBayes
printstyled(" - Bayesian Alphabet: multi-trait Bayesian models are used to sample marker effect. \n",bold=false,color=:green)
end

# NNBayes: modify parameters for partial connected NN
if is_nnbayes_partial
nnbayes_partial_para_modify2(mme)
end
############################################################################
#Make incidence matrices and genotype covariates for training observations
Expand All @@ -328,18 +334,15 @@ function runMCMC(mme::MME,df;
############################################################################
describe(mme)
if mme.nModels ==1 && RRM != false
mme.output=MCMC_BayesianAlphabet_RRM(chain_length,mme,df,
mme.output=MCMC_BayesianAlphabet_RRM(mme,df,
Φ = RRM,
Pi = Pi,
burnin = burnin,
methods = methods,
estimatePi = estimatePi,
estimateScale = estimateScale,
starting_value = mme.MCMCinfo.starting_value,
starting_value = mme.sol,
outFreq = printout_frequency,
output_samples_frequency = output_samples_frequency,
output_file = output_samples_file,
update_priors_frequency = update_priors_frequency)
nIter = chain_length,
output_folder = mme.MCMCinfo.output_folder)
else
mme.output=MCMC_BayesianAlphabet(mme,df)
end
Expand All @@ -362,7 +365,22 @@ function runMCMC(mme::MME,df;
versioninfo()
printstyled("\n\nThe analysis has finished. Results are saved in the returned ",bold=true)
printstyled("variable and text files. MCMC samples are saved in text files.\n\n\n",bold=true)

# make MCMC samples for indirect marker effect
if causal_structure != false

#generate the MCMC sample file for indirect and direct effect file.
generate_indirect_marker_effect_sample(mme.lhsVec,output_folder,causal_structure,"structure_coefficient_MCMC_samples.txt")
generate_overall_marker_effect_sample(mme.lhsVec,output_folder,causal_structure)

# generate marker effet file for direct, indirect, and overall effect
generate_marker_effect(mme.lhsVec, output_folder,causal_structure,"direct")
generate_marker_effect(mme.lhsVec, output_folder,causal_structure,"indirect")
generate_marker_effect(mme.lhsVec, output_folder,causal_structure,"overall")
end

return mme.output

end
################################################################################
# Print out Model or MCMC information
Expand Down Expand Up @@ -429,6 +447,7 @@ end
* (internal function) Print out MCMC information.
"""
function getMCMCinfo(mme)
is_nnbayes_partial = mme.nonlinear_function != false && mme.is_fully_connected==false
if mme.MCMCinfo == false
printstyled("MCMC information is not available\n\n",bold=true)
return
Expand Down Expand Up @@ -479,18 +498,26 @@ function getMCMCinfo(mme)
@printf("%-30s %20s\n","Method",Mi.method)
for Mi in mme.M
if Mi.genetic_variance != false
if mme.nModels == 1
if mme.nModels == 1 && mme.MCMCinfo.RRM == false || is_nnbayes_partial
@printf("%-30s %20.3f\n","genetic variances (genomic):",Mi.genetic_variance)
else
elseif mme.nModels==1 && mme.MCMCinfo.RRM != false
@printf("%-30s\n","genetic variances (genomic):")
Base.print_matrix(stdout,round.(Mi.genetic_variance,digits=3))
println()
elseif mme.nModels>1
@printf("%-30s\n","genetic variances (genomic):")
Base.print_matrix(stdout,round.(Mi.genetic_variance,digits=3))
println()
end
end
if !(Mi.method in ["GBLUP"])
if mme.nModels == 1
if mme.nModels == 1 && mme.MCMCinfo.RRM == false || is_nnbayes_partial
@printf("%-30s %20.3f\n","marker effect variances:",Mi.G)
else
elseif mme.nModels==1 && mme.MCMCinfo.RRM != false
@printf("%-30s\n","marker effect variances:")
Base.print_matrix(stdout,round.(Mi.G,digits=3))
println()
elseif mme.nModels>1
@printf("%-30s\n","marker effect variances:")
Base.print_matrix(stdout,round.(Mi.G,digits=3))
println()
Expand Down
Loading