Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bioc review #8

Merged
merged 8 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: iSEEfier
Title: Streamlining the creation of initial states for starting an iSEE instance
Version: 0.99.1
Version: 0.99.2
Authors@R:
c(
person(given = "Najla", family = "Abassi", role = c("aut", "cre"),
Expand Down Expand Up @@ -33,7 +33,8 @@ Imports:
stats,
SummarizedExperiment,
SingleCellExperiment,
visNetwork
visNetwork,
BiocBaseUtils
Suggests:
knitr,
rmarkdown,
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ importClassesFrom(iSEE,FeatureAssayPlot)
importClassesFrom(iSEE,ReducedDimensionPlot)
importClassesFrom(iSEE,RowDataTable)
importClassesFrom(iSEEu,MarkdownBoard)
importFrom(BiocBaseUtils,isCharacter)
importFrom(BiocBaseUtils,isScalarCharacter)
importFrom(BiocBaseUtils,isTRUEorFALSE)
importFrom(SingleCellExperiment,reducedDimNames)
importFrom(SummarizedExperiment,colData)
importFrom(ggplot2,aes)
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# iSEEfier 0.99.2

* Addressing the points raised in the Bioc review
* Better checks of the arguments - more compact and robust
* Explicitly suggesting the instructions to install potentially missing packages for `iSEEnrich()`

# iSEEfier 0.99.1

* Ready for Bioconductor review
Expand Down
60 changes: 34 additions & 26 deletions R/iSEEinit.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
#' iSEEinit: Create an initial state of an iSEE instance for gene expression visualization
#' iSEEinit: Create an initial state of an iSEE instance for gene expression
#' visualization
#'
#' `iSEEinit()` defines the initial setup of an iSEE instance, recommending tailored visual elements to effortlessly illustrate the expression of a gene list in a single view.
#' `iSEEinit()` defines the initial setup of an iSEE instance, recommending
#' tailored visual elements to effortlessly illustrate the expression of a gene
#' list in a single view.
#'
#' @param sce SingleCellExperiment object
#' @param features A character vector containing a list of genes
#' @param reddim_type A string vector containing the dimensionality reduction type
#' @param clusters A character string containing the name of the clusters/cell-type/state...(as listed in the colData of the sce)
#' @param groups A character string of the groups/conditions...(as it appears in the colData of the sce)
#' @param add_markdown_panel A logical indicating whether or not to include the MarkdownBoard panel in the initial configuration
#' @param add_dynamicTable_panel A logical indicating whether or not the DynamicMarkerTable and linked panels should be included in the initial configuration
#' @param reddim_type A string vector containing the dimensionality reduction
#' type
#' @param clusters A character string containing the name of the
#' clusters/cell-type/state...(as listed in the colData of the sce)
#' @param groups A character string of the groups/conditions...(as it appears in
#' the colData of the sce)
#' @param add_markdown_panel A logical indicating whether or not to include the
#' MarkdownBoard panel in the initial configuration
#' @param add_dynamicTable_panel A logical indicating whether or not the
#' DynamicMarkerTable and linked panels should be included in the initial
#' configuration
#'
#' @return A list of "Panel" objects specifying the initial state of iSEE instance
#' @return A list of "Panel" objects specifying the initial state of iSEE
#' instance
#' @export
#' @importFrom methods new
#' @importFrom SummarizedExperiment colData
Expand All @@ -22,14 +32,17 @@
#' @importClassesFrom iSEE RowDataTable
#' @importClassesFrom iSEE ComplexHeatmapPlot
#' @importClassesFrom iSEEu MarkdownBoard
#' @importFrom BiocBaseUtils isCharacter isScalarCharacter isTRUEorFALSE
#'
#'
#' @examples
#' sce <- scRNAseq::RichardTCellData()
#' sce <- scuttle::logNormCounts(sce)
#' sce <- scater::runPCA(sce)
#' sce <- scater::runTSNE(sce)
#' gene_list <- c("ENSMUSG00000026581", "ENSMUSG00000005087", "ENSMUSG00000015437")
#' gene_list <- c("ENSMUSG00000026581",
#' "ENSMUSG00000005087",
#' "ENSMUSG00000015437")
#' cluster <- "stimulus"
#' group <- "single cell quality"
#' initial <- iSEEinit(sce = sce, features = gene_list, clusters = cluster, groups = group)
Expand All @@ -45,22 +58,17 @@ iSEEinit <- function(sce,
if (!is(sce, "SingleCellExperiment"))
stop("Please provide a SingleCellExperiment as input!")

stopifnot(is.character(features))
stopifnot(length(features) > 0)
stopifnot(is.character(features), length(features) > 0)

stopifnot(is.character(reddim_type))
stopifnot(length(reddim_type) == 1)
stopifnot(isScalarCharacter(reddim_type))

stopifnot(is.character(clusters))
stopifnot(length(clusters) == 1)
stopifnot(isScalarCharacter(clusters))

stopifnot(is.character(groups))
stopifnot(length(groups) == 1)
stopifnot(isScalarCharacter(groups))

stopifnot(is.logical(add_markdown_panel))
stopifnot(length(add_markdown_panel) == 1)
stopifnot(is.logical(add_dynamicTable_panel))
stopifnot(length(add_dynamicTable_panel) == 1)
stopifnot(isTRUEorFALSE(add_markdown_panel))

stopifnot(isTRUEorFALSE(add_dynamicTable_panel))

if (!(reddim_type %in% reducedDimNames(sce))) {
available_reddims <- reducedDimNames(sce)
Expand Down Expand Up @@ -179,21 +187,21 @@ iSEEinit <- function(sce,
PanelWidth = 4L)
}

if(add_dynamicTable_panel == TRUE) {
initial[[paste0("ReducedDimensionPlot",length(features)+2)]] <- new(
if (add_dynamicTable_panel == TRUE) {
initial[[paste0("ReducedDimensionPlot",length(features) + 2)]] <- new(
"ReducedDimensionPlot",
Type = reddim_type,
ColorByColumnData = clusters,
ColorBy = "Column data",
SelectionAlpha = 0.05,
ColumnSelectionSource = paste0("FeatureAssayPlot",length(features)+2))
ColumnSelectionSource = paste0("FeatureAssayPlot",length(features) + 2))


initial[["DynamicMarkerTable1"]] <- new(
"DynamicMarkerTable",
ColumnSelectionSource = paste0("ReducedDimensionPlot",length(features)+2))
ColumnSelectionSource = paste0("ReducedDimensionPlot",length(features) + 2))

initial[[paste0("FeatureAssayPlot",length(features)+2)]] <- new(
initial[[paste0("FeatureAssayPlot",length(features) + 2)]] <- new(
"FeatureAssayPlot",
XAxis = "Column data",
XAxisColumnData = groups,
Expand Down
36 changes: 21 additions & 15 deletions R/iSEEnrich.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
#' iSEEnrich
#'
#' `iSEEnrich()` creates an initial state of an iSEE instance for interactive exploration of feature sets extracted from GO and KEGG database,
#' displaying all associated genes in a `RowDataTable` panel.
#' `iSEEnrich()` creates an initial state of an iSEE instance for interactive
#' exploration of feature sets extracted from GO and KEGG database, displaying
#' all associated genes in a `RowDataTable` panel.
#'
#' @param sce SingleCellExperiment object
#' @param collection A character vector specifying the gene set collections of interest (GO,KEGG)
#' @param organism A character string of the org.*.eg.db package to use to extract mappings of gene sets to gene IDs.
#' @param gene_identifier A character string specifying the identifier to use to extract gene IDs for the organism package
#' @param collection A character vector specifying the gene set collections of
#' interest (GO,KEGG)
#' @param organism A character string of the org.*.eg.db package to use to
#' extract mappings of gene sets to gene IDs.
#' @param gene_identifier A character string specifying the identifier to use to
#' extract gene IDs for the organism package
#'
#' @return A list of "Panel" objects specifying the initial state of iSEE instance
#' @return A list of "Panel" objects specifying the initial state of iSEE
#' instance
#' @export iSEEnrich
#' @importFrom iSEE RowDataTable
#' @importFrom iSEEu createGeneSetCommands
#' @importFrom iSEEu registerFeatureSetCommands
#' @importFrom iSEEu FeatureSetTable
#' @importFrom BiocBaseUtils isScalarCharacter
#'
#'
#' @examples
Expand All @@ -27,7 +33,7 @@
#' collection = GO_collection,
#' organism = Mm_organism,
#' gene_identifier = gene_id)
#'
#'
iSEEnrich <- function(sce,
collection = c("GO", "KEGG"),
organism = "org.Hs.eg.db",
Expand All @@ -37,20 +43,19 @@ iSEEnrich <- function(sce,
if (!is(sce, "SingleCellExperiment"))
stop("Please provide a SingleCellExperiment as input!")

stopifnot(is.character(collection))
stopifnot(length(collection) == 1)
stopifnot(isScalarCharacter(collection))

collection <- match.arg(collection, c("GO", "KEGG"))

stopifnot(is.character(organism))
stopifnot(length(organism) == 1)
stopifnot(isScalarCharacter(organism))

stopifnot(is.character(gene_identifier))
stopifnot(length(gene_identifier) == 1)
stopifnot(isScalarCharacter(gene_identifier))

if (!requireNamespace(organism, quietly = TRUE))
stop("Please check the value of the provided orgDb package ",
"(it needs to be installed)...")
"(the package needs to be installed)...",
"If you want to install it run the following line:\n",
"BiocManager::install('", organism,"')")


initial <- list()
Expand All @@ -62,7 +67,8 @@ iSEEnrich <- function(sce,

initial[["FeatureSetTable1"]] <- FeatureSetTable()

initial[["RowDataTable1"]] <- RowDataTable(RowSelectionSource="FeatureSetTable1")
initial[["RowDataTable1"]] <- RowDataTable(
RowSelectionSource = "FeatureSetTable1")

return(
list(
Expand Down
11 changes: 7 additions & 4 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#' @importFrom ggplot2 ggplot aes geom_tile scale_fill_manual scale_y_discrete
#' theme theme_void
#' @importFrom rlang .data
#' @importFrom BiocBaseUtils isCharacter
#'
#' @seealso [view_initial_network()]
#'
Expand All @@ -36,7 +37,9 @@
#' sce <- scater::runPCA(sce)
#' sce <- scater::runTSNE(sce)
#' ## Select some features and aspects to focus on
#' gene_list <- c("ENSMUSG00000026581", "ENSMUSG00000005087", "ENSMUSG00000015437")
#' gene_list <- c("ENSMUSG00000026581",
#' "ENSMUSG00000005087",
#' "ENSMUSG00000015437")
#' cluster <- "stimulus"
#' group <- "single cell quality"
#' initial <- iSEEinit(sce = sce,
Expand Down Expand Up @@ -73,7 +76,7 @@ view_initial_tiles <- function(initial) {
cur_row <- 1

# fill in the tiles vector "with the rule of 12"
for(i in seq_len(length(initial))) {
for (i in seq_len(length(initial))) {
this_width <- panel_widths[i]
this_paneltype <- panel_types[i]
this_color <- iSEE_panel_colors[this_paneltype]
Expand Down Expand Up @@ -133,7 +136,7 @@ view_initial_tiles <- function(initial) {
name = "iSEE Panel type",
values = iSEE_panel_colors
) +
theme(legend.position="bottom")
theme(legend.position = "bottom")

return(p)
}
Expand Down Expand Up @@ -328,7 +331,7 @@ glue_initials <- function(...,
allowed_panels <- names(iSEE_panel_colors)

if (!is.null(custom_panels_allowed)) {
stopifnot(is.character(custom_panels_allowed))
stopifnot(isCharacter(custom_panels_allowed))
allowed_panels <- c(allowed_panels, custom_panels_allowed)
}

Expand Down
30 changes: 21 additions & 9 deletions man/iSEEinit.Rd

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

17 changes: 11 additions & 6 deletions man/iSEEnrich.Rd

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

4 changes: 3 additions & 1 deletion man/view_initial_tiles.Rd

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

Loading
Loading