34
34
# ' @export
35
35
msigdbr <- function (species = " Homo sapiens" , db_species = " HS" , collection = NULL , subcollection = NULL , category = deprecated(), subcategory = deprecated()) {
36
36
# Check parameters
37
- if (! is(species , " character" )) {
38
- stop(" `species` is not a character string" )
39
- }
40
- if (length(species ) > 1 ) {
41
- stop(" only one `species` should be specified" )
37
+ assertthat :: assert_that(
38
+ is.character(species ),
39
+ length(species ) == 1 ,
40
+ nchar(species ) > 1
41
+ )
42
+ assertthat :: assert_that(
43
+ is.character(db_species ),
44
+ length(db_species ) == 1 ,
45
+ nchar(db_species ) == 2
46
+ )
47
+ if (! is.null(collection )) {
48
+ assertthat :: assert_that(
49
+ is.character(collection ),
50
+ length(collection ) == 1 ,
51
+ nchar(collection ) > 0
52
+ )
42
53
}
43
- if (! is(db_species , " character" )) {
44
- stop(" `db_species` is not a character string" )
54
+ if (! is.null(subcollection )) {
55
+ assertthat :: assert_that(
56
+ is.character(subcollection ),
57
+ length(subcollection ) == 1 ,
58
+ nchar(subcollection ) > 0
59
+ )
45
60
}
46
61
47
62
# Use only mouse genes for mouse database
48
63
db_species <- toupper(db_species )
49
64
if (db_species == " MM" && ! (species %in% c(" Mus musculus" , " mouse" , " house mouse" ))) {
50
- stop(" set species to mouse for the mouse database" )
65
+ stop(" Set ` species` to mouse for the mouse database. " )
51
66
}
52
67
53
68
# Check for deprecated category arguments
54
69
if (lifecycle :: is_present(category )) {
55
- lifecycle :: deprecate_warn(" 9.0.0" , " msigdbr(category)" , " msigdbr(collection)" )
70
+ lifecycle :: deprecate_warn(" 10.0.0" , " msigdbr(category)" , " msigdbr(collection)" )
71
+ assertthat :: assert_that(is.character(category ), length(category ) == 1 , nchar(category ) > 0 )
56
72
collection <- category
57
73
}
58
74
if (lifecycle :: is_present(subcategory )) {
59
- lifecycle :: deprecate_warn(" 9.0.0" , " msigdbr(subcategory)" , " msigdbr(subcollection)" )
75
+ lifecycle :: deprecate_warn(" 10.0.0" , " msigdbr(subcategory)" , " msigdbr(subcollection)" )
76
+ assertthat :: assert_that(is.character(subcategory ), length(subcategory ) == 1 , nchar(subcategory ) > 0 )
60
77
subcollection <- subcategory
61
78
}
62
79
@@ -77,9 +94,6 @@ msigdbr <- function(species = "Homo sapiens", db_species = "HS", collection = NU
77
94
78
95
# Filter by collection
79
96
if (is.character(collection )) {
80
- if (length(collection ) > 1 ) {
81
- stop(" Please specify only one collection at a time." )
82
- }
83
97
if (collection %in% mdb $ gs_collection ) {
84
98
mdb <- dplyr :: filter(mdb , .data $ gs_collection == collection )
85
99
} else {
@@ -89,9 +103,6 @@ msigdbr <- function(species = "Homo sapiens", db_species = "HS", collection = NU
89
103
90
104
# Filter by sub-collection
91
105
if (is.character(subcollection )) {
92
- if (length(subcollection ) > 1 ) {
93
- stop(" Please specify only one subcollection at a time." )
94
- }
95
106
if (subcollection %in% mdb $ gs_subcollection ) {
96
107
mdb <- dplyr :: filter(mdb , .data $ gs_subcollection == subcollection )
97
108
} else if (subcollection %in% gsub(" .*:" , " " , mdb $ gs_subcollection )) {
0 commit comments