Skip to content

Commit 59d6544

Browse files
committed
Expand the set of allowed species
1 parent 7e18b6d commit 59d6544

20 files changed

Lines changed: 81 additions & 53 deletions

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Add argument to define the assays(s) to use for exported values and barplots
77
* Harmonize treatment of merged groups in runTest and plotVolcano
88
* Sort exported test results by p-value instead of logFC
9+
* Expand the set of allowed species
910

1011
# einprot 0.7.3
1112

R/getSupportedSpecies.R

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,26 @@
1414
#'
1515
getSupportedSpecies <- function() {
1616
data.frame(
17-
taxId = c(10090, 9606, 6239, 7955, 7227, 4932, 284812),
17+
taxId = c(10090, 9606, 6239, 7955, 7227, 4932, 284812, 28377,
18+
9913, 9615, 9796, 9685, 9031, 9544, 13616, 9258,
19+
9598, 10116, 9823, 8364),
1820
species = c("Mus musculus", "Homo sapiens", "Caenorhabditis elegans",
1921
"Danio rerio", "Drosophila melanogaster",
2022
"Saccharomyces cerevisiae",
21-
"Schizosaccharomyces pombe 972h-"),
23+
"Schizosaccharomyces pombe 972h-",
24+
"Anolis carolinensis", "Bos taurus",
25+
"Canis lupus familiaris", "Equus caballus",
26+
"Felis catus", "Gallus gallus",
27+
"Macaca mulatta", "Monodelphis domestica",
28+
"Ornithorhynchus anatinus", "Pan troglodytes",
29+
"Rattus norvegicus", "Sus scrofa",
30+
"Xenopus tropicalis"),
2231
speciesCommon = c("mouse", "human", "roundworm", "zebrafish",
23-
"fruitfly", "baker's yeast", "fission yeast")
32+
"fruitfly", "baker's yeast", "fission yeast",
33+
"green anole", "bovine", "dog", "horse", "cat",
34+
"chicken", "rhesus macaque", "opossum",
35+
"platypus", "chimpanzee", "Norway rat",
36+
"pig", "tropical clawed frog")
2437
)
2538
}
2639

@@ -44,6 +57,8 @@ getSupportedSpecies <- function() {
4457
#' getSpeciesInfo("mouse")
4558
#' getSpeciesInfo(6239)
4659
#' getSpeciesInfo("Homo sapiens")
60+
#' ## unsupported species
61+
#' getSpeciesInfo("E.coli")
4762
#'
4863
getSpeciesInfo <- function(species) {
4964
stopifnot(length(species) == 1)
@@ -56,21 +71,26 @@ getSpeciesInfo <- function(species) {
5671
species_common <-
5772
taxTable$speciesCommon[match(tolower(species),
5873
tolower(taxTable$speciesCommon))]
74+
tax_id <- taxTable$taxId[match(species_id, taxTable$species)]
5975
} else if (tolower(species) %in% tolower(taxTable$species)) {
6076
species_id <- taxTable$species[match(tolower(species),
6177
tolower(taxTable$species))]
6278
species_common <-
6379
taxTable$speciesCommon[match(tolower(species),
6480
tolower(taxTable$species))]
81+
tax_id <- taxTable$taxId[match(species_id, taxTable$species)]
6582
} else if (species %in% taxTable$taxId) {
6683
species_id <- taxTable$species[match(species,
6784
taxTable$taxId)]
6885
species_common <- taxTable$speciesCommon[match(species,
6986
taxTable$taxId)]
87+
tax_id <- taxTable$taxId[match(species_id, taxTable$species)]
7088
} else {
71-
stop("Unknown species ", species)
89+
warning("Unknown species ", species)
90+
species_id <- species
91+
species_common <- ""
92+
tax_id <- NA_real_
7293
}
73-
tax_id <- taxTable$taxId[match(species_id, taxTable$species)]
7494

7595
list(species = species_id,
7696
speciesCommon = species_common,

R/getUniProtToGeneSymbolMapping.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
f <- "YEAST_559292_idmapping.dat.gz"
1919
} else if (spi$species == "Schizosaccharomyces pombe 972h-") {
2020
f <- "SCHPO_284812_idmapping.dat.gz"
21+
} else if (spi$species == "Gallus gallus") {
22+
f <- "CHICK_9031_idmapping.dat.gz"
23+
} else if (spi$species == "Rattus norvegicus") {
24+
f <- "RAT_10116_idmapping.dat.gz"
2125
} else {
2226
stop("Unsupported species")
2327
}

R/makeDbLinkTable.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ makeDbLinkTable <- function(df, idCol, speciesCommon,
213213
.assertVector(x = df, type = "data.frame")
214214
.assertScalar(x = idCol, type = "character", validValues = colnames(df))
215215
.assertScalar(x = speciesCommon, type = "character",
216-
validValues = getSupportedSpecies()$speciesCommon)
216+
validValues = c("", getSupportedSpecies()$speciesCommon))
217217
.assertScalar(x = addSpeciesSpecificColumns, type = "logical")
218218
.assertVector(x = convTablePomBase, type = "data.frame", allowNULL = TRUE)
219219
.assertVector(x = convTableWormBase, type = "data.frame",

R/prepareFeatureCollections.R

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -135,21 +135,25 @@ prepareFeatureCollections <- function(sce, idCol, includeFeatureCollections,
135135
## -------------------------------------------------------------------------
136136
if ("complexes" %in% includeFeatureCollections) {
137137
complexes <- readRDS(complexDbPath)
138-
if (speciesInfo$speciesCommon %in% names(complexes)) {
139-
crl <- complexes[[speciesInfo$speciesCommon]]
140-
} else if (speciesInfo$species %in% names(complexes)) {
141-
crl <- complexes[[speciesInfo$species]]
138+
if (any(c(speciesInfo$speciesCommon, speciesInfo$species) %in%
139+
names(complexes))) {
140+
if (speciesInfo$speciesCommon %in% names(complexes)) {
141+
crl <- complexes[[speciesInfo$speciesCommon]]
142+
} else if (speciesInfo$species %in% names(complexes)) {
143+
crl <- complexes[[speciesInfo$species]]
144+
}
145+
if (complexSpecies == "current") {
146+
## Only test complexes defined for the current species
147+
crl <- crl[S4Vectors::mcols(crl)$Species.common %in%
148+
c(speciesInfo$species, speciesInfo$speciesCommon)]
149+
}
150+
S4Vectors::mcols(crl)$genes <- vapply(
151+
crl, function(w) gsub(pat, "\\1; ", paste(w, collapse = ";")), "")
152+
S4Vectors::mcols(crl)$nGenes <- lengths(crl)
142153
} else {
143-
stop("No complex database available for the current species")
154+
warning("No complex database available for the current species")
155+
crl <- IRanges::CharacterList()
144156
}
145-
if (complexSpecies == "current") {
146-
## Only test complexes defined for the current species
147-
crl <- crl[S4Vectors::mcols(crl)$Species.common %in%
148-
c(speciesInfo$species, speciesInfo$speciesCommon)]
149-
}
150-
S4Vectors::mcols(crl)$genes <- vapply(
151-
crl, function(w) gsub(pat, "\\1; ", paste(w, collapse = ";")), "")
152-
S4Vectors::mcols(crl)$nGenes <- lengths(crl)
153157
} else {
154158
crl <- IRanges::CharacterList()
155159
}
@@ -185,7 +189,8 @@ prepareFeatureCollections <- function(sce, idCol, includeFeatureCollections,
185189
## -------------------------------------------------------------------------
186190
## GO terms
187191
## -------------------------------------------------------------------------
188-
if ("GO" %in% includeFeatureCollections) {
192+
if ("GO" %in% includeFeatureCollections &&
193+
speciesInfo$species %in% getSupportedSpecies()$species) {
189194
goannots <- msigdbr::msigdbr(species = speciesInfo$species,
190195
category = "C5") %>%
191196
dplyr::select("gs_name", "gene_symbol")

inst/extdata/process_FragPipe_template.Rmd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ of the data are provided via [principal component analysis](#run-pca) and
7272
## Get species info and define STRINGdb object
7373
speciesInfo <- getSpeciesInfo(species)
7474
if (is.null(stringDir)) stringDir <- ""
75-
if (is.null(stringIdCol)) {
76-
## If no STRING IDs are extracted, don't do STRING analysis
75+
if (is.null(stringIdCol) || is.na(speciesInfo$taxId)) {
76+
## If no STRING IDs are extracted or an unknown species is provided,
77+
## don't do STRING analysis
7778
string_db <- NULL
7879
} else {
7980
string_db <- tryCatch({

inst/extdata/process_MaxQuant_template.Rmd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ of the data are provided via [principal component analysis](#run-pca) and
7272
## Get species info and define STRINGdb object
7373
speciesInfo <- getSpeciesInfo(species)
7474
if (is.null(stringDir)) stringDir <- ""
75-
if (is.null(stringIdCol)) {
76-
## If no STRING IDs are extracted, don't do STRING analysis
75+
if (is.null(stringIdCol) || is.na(speciesInfo$taxId)) {
76+
## If no STRING IDs are extracted or an unknown species is provided,
77+
## don't do STRING analysis
7778
string_db <- NULL
7879
} else {
7980
string_db <- tryCatch({

inst/extdata/process_PD_TMT_template.Rmd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ speciesInfo <- getSpeciesInfo(species)
7373
7474
if (inputLevel == "Proteins") {
7575
if (is.null(stringDir)) stringDir <- ""
76-
if (is.null(stringIdCol)) {
77-
## If no STRING IDs are extracted, don't do STRING analysis
76+
if (is.null(stringIdCol) || is.na(speciesInfo$taxId)) {
77+
## If no STRING IDs are extracted or an unknown species is provided,
78+
## don't do STRING analysis
7879
string_db <- NULL
7980
} else {
8081
string_db <- tryCatch({

man/getSpeciesInfo.Rd

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

tests/testthat/test-checkArgumentsFragPipe.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ test_that("argument checking for FP works", {
149149
## species
150150
args <- args0
151151
args$species <- 1
152-
expect_error(do.call(.checkArgumentsFragPipe, args),
153-
"Unknown species 1")
152+
expect_warning(do.call(.checkArgumentsFragPipe, args),
153+
"Unknown species 1")
154154
args$species <- c("Mouse", "Human")
155155
expect_error(do.call(.checkArgumentsFragPipe, args),
156156
"length(species) == 1 is not TRUE", fixed = TRUE)

0 commit comments

Comments
 (0)