diff --git a/NAMESPACE b/NAMESPACE index 3d729d7..336d980 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -67,6 +67,7 @@ importFrom(pheatmap,pheatmap) importFrom(stats,as.formula) importFrom(stats,median) importFrom(stats,sd) +importFrom(stats,setNames) importFrom(utils,modifyList) importFrom(utils,packageVersion) importFrom(utils,read.table) diff --git a/R/ColorAdjustments.R b/R/ColorAdjustments.R index db7e7c0..360fc79 100644 --- a/R/ColorAdjustments.R +++ b/R/ColorAdjustments.R @@ -2,7 +2,7 @@ #' Darkens input colors by a set amount #' #' @description A wrapper for the darken function of the colorspace package. -#' @param colors the color(s) input. Can be a list of colors, for example, /code{dittoColors()}. +#' @param colors the color(s) input. Can be a list of colors, for example, \code{dittoColors()}. #' @param percent.change # between 0 and 1. the percentage to darken by. Defaults to 0.25 if not given. #' @param relative TRUE/FALSE. Whether the percentage should be a relative change versus an absolute one. Default = TRUE. #' @return Return a darkened version of the color in hexadecimal color form (="#RRGGBB" in base 16) @@ -23,7 +23,7 @@ Darken <- function(colors, percent.change = 0.25, relative = TRUE) { #' Lightens input colors by a set amount #' #' @description A wrapper for the lighten function of the colorspace package. -#' @param colors the color(s) input. Can be a list of colors, for example, /code{dittoColors()}. +#' @param colors the color(s) input. Can be a list of colors, for example, \code{dittoColors()}. #' @param percent.change # between 0 and 1. the percentage to darken by. Defaults to 0.25 if not given. #' @param relative TRUE/FALSE. Whether the percentage should be a relative change versus an absolute one. Default = TRUE. #' @return Return a lighter version of the color in hexadecimal color form (="#RRGGBB" in base 16) diff --git a/R/DittoDimPlot.R b/R/DittoDimPlot.R index 6fedbf3..d53d07c 100644 --- a/R/DittoDimPlot.R +++ b/R/DittoDimPlot.R @@ -70,7 +70,7 @@ #' @param shape.legend.title String which sets the title of the shapes legend. Default is \code{shape.by} #' @param assay,slot single strings or integers (SCEs and SEs) or an optionally named vector of such values that set which expression data to use. #' See \code{\link{GeneTargeting}} for specifics and examples -- Seurat and SingleCellExperiment objects deal with these differently, and functionality additions in dittoSeq have led to some minimal divergence from the native methodologies. -#' @param adjustment When plotting gene / feature expression, should that data be used directly (default) or should it be adjusted to be +#' @param adjustment \code{NULL} for off or a recognized string indicating if numeric \code{var}-data should be used directly (default) or should be adjusted to be #' \itemize{ #' \item{"z-score": scaled with the scale() function to produce a relative-to-mean z-score representation} #' \item{"relative.to.max": divided by the maximum expression value to give percent of max values between [0,1]} diff --git a/R/DittoScatterPlot.R b/R/DittoScatterPlot.R index 271e8e0..9ec2b35 100644 --- a/R/DittoScatterPlot.R +++ b/R/DittoScatterPlot.R @@ -33,7 +33,7 @@ #' @param colors Integer vector, the indexes / order, of colors from color.panel to actually use #' @param assay.x,assay.y,assay.color,assay.extra,slot.x,slot.y,slot.color,slot.extra single strings or integers (SCEs and SEs) or an optionally named vector of such values that set which expression data to use for each given data target. #' See \code{\link{GeneTargeting}} for specifics and examples -- Seurat and SingleCellExperiment objects deal with these differently, and functionality additions in dittoSeq have led to some minimal divergence from the native methodologies. -#' @param adjustment.x,adjustment.y,adjustment.color,adjustment.extra For the given data target, when targeting gene / feature expression, should that data be used directly (default) or should it be adjusted to be +#' @param adjustment.x,adjustment.y,adjustment.color,adjustment.extra \code{NULL} for off or a recognized string indicating if, for the given data target, when targeting numeric data, that data should be used directly (default) or should be adjusted to be #' \itemize{ #' \item{"z-score": scaled with the scale() function to produce a relative-to-mean z-score representation} #' \item{"relative.to.max": divided by the maximum expression value to give percent of max values between [0,1]} diff --git a/R/dittoDotPlot.R b/R/dittoDotPlot.R index d80436c..e50a484 100644 --- a/R/dittoDotPlot.R +++ b/R/dittoDotPlot.R @@ -22,9 +22,9 @@ #' adding \code{theme(strip.placement = "outside", strip.background.y = element_blank())} to the given \code{theme} (or 'x' counterpart depending on \code{vars.dir}) #' @param summary.fxn.color,summary.fxn.size A function which sets how color or size will be used to summarize variables' data for each group. #' Any function can be used as long as it takes in a numeric vector and returns a single numeric value. -#' @param scale String which sets whether the values shown with color (default: mean non-zero expression) should be centered and scaled. +#' @param scale String which sets whether the values shown with color should be centered and scaled after being summarized per \code{group.by} groups. #' @param size Number which sets the visual dot size associated with the highest value shown by dot size (default: percent non-zero expression). -#' @param adjustment Should expression data be used directly (default) or should it be adjusted to be +#' @param adjustment \code{NULL} for off or a recognized string indicating if \code{vars}-data should be used directly (default) or, prior to any potential scaling per groupings controlled via \code{scale}, should be adjusted to be #' \itemize{ #' \item{"z-score": scaled with the scale() function to produce a relative-to-mean z-score representation} #' \item{"relative.to.max": divided by the maximum expression value to give percent of max values between [0,1]} @@ -597,7 +597,7 @@ dittoDotPlot <- function( ) } -#' @importFrom stats sd +#' @importFrom stats sd setNames .multi_var_gather_raw <- function( object, vars, @@ -623,7 +623,18 @@ dittoDotPlot <- function( } gets_data <- if (length(meta_gets)>0) { - getMetas(object, names.only = FALSE)[, meta_gets, drop = FALSE] + data.frame( + setNames( + lapply( + meta_gets, + function(m) { + # Individual pulls for applying adjustments + meta(m, object, adjustment, add.names = FALSE) + } + ), + meta_gets), + row.names = .all_cells(object) + ) } else { data.frame(row.names = .all_cells(object)) } diff --git a/R/dittoPlot.R b/R/dittoPlot.R index a078c8a..b391030 100644 --- a/R/dittoPlot.R +++ b/R/dittoPlot.R @@ -37,7 +37,7 @@ #' See details section for more info. #' @param assay,slot single strings or integers (SCEs and SEs) or an optionally named vector of such values that set which expression data to use. #' See \code{\link{GeneTargeting}} for specifics and examples -- Seurat and SingleCellExperiment objects deal with these differently, and functionality additions in dittoSeq have led to some minimal divergence from the native methodologies. -#' @param adjustment When plotting gene expression / feature counts, should that data be used directly (default) or should it be adjusted to be +#' @param adjustment \code{NULL} for off or a recognized string indicating if \code{var}-data should be used directly (default) or should be adjusted to be #' \itemize{ #' \item{"z-score": scaled with the scale() function to produce a relative-to-mean z-score representation} #' \item{"relative.to.max": divided by the maximum expression value to give percent of max values between [0,1]} diff --git a/R/dittoPlotVarsAcrossGroups.R b/R/dittoPlotVarsAcrossGroups.R index 08a80e8..43c0138 100644 --- a/R/dittoPlotVarsAcrossGroups.R +++ b/R/dittoPlotVarsAcrossGroups.R @@ -15,7 +15,7 @@ #' @param plots String vector which sets the types of plots to include: possibilities = "jitter", "boxplot", "vlnplot", "ridgeplot". #' Order matters: c("vlnplot", "boxplot", "jitter") will put a violin plot in the back, boxplot in the middle, and then individual dots in the front. #' See details section for more info. -#' @param adjustment When plotting gene expression (or antibody, or other forms of counts data), should that data be used directly or should it be adjusted to be +#' @param adjustment \code{NULL} for off or a recognized string indicating if \code{var}-data should be used directly or should be adjusted to be #' \itemize{ #' \item{"z-score": DEFAULT, centered and scaled to produce a relative-to-mean z-score representation} #' \item{NULL: no adjustment, the normal method for all other ditto expression plotting functions} diff --git a/R/gene-getters.R b/R/gene-getters.R index 902f750..de55702 100644 --- a/R/gene-getters.R +++ b/R/gene-getters.R @@ -110,7 +110,7 @@ getGenes <- function( #' @param object A Seurat, SingleCellExperiment, or SummarizedExperiment object. #' @param assay,slot single strings or integers (SCEs and SEs) or a vector of such values that set which expression data to use. #' See \code{\link{GeneTargeting}} for specifics and examples -- Seurat and SingleCellExperiment objects deal with these differently, and functionality additions in dittoSeq have led to some minimal divergence from the native methodologies. -#' @param adjustment Should expression data be used directly (default) or should it be adjusted to be +#' @param adjustment \code{NULL} for off or a recognized string indicating if expression data should be used directly (default) or should instead be adjusted to be #' \itemize{ #' \item{"z-score": scaled with the scale() function to produce a relative-to-mean z-score representation} #' \item{"relative.to.max": divided by the maximum expression value to give percent of max values between [0,1]} diff --git a/R/meta-getters.R b/R/meta-getters.R index d36d0c8..a358852 100644 --- a/R/meta-getters.R +++ b/R/meta-getters.R @@ -86,11 +86,11 @@ getMetas <- function(object, names.only = TRUE){ } #### meta: for extracting the values of a particular metadata for all cells/samples #### -#' Returns the values of a meta.data for all cells/samples +#' Returns the values of a meta.data for all cells/samples #' #' @param meta String, the name of the "metadata" slot to grab. OR "ident" to retireve the clustering of a Seurat \code{object}. #' @param object A Seurat, SingleCellExperiment, or SummarizedExperiment object. -#' @param adjustment A recognized string indicating whether numeric metadata should be used directly (default) versus adjusted to be +#' @param adjustment \code{NULL} for off or a recognized string indicating whether numeric metadata should be used directly (default) versus adjusted to be #' \itemize{ #' \item{"z-score": scaled with the scale() function to produce a relative-to-mean z-score representation} #' \item{"relative.to.max": divided by the maximum expression value to give percent of max values between [0,1]} @@ -100,14 +100,15 @@ getMetas <- function(object, names.only = TRUE){ #' @param adj.fxn A function which takes a vector (of metadata values) and returns a vector of the same length. #' #' For example, \code{function(x) \{log2(x)\}} or \code{as.factor} -#' @return A named vector. +#' @param add.names Logical which sets whether cells'/samples' names should be added as names on the output. +#' @return A vector #' @details #' Retrieves the values of a metadata slot from \code{object}, or the clustering slot if \code{meta = "ident"} and the \code{object} is a Seurat. #' #' If \code{adjustment} or \code{adj.fxn} are provided, then these requested adjustments are applied to these values (\code{adjustment} first). #' Note: Alterations via \code{adjustment} are only applied when metadata is numeric, but \code{adj.fxn} alterations are applied to metadata of any type. #' -#' Lastly, outputs these values are named as the cells'/samples' names. +#' Lastly, if \code{add.names = TRUE} the values are named as the cells'/samples' names before being output. #' @seealso #' \code{\link{metaLevels}} for returning just the unique discrete identities that exist within a metadata slot #' @@ -127,7 +128,7 @@ getMetas <- function(object, names.only = TRUE){ #' @export meta <- function(meta, object, - adjustment = NULL, adj.fxn = NULL) { + adjustment = NULL, adj.fxn = NULL, add.names = TRUE) { if (!isMeta(meta, object)) { stop(dQuote(meta)," is not a metadata of 'object'") @@ -165,7 +166,9 @@ meta <- function(meta, object, } # Add names - names(values) <- .all_cells(object) + if (add.names) { + names(values) <- .all_cells(object) + } values } diff --git a/R/utils-getters.R b/R/utils-getters.R index 3081480..cd92a02 100644 --- a/R/utils-getters.R +++ b/R/utils-getters.R @@ -113,7 +113,7 @@ if (length(var)==1 && is.character(var)) { if (isMeta(var, object)) { - OUT <- meta(var, object) + OUT <- meta(var, object, adjustment) } else if (isGene(var, object, assay)) { OUT <- gene(var, object, assay, slot, adjustment) } diff --git a/man/Darken.Rd b/man/Darken.Rd index 6d3156b..71e5307 100644 --- a/man/Darken.Rd +++ b/man/Darken.Rd @@ -7,7 +7,7 @@ Darken(colors, percent.change = 0.25, relative = TRUE) } \arguments{ -\item{colors}{the color(s) input. Can be a list of colors, for example, /code{dittoColors()}.} +\item{colors}{the color(s) input. Can be a list of colors, for example, \code{dittoColors()}.} \item{percent.change}{# between 0 and 1. the percentage to darken by. Defaults to 0.25 if not given.} diff --git a/man/Lighten.Rd b/man/Lighten.Rd index 82fda89..0fa29be 100644 --- a/man/Lighten.Rd +++ b/man/Lighten.Rd @@ -7,7 +7,7 @@ Lighten(colors, percent.change = 0.25, relative = TRUE) } \arguments{ -\item{colors}{the color(s) input. Can be a list of colors, for example, /code{dittoColors()}.} +\item{colors}{the color(s) input. Can be a list of colors, for example, \code{dittoColors()}.} \item{percent.change}{# between 0 and 1. the percentage to darken by. Defaults to 0.25 if not given.} diff --git a/man/dittoDimPlot.Rd b/man/dittoDimPlot.Rd index eb0e89d..354863d 100644 --- a/man/dittoDimPlot.Rd +++ b/man/dittoDimPlot.Rd @@ -143,7 +143,7 @@ Useful for making custom splitting/faceting or other additional alterations \emp \item{assay, slot}{single strings or integers (SCEs and SEs) or an optionally named vector of such values that set which expression data to use. See \code{\link{GeneTargeting}} for specifics and examples -- Seurat and SingleCellExperiment objects deal with these differently, and functionality additions in dittoSeq have led to some minimal divergence from the native methodologies.} -\item{adjustment}{When plotting gene / feature expression, should that data be used directly (default) or should it be adjusted to be +\item{adjustment}{\code{NULL} for off or a recognized string indicating if numeric \code{var}-data should be used directly (default) or should be adjusted to be \itemize{ \item{"z-score": scaled with the scale() function to produce a relative-to-mean z-score representation} \item{"relative.to.max": divided by the maximum expression value to give percent of max values between [0,1]} diff --git a/man/dittoDotPlot.Rd b/man/dittoDotPlot.Rd index 8512fa9..1fc5bc8 100644 --- a/man/dittoDotPlot.Rd +++ b/man/dittoDotPlot.Rd @@ -65,7 +65,7 @@ Example: \code{vars = list('Epithelial Cells' = c("gene1","gene2"), Neuron = c(" \item{group.by}{String representing the name of a metadata to use for separating the cells/samples into discrete groups.} -\item{scale}{String which sets whether the values shown with color (default: mean non-zero expression) should be centered and scaled.} +\item{scale}{String which sets whether the values shown with color should be centered and scaled after being summarized per \code{group.by} groups.} \item{split.by}{1 or 2 strings naming discrete metadata to use for splitting the cells/samples into multiple plots with ggplot faceting. \itemize{ @@ -135,7 +135,7 @@ When set to NA, the minimum/maximum of the data are used.} \item{assay, slot}{single strings or integers (SCEs and SEs) or an optionally named vector of such values that set which expression data to use. See \code{\link{GeneTargeting}} for specifics and examples -- Seurat and SingleCellExperiment objects deal with these differently, and functionality additions in dittoSeq have led to some minimal divergence from the native methodologies.} -\item{adjustment}{Should expression data be used directly (default) or should it be adjusted to be +\item{adjustment}{\code{NULL} for off or a recognized string indicating if \code{vars}-data should be used directly (default) or, prior to any potential scaling per groupings controlled via \code{scale}, should be adjusted to be \itemize{ \item{"z-score": scaled with the scale() function to produce a relative-to-mean z-score representation} \item{"relative.to.max": divided by the maximum expression value to give percent of max values between [0,1]} diff --git a/man/dittoHex.Rd b/man/dittoHex.Rd index a694de4..85864d7 100644 --- a/man/dittoHex.Rd +++ b/man/dittoHex.Rd @@ -201,7 +201,7 @@ OR when giving 2 metadatas to \code{split.by}, see \code{\link[ggplot2]{facet_gr \item{assay, slot}{single strings or integers (SCEs and SEs) or an optionally named vector of such values that set which expression data to use. See \code{\link{GeneTargeting}} for specifics and examples -- Seurat and SingleCellExperiment objects deal with these differently, and functionality additions in dittoSeq have led to some minimal divergence from the native methodologies.} -\item{adjustment}{When plotting gene / feature expression, should that data be used directly (default) or should it be adjusted to be +\item{adjustment}{\code{NULL} for off or a recognized string indicating if numeric \code{var}-data should be used directly (default) or should be adjusted to be \itemize{ \item{"z-score": scaled with the scale() function to produce a relative-to-mean z-score representation} \item{"relative.to.max": divided by the maximum expression value to give percent of max values between [0,1]} @@ -298,7 +298,7 @@ Alternatively, can be a directly supplied numeric vector of length equal to the \item{assay.x, assay.y, assay.color, assay.extra, slot.x, slot.y, slot.color, slot.extra}{single strings or integers (SCEs and SEs) or an optionally named vector of such values that set which expression data to use for each given data target. See \code{\link{GeneTargeting}} for specifics and examples -- Seurat and SingleCellExperiment objects deal with these differently, and functionality additions in dittoSeq have led to some minimal divergence from the native methodologies.} -\item{adjustment.x, adjustment.y, adjustment.color, adjustment.extra}{For the given data target, when targeting gene / feature expression, should that data be used directly (default) or should it be adjusted to be +\item{adjustment.x, adjustment.y, adjustment.color, adjustment.extra}{\code{NULL} for off or a recognized string indicating if, for the given data target, when targeting numeric data, that data should be used directly (default) or should be adjusted to be \itemize{ \item{"z-score": scaled with the scale() function to produce a relative-to-mean z-score representation} \item{"relative.to.max": divided by the maximum expression value to give percent of max values between [0,1]} diff --git a/man/dittoPlot.Rd b/man/dittoPlot.Rd index 83693d2..7492b21 100644 --- a/man/dittoPlot.Rd +++ b/man/dittoPlot.Rd @@ -123,7 +123,7 @@ When set to "split", inputs \code{split.nrow}, \code{split.ncol}, and \code{spli \item{assay, slot}{single strings or integers (SCEs and SEs) or an optionally named vector of such values that set which expression data to use. See \code{\link{GeneTargeting}} for specifics and examples -- Seurat and SingleCellExperiment objects deal with these differently, and functionality additions in dittoSeq have led to some minimal divergence from the native methodologies.} -\item{adjustment}{When plotting gene expression / feature counts, should that data be used directly (default) or should it be adjusted to be +\item{adjustment}{\code{NULL} for off or a recognized string indicating if \code{var}-data should be used directly (default) or should be adjusted to be \itemize{ \item{"z-score": scaled with the scale() function to produce a relative-to-mean z-score representation} \item{"relative.to.max": divided by the maximum expression value to give percent of max values between [0,1]} diff --git a/man/dittoPlotVarsAcrossGroups.Rd b/man/dittoPlotVarsAcrossGroups.Rd index 7a3bff2..266836a 100644 --- a/man/dittoPlotVarsAcrossGroups.Rd +++ b/man/dittoPlotVarsAcrossGroups.Rd @@ -98,7 +98,7 @@ See details section for more info.} \item{assay, slot}{single strings or integers (SCEs and SEs) or an optionally named vector of such values that set which expression data to use. See \code{\link{GeneTargeting}} for specifics and examples -- Seurat and SingleCellExperiment objects deal with these differently, and functionality additions in dittoSeq have led to some minimal divergence from the native methodologies.} -\item{adjustment}{When plotting gene expression (or antibody, or other forms of counts data), should that data be used directly or should it be adjusted to be +\item{adjustment}{\code{NULL} for off or a recognized string indicating if \code{var}-data should be used directly or should be adjusted to be \itemize{ \item{"z-score": DEFAULT, centered and scaled to produce a relative-to-mean z-score representation} \item{NULL: no adjustment, the normal method for all other ditto expression plotting functions} diff --git a/man/dittoScatterPlot.Rd b/man/dittoScatterPlot.Rd index 17d491f..969d510 100644 --- a/man/dittoScatterPlot.Rd +++ b/man/dittoScatterPlot.Rd @@ -139,7 +139,7 @@ OR when giving 2 metadatas to \code{split.by}, see \code{\link[ggplot2]{facet_gr \item{assay.x, assay.y, assay.color, assay.extra, slot.x, slot.y, slot.color, slot.extra}{single strings or integers (SCEs and SEs) or an optionally named vector of such values that set which expression data to use for each given data target. See \code{\link{GeneTargeting}} for specifics and examples -- Seurat and SingleCellExperiment objects deal with these differently, and functionality additions in dittoSeq have led to some minimal divergence from the native methodologies.} -\item{adjustment.x, adjustment.y, adjustment.color, adjustment.extra}{For the given data target, when targeting gene / feature expression, should that data be used directly (default) or should it be adjusted to be +\item{adjustment.x, adjustment.y, adjustment.color, adjustment.extra}{\code{NULL} for off or a recognized string indicating if, for the given data target, when targeting numeric data, that data should be used directly (default) or should be adjusted to be \itemize{ \item{"z-score": scaled with the scale() function to produce a relative-to-mean z-score representation} \item{"relative.to.max": divided by the maximum expression value to give percent of max values between [0,1]} diff --git a/man/gene.Rd b/man/gene.Rd index d987d76..dbbc0d5 100644 --- a/man/gene.Rd +++ b/man/gene.Rd @@ -22,7 +22,7 @@ gene( \item{assay, slot}{single strings or integers (SCEs and SEs) or a vector of such values that set which expression data to use. See \code{\link{GeneTargeting}} for specifics and examples -- Seurat and SingleCellExperiment objects deal with these differently, and functionality additions in dittoSeq have led to some minimal divergence from the native methodologies.} -\item{adjustment}{Should expression data be used directly (default) or should it be adjusted to be +\item{adjustment}{\code{NULL} for off or a recognized string indicating if expression data should be used directly (default) or should instead be adjusted to be \itemize{ \item{"z-score": scaled with the scale() function to produce a relative-to-mean z-score representation} \item{"relative.to.max": divided by the maximum expression value to give percent of max values between [0,1]} diff --git a/man/meta.Rd b/man/meta.Rd index 15e8bd1..a04471c 100644 --- a/man/meta.Rd +++ b/man/meta.Rd @@ -2,16 +2,16 @@ % Please edit documentation in R/meta-getters.R \name{meta} \alias{meta} -\title{Returns the values of a meta.data for all cells/samples} +\title{Returns the values of a meta.data for all cells/samples} \usage{ -meta(meta, object, adjustment = NULL, adj.fxn = NULL) +meta(meta, object, adjustment = NULL, adj.fxn = NULL, add.names = TRUE) } \arguments{ \item{meta}{String, the name of the "metadata" slot to grab. OR "ident" to retireve the clustering of a Seurat \code{object}.} \item{object}{A Seurat, SingleCellExperiment, or SummarizedExperiment object.} -\item{adjustment}{A recognized string indicating whether numeric metadata should be used directly (default) versus adjusted to be +\item{adjustment}{\code{NULL} for off or a recognized string indicating whether numeric metadata should be used directly (default) versus adjusted to be \itemize{ \item{"z-score": scaled with the scale() function to produce a relative-to-mean z-score representation} \item{"relative.to.max": divided by the maximum expression value to give percent of max values between [0,1]} @@ -22,12 +22,14 @@ Ignored if the target metadata is not numeric.} \item{adj.fxn}{A function which takes a vector (of metadata values) and returns a vector of the same length. For example, \code{function(x) \{log2(x)\}} or \code{as.factor}} + +\item{add.names}{Logical which sets whether cells'/samples' names should be added as names on the output.} } \value{ -A named vector. +A vector } \description{ -Returns the values of a meta.data for all cells/samples +Returns the values of a meta.data for all cells/samples } \details{ Retrieves the values of a metadata slot from \code{object}, or the clustering slot if \code{meta = "ident"} and the \code{object} is a Seurat. @@ -35,7 +37,7 @@ Retrieves the values of a metadata slot from \code{object}, or the clustering sl If \code{adjustment} or \code{adj.fxn} are provided, then these requested adjustments are applied to these values (\code{adjustment} first). Note: Alterations via \code{adjustment} are only applied when metadata is numeric, but \code{adj.fxn} alterations are applied to metadata of any type. -Lastly, outputs these values are named as the cells'/samples' names. +Lastly, if \code{add.names = TRUE} the values are named as the cells'/samples' names before being output. } \examples{ example(importDittoBulk, echo = FALSE) diff --git a/tests/testthat/test-getters.R b/tests/testthat/test-getters.R index 286f9c0..6ffc9ca 100644 --- a/tests/testthat/test-getters.R +++ b/tests/testthat/test-getters.R @@ -1,5 +1,5 @@ # Tests for visualization functions -# library(dittoSeq); library(testthat); source("setup.R"); source("../../R/utils.R"); source("../../R/utils-getters.R"); source("../../R/get.reductions.R"); source("../../R/utils-defaulting.R"); source("test-getters.R") +# library(dittoSeq); library(testthat); for (i in list.files("../../R", pattern="^utils", full.names = TRUE)) source(i); source("test-getters.R") # Make Seurat, if can try(seurat <- Seurat::as.Seurat(sce), silent = TRUE) @@ -28,7 +28,7 @@ test_that("isMeta works for Seurat and SCE", { expect_true(isMeta("score", seurat)) }) -test_that("meta works for Seurat and SCE (+ adjustment/adj.fxn)", { +test_that("meta works for Seurat and SCE (+ adjustment/adj.fxn, add.names)", { expect_type( meta("score", sce), "double") @@ -45,6 +45,12 @@ test_that("meta works for Seurat and SCE (+ adjustment/adj.fxn)", { factor(meta("score", sce)), meta("score", sce, adj.fxn = function(x) {factor(x)})) + expect_true(is.null(names(meta("age", sce, add.names = FALSE)))) + expect_equal( + names(meta("age", sce)), + .all_cells(sce) + ) + skip_if_not(seurat_conversion_worked, message = "Seurat conversion bug") expect_equal( meta("score", sce),