-
Notifications
You must be signed in to change notification settings - Fork 0
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
Update sce_to_seurat
function
#123
Changes from 6 commits
099dd56
8d17886
2dc851a
7594592
de00899
e745277
6dd5790
823ad4d
cc3b0b5
04c6556
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
_snaps/ | ||
test_anndata.h5 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ rowData(altExp(sce, alt_name)) <- data.frame("alt_test_row" = sample(0:5, 10, re | |
tibble::column_to_rownames("alt_id") %>% | ||
DataFrame() | ||
|
||
logcounts(sce) <- counts(sce) # dummy logcounts to test the assay_name argument | ||
|
||
test_that("Converting SCE to Seurat objects works as expected", { | ||
|
||
seurat_object <- sce_to_seurat(sce) | ||
|
@@ -34,7 +36,32 @@ test_that("Converting SCE to Seurat objects works as expected", { | |
|
||
# can't directly check that coldata is equal because of added columns in seurat object | ||
expect_true(all(colnames(coldata_sce) %in% colnames(seurat_object@meta.data))) | ||
expect_equal(rowdata_sce, seurat_object[["RNA"]]@var.features) | ||
expect_equal(rowdata_sce, seurat_object[["RNA"]]@var.features) # since default "counts" is used, RNA name is expected here | ||
expect_equal(metadata(sce), seurat_object@misc) | ||
|
||
# check that altExp data was converted and rowData | ||
expect_s4_class(seurat_object[[alt_name]], 'Assay') | ||
alt_rowdata_sce <- as.data.frame(rowData(altExp(sce, alt_name))) | ||
expect_equal(alt_rowdata_sce, seurat_object[[alt_name]]@var.features) | ||
|
||
}) | ||
|
||
|
||
test_that("Converting SCE to Seurat objects works as expected for custom assay name", { | ||
|
||
seurat_object <- sce_to_seurat(sce, assay_name = "logcounts") | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I would also include an explicit check for the assay name being logcounts here? I don't know that you need the rest of the checks but they can't hurt to have since they should all pass if it's converted successfully. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 6dd5790! |
||
# check that column names of Seurat object are derived from SCE object | ||
# they won't necessarily be equal if some cells with 0 counts were removed | ||
expect_true(all(colnames(seurat_object) %in% colnames(sce))) | ||
sjspielman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# check that attached metadata/coldata/rowdata in SCE are present in seurat object | ||
coldata_sce <- as.data.frame(colData(sce)) | ||
rowdata_sce <- as.data.frame(rowData(sce)) | ||
|
||
# can't directly check that coldata is equal because of added columns in seurat object | ||
expect_true(all(colnames(coldata_sce) %in% colnames(seurat_object@meta.data))) | ||
expect_equal(rowdata_sce, seurat_object[["logcounts"]]@var.features) # since default "counts" is used, RNA name is expected here | ||
expect_equal(metadata(sce), seurat_object@misc) | ||
|
||
# check that altExp data was converted and rowData | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Josh and I have been going back and forth on committing and removing this change because for some reason we have different versions but can't figure out why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to join in the party!