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

Seurat output #25

Merged
merged 2 commits into from
Oct 28, 2022
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
27 changes: 14 additions & 13 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,20 @@ Imports:
RSQLite,
dbplyr
Suggests:
here,
stringr,
Seurat,
tidyseurat,
scMerge,
DelayedArray,
openssl,
cellxgenedp,
SingleCellExperiment,
celldex,
SingleR,
tools,
rmarkdown
here,
stringr,
Seurat,
tidyseurat,
scMerge,
DelayedArray,
openssl,
cellxgenedp,
SingleCellExperiment,
celldex,
SingleR,
tools,
rmarkdown,
SeuratObject
VignetteBuilder:
knitr
RdMacros:
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Generated by roxygen2: do not edit by hand

S3method(as.sparse,DelayedMatrix)
export(get_SingleCellExperiment)
export(get_metadata)
export(get_seurat)
importFrom(BiocGenerics,cbind)
importFrom(DBI,dbConnect)
importFrom(HDF5Array,HDF5RealizationSink)
importFrom(HDF5Array,loadHDF5SummarizedExperiment)
importFrom(RSQLite,SQLITE_RO)
importFrom(RSQLite,SQLite)
importFrom(Seurat,as.Seurat)
importFrom(SeuratObject,as.sparse)
importFrom(SingleCellExperiment,SingleCellExperiment)
importFrom(SummarizedExperiment,"assayNames<-")
importFrom(SummarizedExperiment,colData)
Expand Down
19 changes: 19 additions & 0 deletions R/query.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,25 @@ get_SingleCellExperiment = function(
sce
}

#' @importFrom SeuratObject as.sparse
#' @exportS3Method
as.sparse.DelayedMatrix = function(x){
# This is glue to ensure the SCE -> Seurat conversion works properly with
# DelayedArray types
as(x, "dgCMatrix")
}

stemangiola marked this conversation as resolved.
Show resolved Hide resolved
#' Given a data frame of HCA metadata, returns a Seurat object corresponding to the samples in that data frame
#'
#' @inheritDotParams get_SingleCellExperiment
#' @importFrom Seurat as.Seurat
#' @export
get_seurat = function(
...
){
get_SingleCellExperiment(...) |> as.Seurat(data=NULL)
}


#' Returns a data frame of Human Cell Atlas metadata, which should be filtered
#' and ultimately passed into get_SingleCellExperiment.
Expand Down
21 changes: 21 additions & 0 deletions man/get_seurat.Rd

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

15 changes: 15 additions & 0 deletions tests/testthat/test-query.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,18 @@ test_that("The genes argument to get_SingleCellExperiment subsets genes", {

expect_gt(sce_full, sce_subset)
})

test_that("get_seurat() returns the appropriate data in Seurat format", {
meta = get_metadata() |> head(2)

sce = get_SingleCellExperiment(meta, genes = "PUM1")
seurat = get_seurat(meta, genes = "PUM1")

# The output should be a Seurat object
expect_s4_class(seurat, "Seurat")
# Both methods should have appropriately subset genes
expect_equal(
rownames(sce),
rownames(seurat)
)
})