4848# ' specifies relative difference threshold and determines the first point
4949# ' where the relative change in differences between consecutive quantiles
5050# ' exceeds this threshold. (Default: \code{0.1}) For \code{"cutoff"},
51- # ' values less than or equal to the threshold are replaced with \code{NA }.
51+ # ' values less than or equal to the threshold are replaced with \code{value }.
5252# ' (Default: \code{0})
53+ # ' \item \code{value}: \code{Numeric scalar}. For \code{"cutoff"}, specifies
54+ # ' the replacement value for counts less than or equal to the threshold.
55+ # ' (Default: \code{NA})
5356# ' \item \code{tree}: \code{phylo}. Phylogeny used in PhILR transformation.
5457# ' If \code{NULL}, the tree is retrieved from \code{x}.
5558# ' (Default: \code{NULL}).
102105# '
103106# ' \item 'cutoff': In some ecological studies, only strictly positive values
104107# ' are taken into account. This method keeps only values greater than
105- # ' \code{threshold} and replaces all other values with \code{NA }.
108+ # ' \code{threshold} and replaces all other values with \code{value }.
106109# '
107110# ' }
108111# '
@@ -813,10 +816,13 @@ setMethod("transformAssay", signature = c(x = "SingleCellExperiment"),
813816}
814817
815818# This function replaces values under or equal to threshold with NA
816- .apply_cutoff <- function (mat , threshold = 0 , ... ){
819+ .apply_cutoff <- function (mat , threshold = 0 , value = NA , ... ){
817820 if ( ! .is_a_numeric(threshold ) ){
818- stop(" 'threshold' must be a single numierc value." , call. = FALSE )
821+ stop(" 'threshold' must be a single numeric value." , call. = FALSE )
822+ }
823+ if ( length(value ) != 1L || (! is.numeric(value ) && ! is.na(value )) ){
824+ stop(" 'value' must be a single numeric value or NA." , call. = FALSE )
819825 }
820- mat [ mat < = threshold ] <- NA
826+ mat [ mat < = threshold ] <- value
821827 return (mat )
822828}
0 commit comments