Skip to content

Commit 2d39f6f

Browse files
authored
Merge pull request #233 from kbroman/cran
New version on CRAN: 0.36
2 parents 9fb9b76 + 6d9b2b3 commit 2d39f6f

5 files changed

Lines changed: 48 additions & 18 deletions

File tree

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: qtl2
2-
Version: 0.35-1
3-
Date: 2024-03-15
2+
Version: 0.36
3+
Date: 2024-05-13
44
Title: Quantitative Trait Locus Mapping in Experimental Crosses
55
Description: Provides a set of tools to perform quantitative
66
trait locus (QTL) analysis in experimental crosses. It is a

NEWS.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
## qtl2 0.35-1 (2024-03-15)
1+
## qtl2 0.36 (2024-05-13)
2+
3+
### Minor changes
4+
5+
- In `scan1snps()`, subset `genoprobs` and `map` to common positions,
6+
if they have different markers. (Issue #219)
27

38
### Bug fixes
49

510
- Fixed a problem with `sdp_panel=TRUE` in `plot_snpasso()`. (Issue #232)
611

12+
- Stop `index_snps()` with an error if physical map has missing
13+
values. (Issue #218)
14+
715

816
## qtl2 0.34 (2023-11-28)
917

R/index_snps.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ index_snps <-
114114

115115
### find snps in map
116116
this_map <- map[[uchr]]
117+
if(any(is.na(this_map))) stop("Missing values in map on chr ", uchr)
117118
snploc <- find_intervals(snpinfo$pos, this_map, tol)
118119
interval <- snploc[,1]
119120
on_map <- (snploc[,2]==1)

R/scan1snps.R

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -113,21 +113,30 @@ scan1snps <-
113113
genoprobs <- genoprobs[,cchr]
114114
map <- map[cchr]
115115

116-
# check inputs
117-
if(length(genoprobs) != length(map)) {
118-
stop("length(genoprobs) != length(map)")
119-
}
120-
if(any(dim(genoprobs)[3,] != vapply(map, length, 1))) {
121-
stop("genoprobs and map have different numbers of markers")
122-
}
123-
dn <- dimnames(genoprobs)[[3]]
124-
different_names <- FALSE
125-
for(i in seq_along(dn)) {
126-
if(any(dn[[i]] != names(map[[i]]))) different_names <- TRUE
127-
}
128-
if(different_names) { # different marker names...give a warning (maybe should be an error)
129-
warning("genoprobs and map have different marker names")
116+
# check genoprobs and map have same markers in same order
117+
# - subset to common markers if different
118+
# - stop with error if different order
119+
subset_markers <- FALSE
120+
for(ichr in names(genoprobs)) {
121+
markers_genoprobs <- dimnames(genoprobs[[ichr]])[[3]]
122+
markers_map <- names(map[[ichr]])
123+
124+
if(length(markers_genoprobs) != length(markers_map) ||
125+
any(markers_genoprobs != markers_map)) {
126+
subset_markers <- TRUE # later give warning
127+
markers <- markers_genoprobs[markers_genoprobs %in% markers_map]
128+
if(length(markers)==0) stop("No markers in common between genoprobs and map on chr ", ichr)
129+
genoprobs[[ichr]] <- genoprobs[[ichr]][,,markers_genoprobs %in% markers,drop=FALSE]
130+
map[[ichr]] <- map[[ichr]][markers_map %in% markers]
131+
132+
markers_genoprobs <- dimnames(genoprobs[[ichr]])[[3]]
133+
markers_map <- names(map[[ichr]])
134+
if(any(markers_genoprobs != markers_map))
135+
stop("Markers in different order between genoprobs and map on chr ", ichr)
136+
}
130137
}
138+
if(subset_markers) warning("Subset to common markers between genoprobs and map")
139+
131140
if(!is.null(snpinfo) && !is.null(query_func)) {
132141
warning("If snpinfo is provided, chr, start, end, and query_func are all ignored")
133142
}

tests/testthat/test-scan1snps.R

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,24 @@ test_that("scan1snps works", {
7575
out <- scan1snps(probs, DOex$pmap, DOex$pheno, query_func=queryf, chr=2, start=97.2, end=97.3)
7676
expect_equal(out, expected)
7777

78-
# if probs and map don't conform, should get an error
78+
# if probs and map don't conform, should get a warning
79+
## (one fewer marker in map)
7980
junk_map <- DOex$pmap
8081
junk_map[[1]] <- junk_map[[1]][-1]
82+
expect_warning( scan1snps(probs, junk_map, DOex$pheno, query_func=queryf, chr=2,
83+
start=97.2, end=97.3) )
84+
## (one fewere marker in probs)
85+
junk_probs <- probs
86+
junk_probs[["2"]] <- junk_probs[["2"]][,,-1]
87+
expect_warning( scan1snps(junk_probs, DOex$pmap, DOex$pheno, query_func=queryf, chr=2,
88+
start=97.2, end=97.3) )
89+
## markers out of order gives an error though
90+
junk_map <- DOex$pmap
91+
names(junk_map[["2"]])[1:5] <- names(junk_map[["2"]])[5:1]
8192
expect_error( scan1snps(probs, junk_map, DOex$pheno, query_func=queryf, chr=2,
8293
start=97.2, end=97.3) )
8394

95+
8496
# using a pre-defined table of snps
8597
snpinfo <- queryf(2, 97.2, 97.3)
8698
out2 <- scan1snps(probs, DOex$pmap, DOex$pheno, snpinfo=snpinfo)

0 commit comments

Comments
 (0)