From 12a926648dcb3a77bdd5eae25be0670945d1b6cb Mon Sep 17 00:00:00 2001 From: Karl Broman Date: Fri, 28 Oct 2022 14:58:34 -0500 Subject: [PATCH 1/6] genoprob_to_snpprob: revise to work with DOF1 and HSF1 - Fixes Issue #140 (I thin) --- R/snpprob_from_cross.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/R/snpprob_from_cross.R b/R/snpprob_from_cross.R index 9cb95f85..67379df1 100644 --- a/R/snpprob_from_cross.R +++ b/R/snpprob_from_cross.R @@ -25,6 +25,10 @@ snpprob_from_cross <- map <- cross$pmap if(is.null(map)) map <- cross$gmap + if(cross$crosstype %in% c("hsf1", "dof1")) { # if HSF1 or DOF1, drop last founder + cross$founder_geno <- cross$founder_geno[,-ncol(cross$founder_geno)] + } + sdp <- calc_sdp(t(do.call("cbind", cross$founder_geno))) snpinfo <- data.frame(chr=rep(chr_names(cross), n_mar(cross)), From f3e3b5f68bbb47d186cf896b1918aadbaa076cf3 Mon Sep 17 00:00:00 2001 From: Karl Broman Date: Fri, 28 Oct 2022 15:00:59 -0500 Subject: [PATCH 2/6] Revise calc_genoprob() treatment of X chr in DOF1 and HSF1 - Just keep track of the allele on the DO/HS derived X chr - Assume males had the DO/HS parent as the mother --- DESCRIPTION | 4 +-- NEWS.md | 13 ++++++- src/cross_dof1.cpp | 87 ++++++++++++---------------------------------- src/cross_hsf1.cpp | 86 ++++++++++++--------------------------------- 4 files changed, 59 insertions(+), 131 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 23547790..e40ba050 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: qtl2 -Version: 0.29-5 -Date: 2022-10-25 +Version: 0.29-6 +Date: 2022-10-28 Title: Quantitative Trait Locus Mapping in Experimental Crosses Description: Provides a set of tools to perform quantitative trait locus (QTL) analysis in experimental crosses. It is a diff --git a/NEWS.md b/NEWS.md index 0c8c4697..739fb5bd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,9 +1,20 @@ -## qtl2 0.29-5 (2022-10-25) +## qtl2 0.29-6 (2022-10-28) + +### Major changes + +- For DOF1 and HSF1, revised the results of `calc_genoprob()` for the + X chromosome, so that it just keeps track of the chromosome from the + DO/HS parent. In males, assuming that the DO/HS parent is the + mother. May have fixed ### Minor changes - Add dependency on version of Rcpp (>= 1.0.7) +- Revisions so that `genoprob_to_alleleprob()` to work with DOF1 and + HSF1. `plot_onegeno()` should also work now in these cases. + (Issue #140 and Issue #141) + ### Bug fixes - Revised `predict_snpgeno()` to work for DOF1 and HSF1 populations. diff --git a/src/cross_dof1.cpp b/src/cross_dof1.cpp index 9f36a10e..20464c4f 100644 --- a/src/cross_dof1.cpp +++ b/src/cross_dof1.cpp @@ -23,12 +23,7 @@ const bool DOF1::check_geno(const int gen, const bool is_observed_value, const int n_alleles = 8; const int n_geno = 8; - if(!is_x_chr || is_female) { // autosome or female X - if(gen>= 1 && gen <= n_geno) return true; - } - else { // male X - if(gen>=n_geno+1 && gen <=n_geno+n_alleles) return true; - } + if(gen>= 1 && gen <= n_geno) return true; return false; // otherwise a problem } @@ -56,13 +51,15 @@ const double DOF1::emit(const int obs_gen, const int true_gen, const double erro if(obs_gen==0) return 0.0; // missing - int f1; - if(!is_x_chr || is_female) // autosome or female X - f1 = founder_geno[true_gen-1]; - else - f1 = founder_geno[true_gen-9]; + int f1 = founder_geno[true_gen-1]; - int f2 = founder_geno[8]; // 9th founder is the other strain + int f2; + if(is_x_chr && !is_female) { + f2 = f1; // assuming female DO x male 9th strain, so male is hemizygous DO chr + } else { + // autosome or female X chr + f2 = founder_geno[8]; // 9th founder is the other strain + } // treat founder hets as missing if(f1==2) f1 = 0; @@ -162,30 +159,18 @@ const double DOF1::step(const int gen_left, const int gen_right, const double re const IntegerVector DOF1::possible_gen(const bool is_x_chr, const bool is_female, const IntegerVector& cross_info) { - int n_alleles = 8; int n_geno = 8; - if(is_x_chr && !is_female) { // male X chromosome - IntegerVector result(n_alleles); - for(int i=0; i DOF1::geno_names(const std::vector a { int n_alleles = alleles.size(); - if(is_x_chr) { - std::vector result(n_alleles*2); + std::vector result(n_alleles); - for(int i=0; i result(n_alleles); - - for(int i=0; i= 1 && gen <= n_geno) return true; - } - else { // male X - if(gen>=n_geno+1 && gen <=n_geno+n_alleles) return true; - } + if(gen>= 1 && gen <= n_geno) return true; return false; // otherwise a problem } @@ -56,13 +51,15 @@ const double HSF1::emit(const int obs_gen, const int true_gen, const double erro if(obs_gen==0) return 0.0; // missing - int f1; - if(!is_x_chr || is_female) // autosome or female X - f1 = founder_geno[true_gen-1]; - else - f1 = founder_geno[true_gen-9]; + int f1 = founder_geno[true_gen-1]; - int f2 = founder_geno[8]; // 9th founder is the other strain + int f2; + if(is_x_chr && !is_female) { + f2 = f1; // assuming female DO x male 9th strain, so male is hemizygous DO chr + } else { + // autosome or female X chr + f2 = founder_geno[8]; // 9th founder is the other strain + } // treat founder hets as missing if(f1==2) f1 = 0; @@ -160,30 +157,17 @@ const double HSF1::step(const int gen_left, const int gen_right, const double re const IntegerVector HSF1::possible_gen(const bool is_x_chr, const bool is_female, const IntegerVector& cross_info) { - int n_alleles = 8; int n_geno = 8; - if(is_x_chr && !is_female) { // male X chromosome - IntegerVector result(n_alleles); - for(int i=0; i HSF1::geno_names(const std::vector a { int n_alleles = alleles.size(); - if(is_x_chr) { - std::vector result(n_alleles*2); - - for(int i=0; i result(n_alleles); + std::vector result(n_alleles); - for(int i=0; i Date: Fri, 28 Oct 2022 19:37:43 -0500 Subject: [PATCH 3/6] Fix the tests for the HMM basics for DOF1 and HSF1 --- NEWS.md | 9 +++++++-- tests/testthat/test-hmmbasic-dof1.R | 31 ++++++++++++++--------------- tests/testthat/test-hmmbasic-hsf1.R | 27 ++++++++++++------------- 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/NEWS.md b/NEWS.md index 739fb5bd..b1b22f7f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,8 +4,8 @@ - For DOF1 and HSF1, revised the results of `calc_genoprob()` for the X chromosome, so that it just keeps track of the chromosome from the - DO/HS parent. In males, assuming that the DO/HS parent is the - mother. May have fixed + DO/HS parent. In males, we are assuming that the DO/HS parent is the + mother. ### Minor changes @@ -31,6 +31,11 @@ - Issue a warning message if founder genotypes are included but not used (Issue #211). +- The treatment of the male X chromosome in DOF1 and HSF1 was + incorrect. We're now assuming that the DO or HS parent was the + mother in the F1 cross, in which case males will be hemizygous for + one of the DO/HS founder alleles. + ## qtl2 0.28 (2021-10-11) diff --git a/tests/testthat/test-hmmbasic-dof1.R b/tests/testthat/test-hmmbasic-dof1.R index 14fe51a8..619605f1 100644 --- a/tests/testthat/test-hmmbasic-dof1.R +++ b/tests/testthat/test-hmmbasic-dof1.R @@ -9,7 +9,7 @@ test_that("DOF1 check_geno works", { # observed genotypes for(i in 0:5) { # Autosome - expect_true(test_check_geno("dof1", i, TRUE, FALSE, FALSE, 20)) + expect_true(test_check_geno("dof1", i, TRUE, FALSE, FALSE, 8)) # Female X expect_true(test_check_geno("dof1", i, TRUE, TRUE, TRUE, 20)) # Male X @@ -38,20 +38,20 @@ test_that("DOF1 check_geno works", { expect_false(test_check_geno("dof1", i, FALSE, TRUE, TRUE, 20)) } - # true genotypes, autosome and female X - for(i in 8 + 1:8) { - expect_true(test_check_geno("dof1", i, FALSE, TRUE, FALSE, 20)) - } - for(i in c(0:8, 8+9)) { + # true genotypes, male X + for(i in c(0, 9:18)) { expect_false(test_check_geno("dof1", i, FALSE, TRUE, FALSE, 20)) } + for(i in c(1:8)) { + expect_true(test_check_geno("dof1", i, FALSE, TRUE, FALSE, 20)) + } }) test_that("DOF1 n_gen works", { expect_equal(test_ngen("dof1", FALSE), 8) - expect_equal(test_ngen("dof1", TRUE), 8+8) + expect_equal(test_ngen("dof1", TRUE), 8) }) @@ -64,7 +64,7 @@ test_that("DOF1 possible_gen works", { expect_equal(test_possible_gen("dof1", TRUE, TRUE, 20), 1:8) # X male - expect_equal(test_possible_gen("dof1", TRUE, FALSE, 20), 8+(1:8)) + expect_equal(test_possible_gen("dof1", TRUE, FALSE, 20), 1:8) }) @@ -90,29 +90,30 @@ test_that("DOF1 emit works", { fgen <- c(1,3,0,1,3,0,1,3,1) # founder genotypes; 0=missing, 1=AA, 3=BB err <- 0.01 - # Autosome or female X expected <- log(c(1-err, err/2, err/2, 1-err/2, err)) for(trueg in c(1,4,7)) { # A, D, G for(obsg in 1:5) { expect_equal(test_emit("dof1", obsg, trueg, err, fgen, FALSE, FALSE, 20), expected[obsg]) expect_equal(test_emit("dof1", obsg, trueg, err, fgen, TRUE, TRUE, 20), expected[obsg]) - expect_equal(test_emit("dof1", obsg, trueg+8, err, fgen, TRUE, FALSE, 20), expected[obsg]) + expect_equal(test_emit("dof1", obsg, trueg, err, fgen, TRUE, FALSE, 20), expected[obsg]) } } expected <- log(c(err/2, 1-err, err/2, 1-err/2, 1-err/2)) + expected_male <- log(c(err/2, err/2, 1-err, err, 1-err/2)) for(trueg in c(2,5,8)) { # B, E, H for(obsg in 1:5) { expect_equal(test_emit("dof1", obsg, trueg, err, fgen, FALSE, FALSE, 20), expected[obsg]) - expect_equal(test_emit("dof1", obsg, trueg, err, fgen, TRUE, TRUE, 20), expected[obsg]) - expect_equal(test_emit("dof1", obsg, trueg+8, err, fgen, TRUE, FALSE, 20), expected[obsg]) + expect_equal(test_emit("dof1", obsg, trueg, err, fgen, TRUE, TRUE, 20), expected[obsg]) + expect_equal(test_emit("dof1", obsg, trueg, err, fgen, TRUE, FALSE, 20), expected_male[obsg]) } } expected <- log(c(1-err, 1, err, 1-err, err)) + expected_male <- log(c(1, 1, 1, 1, 1)) for(trueg in c(3,6)) { for(obsg in 1:5) { expect_equal(test_emit("dof1", obsg, trueg, err, fgen, FALSE, FALSE, 20), expected[obsg]) expect_equal(test_emit("dof1", obsg, trueg, err, fgen, TRUE, TRUE, 20), expected[obsg]) - expect_equal(test_emit("dof1", obsg, trueg+8, err, fgen, TRUE, FALSE, 20), expected[obsg]) + expect_equal(test_emit("dof1", obsg, trueg, err, fgen, TRUE, FALSE, 20), expected_male[obsg]) } } @@ -188,9 +189,7 @@ test_that("DOF1 step works", { test_that("geno_names works", { auto <- LETTERS[1:8] - X <- c(paste0(LETTERS[1:8], "X"), - paste0(LETTERS[1:8], "Y")) expect_equal(geno_names("dof1", LETTERS[1:8], FALSE), auto) - expect_equal(geno_names("dof1", LETTERS[1:8], TRUE), X) + expect_equal(geno_names("dof1", LETTERS[1:8], TRUE), auto) }) diff --git a/tests/testthat/test-hmmbasic-hsf1.R b/tests/testthat/test-hmmbasic-hsf1.R index c85826f6..bb972b02 100644 --- a/tests/testthat/test-hmmbasic-hsf1.R +++ b/tests/testthat/test-hmmbasic-hsf1.R @@ -38,20 +38,20 @@ test_that("HSF1 check_geno works", { expect_false(test_check_geno("hsf1", i, FALSE, TRUE, TRUE, 20)) } - # true genotypes, autosome and female X - for(i in 8 + 1:8) { - expect_true(test_check_geno("hsf1", i, FALSE, TRUE, FALSE, 20)) - } - for(i in c(0:8, 8+9)) { + # true genotypes, male X + for(i in c(0, 8 + 1:8)) { expect_false(test_check_geno("hsf1", i, FALSE, TRUE, FALSE, 20)) } + for(i in 1:8) { + expect_true(test_check_geno("hsf1", i, FALSE, TRUE, FALSE, 20)) + } }) test_that("HSF1 n_gen works", { expect_equal(test_ngen("hsf1", FALSE), 8) - expect_equal(test_ngen("hsf1", TRUE), 8+8) + expect_equal(test_ngen("hsf1", TRUE), 8) }) @@ -64,7 +64,7 @@ test_that("HSF1 possible_gen works", { expect_equal(test_possible_gen("hsf1", TRUE, TRUE, 20), 1:8) # X male - expect_equal(test_possible_gen("hsf1", TRUE, FALSE, 20), 8+(1:8)) + expect_equal(test_possible_gen("hsf1", TRUE, FALSE, 20), 1:8) }) @@ -90,29 +90,30 @@ test_that("HSF1 emit works", { fgen <- c(1,3,0,1,3,0,1,3,1) # founder genotypes; 0=missing, 1=AA, 3=BB err <- 0.01 - # Autosome or female X expected <- log(c(1-err, err/2, err/2, 1-err/2, err)) for(trueg in c(1,4,7)) { # A, D, G for(obsg in 1:5) { expect_equal(test_emit("hsf1", obsg, trueg, err, fgen, FALSE, FALSE, 20), expected[obsg]) expect_equal(test_emit("hsf1", obsg, trueg, err, fgen, TRUE, TRUE, 20), expected[obsg]) - expect_equal(test_emit("hsf1", obsg, trueg+8, err, fgen, TRUE, FALSE, 20), expected[obsg]) + expect_equal(test_emit("hsf1", obsg, trueg, err, fgen, TRUE, FALSE, 20), expected[obsg]) } } expected <- log(c(err/2, 1-err, err/2, 1-err/2, 1-err/2)) + expected_male <- log(c(err/2, err/2, 1-err, err, 1-err/2)) for(trueg in c(2,5,8)) { # B, E, H for(obsg in 1:5) { expect_equal(test_emit("hsf1", obsg, trueg, err, fgen, FALSE, FALSE, 20), expected[obsg]) expect_equal(test_emit("hsf1", obsg, trueg, err, fgen, TRUE, TRUE, 20), expected[obsg]) - expect_equal(test_emit("hsf1", obsg, trueg+8, err, fgen, TRUE, FALSE, 20), expected[obsg]) + expect_equal(test_emit("hsf1", obsg, trueg, err, fgen, TRUE, FALSE, 20), expected_male[obsg]) } } expected <- log(c(1-err, 1, err, 1-err, err)) + expected_male <- log(c(1, 1, 1, 1, 1)) for(trueg in c(3,6)) { for(obsg in 1:5) { expect_equal(test_emit("hsf1", obsg, trueg, err, fgen, FALSE, FALSE, 20), expected[obsg]) expect_equal(test_emit("hsf1", obsg, trueg, err, fgen, TRUE, TRUE, 20), expected[obsg]) - expect_equal(test_emit("hsf1", obsg, trueg+8, err, fgen, TRUE, FALSE, 20), expected[obsg]) + expect_equal(test_emit("hsf1", obsg, trueg, err, fgen, TRUE, FALSE, 20), expected_male[obsg]) } } @@ -188,9 +189,7 @@ test_that("HSF1 step works", { test_that("geno_names works", { auto <- LETTERS[1:8] - X <- c(paste0(LETTERS[1:8], "X"), - paste0(LETTERS[1:8], "Y")) expect_equal(geno_names("hsf1", LETTERS[1:8], FALSE), auto) - expect_equal(geno_names("hsf1", LETTERS[1:8], TRUE), X) + expect_equal(geno_names("hsf1", LETTERS[1:8], TRUE), auto) }) From 5b03b82abc5136b305a172b6cede21f3b42ea688 Mon Sep 17 00:00:00 2001 From: Karl Broman Date: Sat, 29 Oct 2022 08:42:40 -0500 Subject: [PATCH 4/6] Fix predict_snpgeno for DOF1/HSF1 on X chr --- DESCRIPTION | 4 ++-- NEWS.md | 2 +- R/predict_snpgeno.R | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e40ba050..0f3d6b65 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: qtl2 -Version: 0.29-6 -Date: 2022-10-28 +Version: 0.29-7 +Date: 2022-10-29 Title: Quantitative Trait Locus Mapping in Experimental Crosses Description: Provides a set of tools to perform quantitative trait locus (QTL) analysis in experimental crosses. It is a diff --git a/NEWS.md b/NEWS.md index b1b22f7f..099c6c4d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -## qtl2 0.29-6 (2022-10-28) +## qtl2 0.29-7 (2022-10-29) ### Major changes diff --git a/R/predict_snpgeno.R b/R/predict_snpgeno.R index c67ab2da..3dc586db 100644 --- a/R/predict_snpgeno.R +++ b/R/predict_snpgeno.R @@ -87,7 +87,11 @@ function(cross, geno, cores=1) # ugh deal with DOF1/HSF1 specially if(cross$crosstype %in% c("dof1", "hsf1")) { - ph2[] <- 9 # one chromosome is from 9th founder + if(!is_x_chr[chr]) ph2[[chr]][] <- 9 # one chromosome is from 9th founder + else { + if(any(is_male)) ph2[[chr]][is_male,] <- ph1[[chr]][is_male,] + if(any(!is_male)) ph2[[chr]][!is_male,] <- 9 + } } if(ncol(fg) != ncol(ph1) || From d766b4d0669e5a38fde42583f513ea3f016f4207 Mon Sep 17 00:00:00 2001 From: Karl Broman Date: Sat, 29 Oct 2022 13:22:58 -0500 Subject: [PATCH 5/6] Fix the last correction to predict_snpgeno for DOF1 - also add a test --- R/predict_snpgeno.R | 6 +-- tests/testthat/test-predict_snpgeno.R | 75 +++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 3 deletions(-) diff --git a/R/predict_snpgeno.R b/R/predict_snpgeno.R index 3dc586db..20cd63cc 100644 --- a/R/predict_snpgeno.R +++ b/R/predict_snpgeno.R @@ -87,10 +87,10 @@ function(cross, geno, cores=1) # ugh deal with DOF1/HSF1 specially if(cross$crosstype %in% c("dof1", "hsf1")) { - if(!is_x_chr[chr]) ph2[[chr]][] <- 9 # one chromosome is from 9th founder + if(!is_x_chr[chr]) ph2[] <- 9 # one chromosome is from 9th founder else { - if(any(is_male)) ph2[[chr]][is_male,] <- ph1[[chr]][is_male,] - if(any(!is_male)) ph2[[chr]][!is_male,] <- 9 + if(any(is_male)) ph2[is_male,] <- ph1[is_male,,drop=FALSE] + if(any(!is_male)) ph2[!is_male,] <- 9 } } diff --git a/tests/testthat/test-predict_snpgeno.R b/tests/testthat/test-predict_snpgeno.R index 68abed1a..457dddf7 100644 --- a/tests/testthat/test-predict_snpgeno.R +++ b/tests/testthat/test-predict_snpgeno.R @@ -55,3 +55,78 @@ test_that("predict_snpgeno works for magic lines", { expect_equivalent(infg[[chr]], infg_hard) }) + + +test_that("predict_snpgeno works for DOF1 and DOHS", { + + # a small subset of a DOF1 population: 3 individuals, 10 markers on each of 2 chr + x <- structure(list(crosstype = "dof1", geno = list(`2` = structure(c(3L, +3L, 2L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 1L, 1L, +1L, 2L, 2L, 3L, 3L, 3L, 3L, 2L, 2L, 1L, 2L, 2L, 1L), dim = c(3L, +10L), dimnames = list(c("117447", "117443", "119519"), c("UNCHS003833", +"UNCHS003834", "UNC2466989", "JAX00090637", "JAX00482049", "UNCHS003835", +"UNCHS003836", "JAX00482064", "CEAJAX00090652", "JAX00090652" +))), X = structure(c(3L, 3L, 2L, 3L, 3L, 2L, 3L, 3L, 2L, 3L, +3L, 2L, 1L, 1L, 2L, 3L, 3L, 2L, 3L, 3L, 3L, 1L, 1L, 2L, 3L, 3L, +3L, 3L, 3L, 3L), dim = c(3L, 10L), dimnames = list(c("117447", +"117443", "119519"), c("JAX00181486", "JAX00714977", "JAX00181489", +"JAX00714985", "JAX00181502", "JAX00181504", "UNC31049617", "UNCHS048912", +"JAX00715002", "JAX00715002r")))), gmap = list(`2` = c(UNCHS003833 = 0.105908732571738, +UNCHS003834 = 0.10825526663261, UNC2466989 = 0.109617384848426, +JAX00090637 = 0.110597154091381, JAX00482049 = 0.143764599886437, +UNCHS003835 = 0.221542081049763, UNCHS003836 = 0.223175029788022, +JAX00482064 = 0.229358993383802, CEAJAX00090652 = 0.250603258188368, +JAX00090652 = 0.250603258188368), X = c(JAX00181486 = 37.7842866029833, +JAX00714977 = 37.7990420259301, JAX00181489 = 37.8119460221676, +JAX00714985 = 37.8912830161017, JAX00181502 = 37.9925319810839, +JAX00181504 = 37.9928259324011, UNC31049617 = 38.0264384750733, +UNCHS048912 = 38.0297613573523, JAX00715002 = 38.0813853540008, +JAX00715002r = 38.0813853540008)), pmap = list(`2` = c(UNCHS003833 = 3.177758, +UNCHS003834 = 3.181293, UNC2466989 = 3.183345, JAX00090637 = 3.184821, +JAX00482049 = 3.234787, UNCHS003835 = 3.351957, UNCHS003836 = 3.354417, +JAX00482064 = 3.363733, CEAJAX00090652 = 3.395737, JAX00090652 = 3.395737 +), X = c(JAX00181486 = 84.865978, JAX00714977 = 84.88179, JAX00181489 = 84.895618, +JAX00714985 = 84.980636, JAX00181502 = 85.089135, JAX00181504 = 85.08945, +UNC31049617 = 85.127743, UNCHS048912 = 85.131962, JAX00715002 = 85.197508, +JAX00715002r = 85.197508)), covar = structure(list(sex = c("M", +"M", "M"), cross_direction = c("(B-B)x(D-D)", "(B-B)x(D-D)", +"(B-B)x(D-D)"), ngen = c("41", "41", "41")), row.names = c("117447", +"117443", "119519"), class = "data.frame"), founder_geno = list( + `2` = structure(c(1L, 3L, 1L, 3L, 1L, 1L, 3L, 3L, 3L, 3L, + 3L, 3L, 3L, 3L, 1L, 1L, 3L, 3L, 1L, 3L, 1L, 3L, 1L, 3L, 3L, + 1L, 3L, 3L, 1L, 3L, 1L, 3L, 1L, 1L, 3L, 1L, 3L, 3L, 3L, 3L, + 3L, 1L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 1L, 1L, 3L, + 3L, 1L, 3L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, + 3L, 3L, 1L, 1L, 3L, 1L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 3L, 1L, + 3L, 3L, 3L, 1L, 1L), dim = 9:10, dimnames = list(c("A", "B", + "C", "D", "E", "F", "G", "H", "I"), c("UNCHS003833", "UNCHS003834", + "UNC2466989", "JAX00090637", "JAX00482049", "UNCHS003835", + "UNCHS003836", "JAX00482064", "CEAJAX00090652", "JAX00090652" + ))), X = structure(c(3L, 1L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, + 3L, 3L, 3L, 3L, 3L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, + 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 3L, 3L, 1L, 1L, 1L, + 1L, 1L, 3L, 3L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 3L, 3L, + 3L, 1L, 3L, 1L, 1L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, + 3L, 3L, 1L, 3L, 3L, 3L, 3L, 3L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, + 3L, 3L, 1L, 3L, 3L, 3L), dim = 9:10, dimnames = list(c("A", + "B", "C", "D", "E", "F", "G", "H", "I"), c("JAX00181486", + "JAX00714977", "JAX00181489", "JAX00714985", "JAX00181502", + "JAX00181504", "UNC31049617", "UNCHS048912", "JAX00715002", + "JAX00715002r")))), is_x_chr = c(`2` = FALSE, X = TRUE), + is_female = c(`117447` = FALSE, `117443` = FALSE, `119519` = TRUE + ), cross_info = structure(c(41L, 41L, 41L), dim = c(3L, 1L + ), dimnames = list(c("117447", "117443", "119519"), "ngen")), + alleles = c("A", "B", "C", "D", "E", "F", "G", "H")), class = "cross2") + + pr <- calc_genoprob(x, err=0.002) + set.seed(20221029) + v <- maxmarg(pr, minprob=0.2) + + snpg <- predict_snpgeno(x, v) + + expect_true(all(snpg$"2" == x$geno$"2")) + expect_equal(sum(snpg$X != x$geno$X), 2) + expect_true(all((snpg$X == x$geno$X)[1:2,])) + expect_equal(snpg$X[3,], colMeans(x$founder_geno$X[c(7,9),])) + +}) From 3dfa720fe7a54d0e5698a10324c71d8e078347ea Mon Sep 17 00:00:00 2001 From: Karl Broman Date: Sat, 29 Oct 2022 14:01:16 -0500 Subject: [PATCH 6/6] Update github workflow for package check --- .github/workflows/R-CMD-check.yaml | 29 ++++++++++------------------- README.md | 2 +- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 05282628..a3ac6182 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,4 +1,4 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/master/examples +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: @@ -18,7 +18,7 @@ jobs: fail-fast: false matrix: config: - - {os: macOS-latest, r: 'release'} + - {os: macos-latest, r: 'release'} - {os: windows-latest, r: 'release'} - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} - {os: ubuntu-latest, r: 'release'} @@ -29,30 +29,21 @@ jobs: R_KEEP_PKG_SOURCE: yes steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - uses: r-lib/actions/setup-pandoc@v1 + - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.config.r }} http-user-agent: ${{ matrix.config.http-user-agent }} use-public-rspm: true - - uses: r-lib/actions/setup-r-dependencies@v1 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: rcmdcheck + extra-packages: any::rcmdcheck + needs: check - - uses: r-lib/actions/check-r-package@v1 - - - name: Show testthat output - if: always() - run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true - shell: bash - - - name: Upload check results - if: failure() - uses: actions/upload-artifact@main + - uses: r-lib/actions/check-r-package@v2 with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check + upload-snapshots: true diff --git a/README.md b/README.md index 1e26dc70..3de4daad 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ### [R/qtl2](https://kbroman.org/qtl2/) -[![R build status](https://github.com/rqtl/qtl2/workflows/R-CMD-check/badge.svg)](https://github.com/rqtl/qtl2/actions) +[![R-CMD-check](https://github.com/rqtl/qtl2/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/rqtl/qtl2/actions/workflows/R-CMD-check.yaml) [![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/qtl2)](https://cran.r-project.org/package=qtl2) [Karl Broman](https://kbroman.org)