aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlexander_Kabui2024-11-11 16:41:18 +0300
committerAlexander_Kabui2024-11-11 16:42:44 +0300
commitc4f5f3dba5a22a625cba88246efa45c8bc4ddf2c (patch)
tree2ab4dda546de7ba9c1621403406f7d89c1e9f902 /scripts
parent9d0cda2c1dc386cdc79505b34dacbeb164afa765 (diff)
downloadgenenetwork3-c4f5f3dba5a22a625cba88246efa45c8bc4ddf2c.tar.gz
feat: add step to insert pseudomarkers to the gmap.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/rqtl2_wrapper.R31
1 files changed, 18 insertions, 13 deletions
diff --git a/scripts/rqtl2_wrapper.R b/scripts/rqtl2_wrapper.R
index 4355769..1ff3e18 100644
--- a/scripts/rqtl2_wrapper.R
+++ b/scripts/rqtl2_wrapper.R
@@ -1,13 +1,12 @@
-# This script file contains the an implementation of qtl mapping using r-qtl2
-# For r-qtl1 implementation see: Scripts/rqtl_wrapper.R
-# load the library
+# This file contains an implementation of qtl mapping using r-qtl2
+# For r-qtl1 implementation see: ./rqtl_wrapper.R
library(qtl2)
library(rjson)
-
library(stringi)
library(optparse)
+# TODO add mapping function as a parameter:
option_list <- list(
make_option(c("-d", "--directory"), action = "store", default = NULL, type = "character", help="Temporary working directory: should also host the input file ."),
@@ -61,6 +60,7 @@ genRandomFileName <- function(prefix, string_size = 9 , file_ext = ".txt") {
# Step: Generate the control file name
+
control_file_path <- file.path(opt$directory,
genRandomFileName(prefix = "control", file_ext = ".json"))
cat("Generated the control file path at ", control_file_path, "\n")
@@ -159,7 +159,6 @@ perform_genetic_pr <- function(cross,
cores = NO_OF_CORES,
step=1,
map=NULL,
- use_pseudomarkers=FALSE,
map_function=c("haldane", "kosambi", "c-f", "morgan"),
error_prob = 0.002
) {
@@ -173,19 +172,23 @@ perform_genetic_pr <- function(cross,
#' @param step for default "1"
#' @return a list of three-dimensional arrays of probabilities, individuals x genotypes x pst
-
- if (use_pseudomarkers){
- cat("Using pseudo markers for genetic probabilites\n")
- map <- insert_pseudomarkers(cross$gmap, step=step)
- }
return(calc_genoprob(cross, map=map,
error_prob=error_prob, map_function=map_function,
quiet=FALSE, cores=cores))
}
+
+#Step: insert pseudomarkers to genetic map
+# TODO need to review this to match rqtl1
+cat("Inserting pseudomarkers to the genetic map with steps", 1 , "and stepwidth" , "fixed\n")
+MAP <- insert_pseudomarkers(cross$gmap, step= 1, stepwidth = "fixed", cores = NO_OF_CORES)
+
+
# Step: calculate the genetic probabilities
cat("Calculating the genetic probabilities\n")
-Pr = perform_genetic_pr(cross)
+Pr = perform_genetic_pr(cross, map = MAP)
+
+
# Step: perform allele probabilites if cross ways
@@ -207,14 +210,16 @@ error_lod <- do.call("cbind", error_lod)
# TODO rework on this
cat("Getting the phenotypes and covariates\n")
pheno <- cross$pheno
-
covar <- match(cross$covar$sex, c("f", "m")) # make numeric
+covar
if (!is.null(covar)){
names(covar) <- rownames(cross$covar)
+
}
print("The covariates are")
-print(covar)
+covar
+
Xcovar <- get_x_covar(cross)
print("The Xcovar are ")
print(Xcovar)