Skip to content

Commit

Permalink
Clean up imports by importing individual functions where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-Eagles committed Nov 7, 2023
1 parent fa3d884 commit 25dc155
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
7 changes: 4 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ export(spot_plot_sparsity)
export(spot_plot_z_score)
import(Matrix)
import(MatrixGenerics)
import(SummarizedExperiment)
import(SpatialExperiment)
import(Seurat)
import(SpatialExperiment)
import(ggplot2)
import(spatialLIBD)
import(viridisLite)
importFrom(SummarizedExperiment,colData)
importFrom(stats,prcomp)
importFrom(viridisLite,plasma)
15 changes: 10 additions & 5 deletions R/multi_gene.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
#'
#' @export
#' @author Nicholas J. Eagles
#' @import SpatialExperiment SummarizedExperiment Matrix MatrixGenerics
#' @import SpatialExperiment Matrix MatrixGenerics
#' @importFrom SummarizedExperiment colData
#' @family Spot plots summarizing expression of multiple genes simultaneously
#'
#' @examples
Expand Down Expand Up @@ -80,7 +81,8 @@ spot_plot_z_score <- function(spe, genes, sample_id, assayname = "logcounts", mi
#'
#' @export
#' @author Nicholas J. Eagles
#' @import SpatialExperiment SummarizedExperiment Matrix MatrixGenerics
#' @import SpatialExperiment Matrix MatrixGenerics
#' @importFrom SummarizedExperiment colData
#' @family Spot plots summarizing expression of multiple genes simultaneously
#'
#' @examples
Expand Down Expand Up @@ -138,7 +140,9 @@ spot_plot_sparsity <- function(spe, genes, sample_id, assayname = "counts", minC
#'
#' @export
#' @author Nicholas J. Eagles
#' @import SpatialExperiment SummarizedExperiment
#' @import SpatialExperiment
#' @importFrom SummarizedExperiment colData
#' @importFrom stats prcomp
#' @family Spot plots summarizing expression of multiple genes simultaneously
#'
#' @examples
Expand All @@ -164,7 +168,7 @@ spot_plot_pca <- function(spe, genes, sample_id, assayname = "logcounts", minCou
spe, genes, sample_id, assayname, minCount, ...
)

pc_exp <- prcomp(t(assays(spe)[[assayname]]), center = TRUE, scale = TRUE)
pc_exp <- stats::prcomp(t(assays(spe)[[assayname]]), center = TRUE, scale = TRUE)
spe$pc_select_genes <- pc_exp$x[, "PC1"]

# Given that:
Expand Down Expand Up @@ -198,7 +202,8 @@ spot_plot_pca <- function(spe, genes, sample_id, assayname = "logcounts", minCou
#'
#' @author Nicholas J. Eagles
#' @inheritParams spot_plot_z_score
#' @import SpatialExperiment SummarizedExperiment
#' @import SpatialExperiment
#' @importFrom SummarizedExperiment colData
#' @return \code{SpatialExperiment} subsetted to the specified sample and to
#' each of the non-constant-expression genes
.multi_gene_validity_check <- function(spe, genes, sample_id, assayname, minCount, ...) {
Expand Down
9 changes: 5 additions & 4 deletions R/spe_seurat.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#'
#' @export
#' @author Nicholas J. Eagles
#' @import SummarizedExperiment SpatialExperiment spatialLIBD Seurat
#' @import SpatialExperiment spatialLIBD Seurat
#' @importFrom SummarizedExperiment colData
#'
#' @examples
#'
Expand All @@ -24,8 +25,8 @@
#' spe <- spatialLIBD::fetch_data(type = "spatialDLPFC_Visium_example_subset")
#' spe$array_row_transformed = spe$array_row
#' spe$array_col_transformed = spe$array_col
#' spe$pxl_row_in_fullres_transformed = spatialCoords(spe)[,'pxl_row_in_fullres']
#' spe$pxl_col_in_fullres_transformed = spatialCoords(spe)[,'pxl_col_in_fullres']
#' spe$pxl_row_in_fullres_transformed = SpatialExperiment::spatialCoords(spe)[,'pxl_row_in_fullres']
#' spe$pxl_col_in_fullres_transformed = SpatialExperiment::spatialCoords(spe)[,'pxl_col_in_fullres']
#' colnames(spe) = spe$key
#'
#' # Convert
Expand Down Expand Up @@ -59,7 +60,7 @@ spe_to_seurat = function(spe, verbose = TRUE) {
}

if (verbose) message("Running 'as.Seurat(spe)'...")
seur = as.Seurat(spe)
seur = Seurat::as.Seurat(spe)

for (sample_id in unique(spe$sample_id)) {
if (verbose) {
Expand Down
4 changes: 3 additions & 1 deletion R/spot_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
#'
#' @export
#' @author Nicholas J. Eagles
#' @import viridisLite spatialLIBD ggplot2 SpatialExperiment SummarizedExperiment
#' @import spatialLIBD ggplot2 SpatialExperiment
#' @importFrom viridisLite plasma
#' @importFrom SummarizedExperiment colData
#'
#' @examples
#'
Expand Down
4 changes: 2 additions & 2 deletions man/spe_to_seurat.Rd

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

0 comments on commit 25dc155

Please sign in to comment.