diff --git a/NAMESPACE b/NAMESPACE index 9bdfe86..347bb19 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,6 +9,7 @@ export(qSVA) export(select_transcripts) import(SummarizedExperiment) import(ggplot2) +import(rlang) importFrom(methods,is) importFrom(stats,cor) importFrom(stats,prcomp) diff --git a/R/getDegTx.R b/R/getDegTx.R index 9104349..108bd27 100644 --- a/R/getDegTx.R +++ b/R/getDegTx.R @@ -28,15 +28,23 @@ #' #' @export #' @importFrom methods is +#' @import rlang #' #' @examples #' getDegTx(covComb_tx_deg) #' stopifnot(mean(rowMeans(assays(covComb_tx_deg)$tpm)) > 1) -getDegTx <- function(rse_tx, type = "cell_component", sig_transcripts = select_transcripts(type), assayname = "tpm") { - stopifnot(is(rse_tx, "RangedSummarizedExperiment")) - rse_tx <- rse_tx[rownames(rse_tx) %in% sig_transcripts, , drop = FALSE] - if (mean(rowMeans(assays(rse_tx)[[assayname]])) < 1) { - warning("The transcripts selected are lowly expressed in your dataset. This can impact downstream analysis.") +getDegTx <- function(rse_tx, type = c("cell_component", "standard", "top1500"), sig_transcripts = select_transcripts(type), assayname = "tpm") { + + type = arg_match(type) + + # Validate rse_tx is a RangedSummarizedExperiment object + if (!is(rse_tx, "RangedSummarizedExperiment")) { + stop("Error: rse_tx must be a RangedSummarizedExperiment object.") + } + + rse_tx <- rse_tx[rownames(rse_tx) %in% sig_transcripts, , drop = FALSE] + if (mean(rowMeans(assays(rse_tx)[[assayname]])) < 1) { + warning("The transcripts selected are lowly expressed in your dataset. This can impact downstream analysis.") } - return(rse_tx) + return(rse_tx) } diff --git a/man/getDegTx.Rd b/man/getDegTx.Rd index 5ac0e48..2765b17 100644 --- a/man/getDegTx.Rd +++ b/man/getDegTx.Rd @@ -6,7 +6,7 @@ \usage{ getDegTx( rse_tx, - type = "cell_component", + type = c("cell_component", "standard", "top1500"), sig_transcripts = select_transcripts(type), assayname = "tpm" )