Skip to content

Commit cbda13d

Browse files
authored
Merge pull request #217 from kbroman/cran
changes for CRAN ver 0.32
2 parents 2749821 + a329e46 commit cbda13d

13 files changed

Lines changed: 93 additions & 22 deletions

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.31-5
3-
Date: 2023-04-20
2+
Version: 0.32
3+
Date: 2023-04-21
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: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
## qtl2 0.31-5 (2023-04-20)
1+
## qtl2 0.32 (2023-04-21)
2+
3+
### Major changes
4+
5+
- In `create_variant_query_func()`, added new arguments `id_field` and
6+
`sdp_field`, and in `create_gene_query_func()`, added arguments
7+
`name_field` and `strand_field` (Issue #215). This gives new
8+
flexibility, but also adds new requirements (for example, that the
9+
variant database has a field `"snp_id"`) and so could potentially
10+
break working code.
211

312
### New features
413

@@ -9,22 +18,22 @@
918

1019
### Minor changes
1120

12-
- Fixed date in citation, Broman et al. (2019) <doi:10.1534/genetics.118.301595>
13-
1421
- `read_cross2()` now gives a warning if sex isn't provided but is
1522
needed. Also, if sex is missing we assume all individuals are
1623
female; previously we assumed they were male. (Issue #214)
1724

1825
- In `plot_genes()`, allow strand to be +/- 1 and not just `"+"` or
1926
`"-"`. (Issue #216)
2027

28+
- Fixed date in citation, Broman et al. (2019)
29+
[doi:10.1534/genetics.118.301595](https://doi.org/10.1534/genetics.118.301595)
30+
2131
### Bug fixes
2232

2333
- In `plot_genes()` there was a case where `stop` was used that should
2434
have been `end`.
2535

2636

27-
2837
## qtl2 0.30 (2022-12-02)
2938

3039
### Major changes
@@ -72,7 +81,7 @@
7281
a color-blind friendly palette. The original CC colors remain as
7382
`CCorigcolors`; the previous default is now `CCaltcolors`. The new
7483
colors are derived from the palette in Wong (2011) Nature
75-
Methods <doi:10.1038/nmeth.1618>.
84+
Methods [doi:10.1038/nmeth.1618](https://doi.org/10.1038/nmeth.1618).
7685

7786
- `plot_coefCC()` was revised to include `col=CCcolors` as an argument.
7887
The default is the new color-blind friendly CC colors, but one can

R/create_gene_query_func.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#' @param chr_field Name of chromosome field
1111
#' @param start_field Name of field with start position (in basepairs)
1212
#' @param stop_field Name of field with stop position (in basepairs)
13+
#' @param name_field Name of field with gene name
14+
#' @param strand_field Name of field with strand (+/-)
1315
#' @param filter Additional SQL filter (as a character string).
1416
#'
1517
#' @return Function with three arguments, `chr`, `start`,
@@ -48,6 +50,7 @@
4850
create_gene_query_func <-
4951
function(dbfile=NULL, db=NULL, table_name="genes",
5052
chr_field="chr", start_field="start", stop_field="stop",
53+
name_field="Name", strand_field="strand",
5154
filter=NULL)
5255
{
5356
if(!is.null(db)) {
@@ -80,6 +83,10 @@ create_gene_query_func <-
8083
result$start <- result[,start_field]/1e6
8184
result$stop <- result[,stop_field]/1e6
8285

86+
# name and strand
87+
result <- swap_colname(result, name_field, "Name")
88+
result <- swap_colname(result, strand_field, "strand")
89+
8390
result
8491
}
8592

@@ -120,6 +127,10 @@ create_gene_query_func <-
120127
result$start <- result[,start_field]/1e6
121128
result$stop <- result[,stop_field]/1e6
122129

130+
# name and strand
131+
result <- swap_colname(result, name_field, "Name")
132+
result <- swap_colname(result, strand_field, "strand")
133+
123134
result
124135
}
125136
}

R/create_variant_query_func.R

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#' @param table_name Name of table in the database
1010
#' @param chr_field Name of chromosome field
1111
#' @param pos_field Name of position field
12+
#' @param id_field Name of SNP/variant ID field
13+
#' @param sdp_field Name of strain distribution pattern (SDP) field
1214
#' @param filter Additional SQL filter (as a character string)
1315
#'
1416
#' @return Function with three arguments, `chr`, `start`,
@@ -50,7 +52,9 @@
5052

5153
create_variant_query_func <-
5254
function(dbfile=NULL, db=NULL, table_name="variants",
53-
chr_field="chr", pos_field="pos", filter=NULL)
55+
chr_field="chr", pos_field="pos",
56+
id_field="snp_id", sdp_field="sdp",
57+
filter=NULL)
5458
{
5559
if(!is.null(db)) {
5660
if(!is.null(dbfile))
@@ -82,6 +86,10 @@ create_variant_query_func <-
8286
# include pos column in Mbp
8387
result$pos <- result[,pos_field]/1e6
8488

89+
# name and sdp fields
90+
result <- swap_colname(result, id_field, "snp")
91+
result <- swap_colname(result, sdp_field, "sdp")
92+
8593
result
8694
}
8795

@@ -122,6 +130,10 @@ create_variant_query_func <-
122130
# include pos column in Mbp
123131
result$pos <- result[,pos_field]/1e6
124132

133+
# name and sdp fields
134+
result <- swap_colname(result, id_field, "snp")
135+
result <- swap_colname(result, sdp_field, "sdp")
136+
125137
result
126138
}
127139
}

R/swap_colname.R

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# swap_colname
2+
#
3+
# replace column name in dataframe
4+
# column labeled orig_name becomes new_name
5+
# if there had already been a column labeled new_name,
6+
# we append "_old"
7+
#
8+
# (used in create_variant_query_func and create_gene_query_func)
9+
swap_colname <-
10+
function(df, orig_name, new_name)
11+
{
12+
if(orig_name == new_name) return(df)
13+
14+
cn <- colnames(df)
15+
if(!any(cn == orig_name)) {
16+
stop('field "', orig_name, '" not found')
17+
}
18+
19+
if(any(cn==new_name)) {
20+
cn[cn==new_name] <- paste0(new_name, "_old")
21+
}
22+
cn[cn==orig_name] <- new_name
23+
24+
colnames(df) <- cn
25+
df
26+
}

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ Install R/qtl2 from [CRAN](https://cran.r-project.org):
3131
- [user guide](https://kbroman.org/qtl2/assets/vignettes/user_guide.html)
3232
- [categorized list of functions in R/qtl2](https://kbroman.org/qtl2/pages/rqtl2_functions.html)
3333
- [input file formats](https://kbroman.org/qtl2/assets/vignettes/input_files.html)
34-
(see also the
34+
(also see the
3535
[sample data files](https://kbroman.org/qtl2/pages/sampledata.html)
3636
and the [qtl2data repository](https://github.com/rqtl/qtl2data))
3737
- [using qtl2fst for on-disk genotype probabilities](https://kbroman.org/qtl2/assets/vignettes/qtl2fst.html)
3838
- [preparing diversity outbred mouse data for R/qtl2](https://kbroman.org/qtl2/pages/prep_do_data.html)
39+
- [resources for mouse genome build GRCm39](https://kbroman.org/qtl2/pages/move_to_build39.html)
3940
- [genotype diagnostics for diversity outbred mice](https://kbroman.org/qtl2/assets/vignettes/do_diagnostics.html)
4041
- [identifying sample mix-ups in diversity outbred mice](https://kbroman.org/qtl2/assets/vignettes/do_mixups.html)
4142
- [differences between R/qtl and R/qtl2](https://kbroman.org/qtl2/assets/vignettes/rqtl_diff.html)

inst/CITATION

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ citHeader("To cite R/qtl2 in publications use:")
22

33
bibentry(bibtype="article",
44
title = "R/qtl2: software for mapping quantitative trait loci with high-dimensional data and multi-parent populations.",
5-
author = personList(person(c("Karl", "W."), "Broman"),
6-
person(c("Daniel", "M."), "Gatti"),
7-
person("Petr", "Simecek"),
8-
person(c("Nicholas", "A."), "Furlotte"),
9-
person("Pjotr", "Prins"),
10-
person("Śaunak", "Sen"),
11-
person(c("Brian", "S."), "Yandell"),
12-
person(c("Gary", "A."), "Churchill")),
5+
author = c(person(c("Karl", "W."), "Broman"),
6+
person(c("Daniel", "M."), "Gatti"),
7+
person("Petr", "Simecek"),
8+
person(c("Nicholas", "A."), "Furlotte"),
9+
person("Pjotr", "Prins"),
10+
person("Śaunak", "Sen"),
11+
person(c("Brian", "S."), "Yandell"),
12+
person(c("Gary", "A."), "Churchill")),
1313
journal = "Genetics",
1414
doi = "10.1534/genetics.118.301595",
1515
year = 2019,

man/create_gene_query_func.Rd

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/create_variant_query_func.Rd

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-arrange_genes.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ context("Arrange genes vertically so they don't overlap")
22

33
test_that("arrange_genes gives appropriate errors", {
44

5-
expect_error(arrange_genes(NULL, NULL))
5+
# expect_error(arrange_genes(NULL, NULL))
66
expect_error(arrange_genes(numeric(0), numeric(0)))
77
expect_error(arrange_genes(c(1,2), 4))
88
expect_error(arrange_genes(c(1,2), c(4,5,6)))

0 commit comments

Comments
 (0)