-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for new function and updating news
- Loading branch information
1 parent
d34472e
commit 9bd53bb
Showing
9 changed files
with
438 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
267 changes: 267 additions & 0 deletions
267
tests/testthat/_snaps/GTEX_expression/gtex-expression-on-mage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
test_that("embryo_expression() works", { | ||
|
||
## returns a SingleCellExperiment | ||
## n valid genes in input returns a SingleCellExperiment of n expected rownames | ||
## returns a warning when an invalid gene is entered | ||
## works with only one gene in input | ||
## error if no dataset is specified | ||
expect_error(embryo_expression("MAGEA1")) | ||
expect_warning(res <- embryo_expression(c("MAGEA1", "xxx"), | ||
dataset = "Petropoulos", | ||
values_only = TRUE), "names invalid") | ||
expect_s4_class(res, "SingleCellExperiment") | ||
expect_equal(nrow(res), 1) | ||
expect_identical(rownames(res), "MAGEA1") | ||
|
||
|
||
## Test that the function returns a heatmap by default | ||
## Test that returns the expected heatmap | ||
## res <- embryo_expression(c("MAGEA1", "MAGEA3", "MAGEA4"), | ||
## dataset = "Petropoulos") | ||
## expect_s4_class(res, "Heatmap") | ||
|
||
## Same with Zhu | ||
expect_warning(res <- embryo_expression(c("MAGEA1", "xxx"), | ||
dataset = "Zhu", | ||
values_only = TRUE), "names invalid") | ||
expect_s4_class(res, "SingleCellExperiment") | ||
expect_equal(nrow(res), 1) | ||
expect_identical(rownames(res), "MAGEA1") | ||
|
||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
test_that("embryos_mean_methylation() works", { | ||
|
||
## returns a RangedSummarizedExperiment when values_only is set to TRUE | ||
res <- embryos_mean_methylation( | ||
genes = c("MAGEA1", "MAGEA2", "MAGEA4"), | ||
values_only = TRUE) | ||
expect_s4_class(res, "RangedSummarizedExperiment") | ||
expect_equal(nrow(res), 3) | ||
|
||
## selects the expected cell types | ||
my_stages <- c("Morula", "Blastocyst") | ||
res <- embryos_mean_methylation(stage = my_stages, genes = "MAGEA1", | ||
values_only = TRUE) | ||
expect_equal(nrow(res), 1) | ||
expect_true(all(unique(colData(res)$Stage) %in% my_stages)) | ||
|
||
## no valid gene in input returns an empty matrix | ||
expect_warning(res_no_gene <- embryos_mean_methylation( | ||
genes = "xxx", values_only = TRUE), "valid types") | ||
expect_equal(nrow(res_no_gene), 0) | ||
|
||
## Test that the function returns a heatmap by default | ||
## res <- embryos_mean_methylation( | ||
## genes = c("MAGEA1", "MAGEA2", "MAGEA4", "TDRD1")) | ||
## expect_s4_class(res, "Heatmap") | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
test_that("fetal_germcells_expression() works", { | ||
|
||
## returns a SingleCellExperiment | ||
## n valid genes in input returns a SingleCellExperiment of n expected rownames | ||
## returns a warning when an invalid gene is entered | ||
## works with only one gene in input | ||
|
||
expect_warning(res <- fetal_germcells_expression(c("MAGEA1", "xxx"), | ||
values_only = TRUE), "names invalid") | ||
expect_s4_class(res, "SingleCellExperiment") | ||
expect_equal(nrow(res), 1) | ||
expect_identical(rownames(res), "MAGEA1") | ||
|
||
|
||
## Test that the function returns a heatmap by default | ||
## Test that returns the expected heatmap | ||
## res <- fetal_germcells_expression(c("MAGEA1", "MAGEA3", "MAGEA4")) | ||
## expect_s4_class(res, "Heatmap") | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
test_that("fetal_germcells_mean_methylation() works", { | ||
|
||
## returns a SummarizedExperiment when values_only is set to TRUE | ||
res <- fetal_germcells_mean_methylation( | ||
genes = c("MAGEA1", "MAGEA2", "MAGEA4"), | ||
values_only = TRUE) | ||
expect_s4_class(res, "SummarizedExperiment") | ||
expect_equal(nrow(res), 3) | ||
|
||
|
||
## no valid gene in input returns an empty matrix | ||
expect_warning(res_no_gene <- fetal_germcells_mean_methylation( | ||
genes = "xxx", values_only = TRUE), "valid types") | ||
expect_equal(nrow(res_no_gene), 0) | ||
|
||
## Test that the function returns a heatmap by default | ||
## res <- fetal_germcells_mean_methylation( | ||
## genes = c("MAGEA1", "MAGEA2", "MAGEA4", "TDRD1")) | ||
## expect_s4_class(res, "Heatmap") | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
test_that("hESC_expression() works", { | ||
|
||
## returns a SummarizedExperiment | ||
res <- hESC_expression(genes = c("MAGEA1", "MAGEA3"), | ||
values_only = TRUE) | ||
expect_s4_class(res, "SummarizedExperiment") | ||
expect_equal(nrow(res), 2) | ||
expect_identical(sort(rowData(res)$external_gene_name), | ||
sort(c("MAGEA1", "MAGEA3"))) | ||
|
||
## Test the "log_TPM" units argument | ||
res_in_log <- hESC_expression(c("MAGEA1", "MAGEA3"), | ||
units = "log_TPM", | ||
values_only = TRUE) | ||
expect_equal(assay(res_in_log)[, "H1"], log1p(assay(res)[, "H1"])) | ||
|
||
# Check default genes with CTP | ||
res_includeCTP <- hESC_expression(include_CTP = TRUE, values_only = TRUE) | ||
expect_equal(nrow(res_includeCTP), nrow(CT_genes)) | ||
|
||
## Test that the function returns a heatmap | ||
## res <- hESC_expression(genes = c("MAGEA1", "MAGEA3")) | ||
## expect_s4_class(res, "Heatmap") | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
test_that("hESC_mean_methylation() works", { | ||
|
||
## returns a SummarizedExperiment when values_only is set to TRUE | ||
## the na.omit parameter set to FALSE keeps genes with missing values | ||
res <- hESC_mean_methylation( | ||
genes = c("MAGEA1", "MAGEA2", "MAGEA4"), | ||
na.omit = FALSE, values_only = TRUE) | ||
expect_s4_class(res, "SummarizedExperiment") | ||
expect_equal(nrow(res), 3) | ||
|
||
## the na.omit parameter set to TRUE removes genes with missing values | ||
res_na_omit <- hESC_mean_methylation( | ||
genes = c("MAGEA1", "MAGEA2", "MAGEA4"), | ||
na.omit = TRUE, values_only = TRUE) | ||
expect_identical(na.omit(res), res_na_omit) | ||
|
||
## no valid gene in input returns an empty matrix | ||
expect_warning(res_no_gene <- hESC_mean_methylation( | ||
genes = "xxx", values_only = TRUE), "valid types") | ||
expect_equal(nrow(res_no_gene), 0) | ||
|
||
## Test that the function returns a heatmap by default | ||
## res <- hESC_mean_methylation( | ||
## genes = c("MAGEA1", "MAGEA2", "MAGEA4", "TDRD1")) | ||
## expect_s4_class(res, "Heatmap") | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
test_that("oocytes_expression() works", { | ||
|
||
## returns a SingleCellExperiment | ||
## n valid genes in input returns a SingleCellExperiment of n expected rownames | ||
## returns a warning when an invalid gene is entered | ||
## works with only one gene in input | ||
|
||
expect_warning(res <- oocytes_expression(c("MAGEA1", "xxx"), | ||
values_only = TRUE), "names invalid") | ||
expect_s4_class(res, "SingleCellExperiment") | ||
expect_equal(nrow(res), 1) | ||
expect_identical(rownames(res), "MAGEA1") | ||
|
||
|
||
## Test that the function returns a heatmap by default | ||
## Test that returns the expected heatmap | ||
## res <- oocytes_expression(c("MAGEA1", "MAGEA3", "MAGEA4")) | ||
## expect_s4_class(res, "Heatmap") | ||
|
||
}) |