Skip to content

Commit

Permalink
Use arg_match for type in case user provide invalid type name. Better…
Browse files Browse the repository at this point in the history
… error message for rse object.
  • Loading branch information
HediaTnani committed Jan 3, 2024
1 parent 7a2e149 commit ef5c79b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export(qSVA)
export(select_transcripts)
import(SummarizedExperiment)
import(ggplot2)
import(rlang)
importFrom(methods,is)
importFrom(stats,cor)
importFrom(stats,prcomp)
Expand Down
20 changes: 14 additions & 6 deletions R/getDegTx.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion man/getDegTx.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ef5c79b

Please sign in to comment.