Skip to content
This repository was archived by the owner on Oct 14, 2025. It is now read-only.

Commit 21b58ae

Browse files
committed
Seurat output
1 parent bc47e43 commit 21b58ae

File tree

4 files changed

+59
-0
lines changed

4 files changed

+59
-0
lines changed

NAMESPACE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
# Generated by roxygen2: do not edit by hand
22

3+
S3method(as.sparse,DelayedMatrix)
34
export(get_SingleCellExperiment)
45
export(get_metadata)
6+
export(get_seurat)
57
importFrom(BiocGenerics,cbind)
68
importFrom(DBI,dbConnect)
79
importFrom(HDF5Array,HDF5RealizationSink)
810
importFrom(HDF5Array,loadHDF5SummarizedExperiment)
911
importFrom(RSQLite,SQLITE_RO)
1012
importFrom(RSQLite,SQLite)
13+
importFrom(Seurat,as.Seurat)
14+
importFrom(Seurat,as.sparse)
1115
importFrom(SingleCellExperiment,SingleCellExperiment)
1216
importFrom(SummarizedExperiment,"assayNames<-")
1317
importFrom(SummarizedExperiment,colData)

R/query.R

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,25 @@ get_SingleCellExperiment = function(
7878
sce
7979
}
8080

81+
#' @importFrom Seurat as.sparse
82+
#' @exportS3Method
83+
as.sparse.DelayedMatrix = function(x){
84+
# This is glue to ensure the SCE -> Seurat conversion works properly with
85+
# DelayedArray types
86+
as(x, "dgCMatrix")
87+
}
88+
89+
#' Given a data frame of HCA metadata, returns a Seurat object corresponding to the samples in that data frame
90+
#'
91+
#' @inheritDotParams get_SingleCellExperiment
92+
#' @importFrom Seurat as.Seurat
93+
#' @export
94+
get_seurat = function(
95+
...
96+
){
97+
get_SingleCellExperiment(...) |> as.Seurat(data=NULL)
98+
}
99+
81100

82101
#' Returns a data frame of Human Cell Atlas metadata, which should be filtered
83102
#' and ultimately passed into get_SingleCellExperiment.

man/get_seurat.Rd

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-query.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,18 @@ test_that("The genes argument to get_SingleCellExperiment subsets genes", {
1313

1414
expect_gt(sce_full, sce_subset)
1515
})
16+
17+
test_that("get_seurat() returns the appropriate data in Seurat format", {
18+
meta = get_metadata() |> head(2)
19+
20+
sce = get_SingleCellExperiment(meta, genes = "PUM1")
21+
seurat = get_seurat(meta, genes = "PUM1")
22+
23+
# The output should be a Seurat object
24+
expect_s4_class(seurat, "Seurat")
25+
# Both methods should have appropriately subset genes
26+
expect_equal(
27+
rownames(sce),
28+
rownames(seurat)
29+
)
30+
})

0 commit comments

Comments
 (0)