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

Commit 1b9407f

Browse files
authored
Merge pull request #25 from stemangiola/seurat
Seurat output
2 parents bc47e43 + d6e411d commit 1b9407f

File tree

5 files changed

+73
-13
lines changed

5 files changed

+73
-13
lines changed

DESCRIPTION

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,20 @@ Imports:
2323
RSQLite,
2424
dbplyr
2525
Suggests:
26-
here,
27-
stringr,
28-
Seurat,
29-
tidyseurat,
30-
scMerge,
31-
DelayedArray,
32-
openssl,
33-
cellxgenedp,
34-
SingleCellExperiment,
35-
celldex,
36-
SingleR,
37-
tools,
38-
rmarkdown
26+
here,
27+
stringr,
28+
Seurat,
29+
tidyseurat,
30+
scMerge,
31+
DelayedArray,
32+
openssl,
33+
cellxgenedp,
34+
SingleCellExperiment,
35+
celldex,
36+
SingleR,
37+
tools,
38+
rmarkdown,
39+
SeuratObject
3940
VignetteBuilder:
4041
knitr
4142
RdMacros:

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(SeuratObject,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 SeuratObject 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)