Skip to content

Commit

Permalink
will need to start visialisation of output via Rshiny
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffersonfparil committed Jun 9, 2024
1 parent 789441d commit f252478
Show file tree
Hide file tree
Showing 17 changed files with 43 additions and 35 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.github/
.vscode/
exec/
_libs/
shell.nix
36 changes: 17 additions & 19 deletions R/models.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ suppressWarnings(suppressPackageStartupMessages(library(sommer)))
#' + $n_non_zero: number of non-zero estimated effects (effects greater than machine epsilon ~2.2e-16)
#' - Err: gpError
#' @examples
#' list_sim = fn_simulate_data(n_pop=3, verbose=TRUE)
#' list_sim = fn_simulate_data(verbose=TRUE)
#' G = fn_load_genotype(fname_geno=list_sim$fname_geno_vcf)
#' list_pheno = fn_load_phenotype(fname_pheno=list_sim$fname_pheno_tsv)
#' list_merged = fn_merge_genotype_and_phenotype(G=G, list_pheno=list_pheno, verbose=TRUE)
Expand All @@ -65,7 +65,7 @@ suppressWarnings(suppressPackageStartupMessages(library(sommer)))
fn_ols = function(list_merged, vec_idx_training, vec_idx_validation, other_params=list(diag_inflate=1e-4), verbose=FALSE) {
###################################################
### TEST
# list_sim = fn_simulate_data(n_pop=3, verbose=TRUE)
# list_sim = fn_simulate_data(verbose=TRUE)
# G = fn_load_genotype(fname_geno=list_sim$fname_geno_vcf)
# list_pheno = fn_load_phenotype(fname_pheno=list_sim$fname_pheno_tsv)
# COVAR = G %*% t(G); # rownames(COVAR) = NULL
Expand Down Expand Up @@ -226,7 +226,7 @@ fn_ols = function(list_merged, vec_idx_training, vec_idx_validation, other_param
#' + $n_non_zero: number of non-zero estimated effects (effects greater than machine epsilon ~2.2e-16)
#' - Err: gpError
#' @examples
#' list_sim = fn_simulate_data(n_pop=3, verbose=TRUE)
#' list_sim = fn_simulate_data(verbose=TRUE)
#' G = fn_load_genotype(fname_geno=list_sim$fname_geno_vcf)
#' list_pheno = fn_load_phenotype(fname_pheno=list_sim$fname_pheno_tsv)
#' list_merged = fn_merge_genotype_and_phenotype(G=G, list_pheno=list_pheno, verbose=TRUE)
Expand All @@ -238,7 +238,7 @@ fn_ols = function(list_merged, vec_idx_training, vec_idx_validation, other_param
fn_ridge = function(list_merged, vec_idx_training, vec_idx_validation, other_params=list(n_folds=10), verbose=FALSE) {
###################################################
### TEST
# list_sim = fn_simulate_data(n_pop=3, verbose=TRUE)
# list_sim = fn_simulate_data(verbose=TRUE)
# G = fn_load_genotype(fname_geno=list_sim$fname_geno_vcf)
# list_pheno = fn_load_phenotype(fname_pheno=list_sim$fname_pheno_tsv)
# COVAR = G %*% t(G); # rownames(COVAR) = NULL
Expand Down Expand Up @@ -370,7 +370,7 @@ fn_ridge = function(list_merged, vec_idx_training, vec_idx_validation, other_par
#' + $n_non_zero: number of non-zero estimated effects (effects greater than machine epsilon ~2.2e-16)
#' - Err: gpError
#' @examples
#' list_sim = fn_simulate_data(n_pop=3, verbose=TRUE)
#' list_sim = fn_simulate_data(verbose=TRUE)
#' G = fn_load_genotype(fname_geno=list_sim$fname_geno_vcf)
#' list_pheno = fn_load_phenotype(fname_pheno=list_sim$fname_pheno_tsv)
#' list_merged = fn_merge_genotype_and_phenotype(G=G, list_pheno=list_pheno, verbose=TRUE)
Expand All @@ -382,7 +382,7 @@ fn_ridge = function(list_merged, vec_idx_training, vec_idx_validation, other_par
fn_lasso = function(list_merged, vec_idx_training, vec_idx_validation, other_params=list(n_folds=10), verbose=FALSE) {
###################################################
### TEST
# list_sim = fn_simulate_data(n_pop=3, verbose=TRUE)
# list_sim = fn_simulate_data(verbose=TRUE)
# G = fn_load_genotype(fname_geno=list_sim$fname_geno_vcf)
# list_pheno = fn_load_phenotype(fname_pheno=list_sim$fname_pheno_tsv)
# COVAR = G %*% t(G); # rownames(COVAR) = NULL
Expand Down Expand Up @@ -514,7 +514,7 @@ fn_lasso = function(list_merged, vec_idx_training, vec_idx_validation, other_par
#' + $n_non_zero: number of non-zero estimated effects (effects greater than machine epsilon ~2.2e-16)
#' - Err: gpError
#' @examples
#' list_sim = fn_simulate_data(n_pop=3, verbose=TRUE)
#' list_sim = fn_simulate_data(verbose=TRUE)
#' G = fn_load_genotype(fname_geno=list_sim$fname_geno_vcf)
#' list_pheno = fn_load_phenotype(fname_pheno=list_sim$fname_pheno_tsv)
#' list_merged = fn_merge_genotype_and_phenotype(G=G, list_pheno=list_pheno, verbose=TRUE)
Expand All @@ -526,7 +526,7 @@ fn_lasso = function(list_merged, vec_idx_training, vec_idx_validation, other_par
fn_elastic_net = function(list_merged, vec_idx_training, vec_idx_validation, other_params=list(n_folds=10), verbose=FALSE) {
###################################################
### TEST
# list_sim = fn_simulate_data(n_pop=3, verbose=TRUE)
# list_sim = fn_simulate_data(verbose=TRUE)
# G = fn_load_genotype(fname_geno=list_sim$fname_geno_vcf)
# list_pheno = fn_load_phenotype(fname_pheno=list_sim$fname_pheno_tsv)
# COVAR = G %*% t(G); # rownames(COVAR) = NULL
Expand Down Expand Up @@ -660,7 +660,7 @@ fn_elastic_net = function(list_merged, vec_idx_training, vec_idx_validation, oth
#' + $n_non_zero: number of non-zero estimated effects (effects greater than machine epsilon ~2.2e-16)
#' - Err: gpError
#' @examples
#' list_sim = fn_simulate_data(n_pop=3, verbose=TRUE)
#' list_sim = fn_simulate_data(verbose=TRUE)
#' G = fn_load_genotype(fname_geno=list_sim$fname_geno_vcf)
#' list_pheno = fn_load_phenotype(fname_pheno=list_sim$fname_pheno_tsv)
#' list_merged = fn_merge_genotype_and_phenotype(G=G, list_pheno=list_pheno, verbose=TRUE)
Expand All @@ -673,7 +673,7 @@ fn_Bayes_A = function(list_merged, vec_idx_training, vec_idx_validation,
other_params=list(nIter=12e3, burnIn=2e3, out_prefix="bglr_bayesA-"), verbose=FALSE) {
###################################################
### TEST
# list_sim = fn_simulate_data(n_pop=3, verbose=TRUE)
# list_sim = fn_simulate_data(verbose=TRUE)
# G = fn_load_genotype(fname_geno=list_sim$fname_geno_vcf)
# list_pheno = fn_load_phenotype(fname_pheno=list_sim$fname_pheno_tsv)
# COVAR = G %*% t(G); # rownames(COVAR) = NULL
Expand Down Expand Up @@ -802,7 +802,7 @@ fn_Bayes_A = function(list_merged, vec_idx_training, vec_idx_validation,
#' + $n_non_zero: number of non-zero estimated effects (effects greater than machine epsilon ~2.2e-16)
#' - Err: gpError
#' @examples
#' list_sim = fn_simulate_data(n_pop=3, verbose=TRUE)
#' list_sim = fn_simulate_data(verbose=TRUE)
#' G = fn_load_genotype(fname_geno=list_sim$fname_geno_vcf)
#' list_pheno = fn_load_phenotype(fname_pheno=list_sim$fname_pheno_tsv)
#' list_merged = fn_merge_genotype_and_phenotype(G=G, list_pheno=list_pheno, verbose=TRUE)
Expand All @@ -815,7 +815,7 @@ fn_Bayes_B = function(list_merged, vec_idx_training, vec_idx_validation,
other_params=list(nIter=12e3, burnIn=2e3, out_prefix="bglr_bayesB-"), verbose=FALSE) {
###################################################
### TEST
# list_sim = fn_simulate_data(n_pop=3, verbose=TRUE)
# list_sim = fn_simulate_data(verbose=TRUE)
# G = fn_load_genotype(fname_geno=list_sim$fname_geno_vcf)
# list_pheno = fn_load_phenotype(fname_pheno=list_sim$fname_pheno_tsv)
# COVAR = G %*% t(G); # rownames(COVAR) = NULL
Expand Down Expand Up @@ -944,7 +944,7 @@ fn_Bayes_B = function(list_merged, vec_idx_training, vec_idx_validation,
#' + $n_non_zero: number of non-zero estimated effects (effects greater than machine epsilon ~2.2e-16)
#' - Err: gpError
#' @examples
#' list_sim = fn_simulate_data(n_pop=3, verbose=TRUE)
#' list_sim = fn_simulate_data(verbose=TRUE)
#' G = fn_load_genotype(fname_geno=list_sim$fname_geno_vcf)
#' list_pheno = fn_load_phenotype(fname_pheno=list_sim$fname_pheno_tsv)
#' list_merged = fn_merge_genotype_and_phenotype(G=G, list_pheno=list_pheno, verbose=TRUE)
Expand All @@ -957,7 +957,7 @@ fn_Bayes_C = function(list_merged, vec_idx_training, vec_idx_validation,
other_params=list(nIter=12e3, burnIn=2e3, out_prefix="bglr_bayesC-"), verbose=FALSE) {
###################################################
### TEST
# list_sim = fn_simulate_data(n_pop=3, verbose=TRUE)
# list_sim = fn_simulate_data(verbose=TRUE)
# G = fn_load_genotype(fname_geno=list_sim$fname_geno_vcf)
# list_pheno = fn_load_phenotype(fname_pheno=list_sim$fname_pheno_tsv)
# COVAR = G %*% t(G); # rownames(COVAR) = NULL
Expand Down Expand Up @@ -1085,7 +1085,7 @@ fn_Bayes_C = function(list_merged, vec_idx_training, vec_idx_validation,
#' effects (effects greater than machine epsilon ~2.2e-16)
#' - Err: gpError
#' @examples
#' list_sim = fn_simulate_data(n_pop=3, verbose=TRUE)
#' list_sim = fn_simulate_data(verbose=TRUE)
#' G = fn_load_genotype(fname_geno=list_sim$fname_geno_vcf)
#' list_pheno = fn_load_phenotype(fname_pheno=list_sim$fname_pheno_tsv)
#' list_merged = fn_merge_genotype_and_phenotype(G=G, list_pheno=list_pheno, verbose=TRUE)
Expand All @@ -1097,7 +1097,7 @@ fn_Bayes_C = function(list_merged, vec_idx_training, vec_idx_validation,
fn_gBLUP = function(list_merged, vec_idx_training, vec_idx_validation, other_params=list(), verbose=FALSE) {
###################################################
### TEST
# list_sim = fn_simulate_data(n_pop=3, verbose=TRUE)
# list_sim = fn_simulate_data(verbose=TRUE)
# G = fn_load_genotype(fname_geno=list_sim$fname_geno_vcf)
# list_pheno = fn_load_phenotype(fname_pheno=list_sim$fname_pheno_tsv)
# COVAR = G %*% t(G); # rownames(COVAR) = NULL
Expand Down Expand Up @@ -1156,10 +1156,8 @@ fn_gBLUP = function(list_merged, vec_idx_training, vec_idx_validation, other_par
covariates_string = paste(paste0("covariate_", 1:ncol(X)), collapse="+")
eval(parse(text=paste0("mod = sommer::mmer(y ~ 1 + ", covariates_string, ", random= ~vsr(id, Gu=A ), rcov= ~vsr(units), data=df_training, dateWarning=FALSE, verbose=FALSE)")))
} else {
mod = sommer::mmer(y ~ 1, random= ~vsr(id, Gu=A ), rcov= ~vsr(units), data=df_training, dateWarning=FALSE, verbose=FALSE)
mod = sommer::mmer(y ~ 1, random= ~vsr(id, Gu=A), rcov= ~vsr(units), data=df_training, dateWarning=FALSE, verbose=FALSE)
}


### Extract effects
b_hat = mod$Beta$Estimate; names(b_hat) = mod$Beta$Effect
u_hat = mod$U$`u:id`$y
Expand Down
2 changes: 1 addition & 1 deletion man/fn_Bayes_A.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/fn_Bayes_B.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/fn_Bayes_C.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/fn_cross_validation_across_populations_bulk.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/fn_cross_validation_across_populations_lopo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/fn_cross_validation_across_populations_pairwise.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/fn_cross_validation_within_population.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/fn_cv_1.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/fn_elastic_net.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/fn_gBLUP.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/fn_lasso.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/fn_ols.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/fn_ridge.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions man/gp.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f252478

Please sign in to comment.