context("test: coverage_plot")
test_that("Testing coverage plot plotting function", {
# Download required test files------------------------------------------------
PC <- readRDS(system.file("testdata", "PeptideCoverage.RDS", package = "pspecterlib"))
# Test coverage plot input checks---------------------------------------------
# Peptide coverage must be of the correct class
expect_error(
coverage_plot(data.frame(test = 1)),
"PeptideCoverage must be an object of the peptide_coverage class generated by get_peptide_coverage."
)
# Color by score must indicate the score to color by
expect_error(
coverage_plot(PC, ColorByScore = c("QValue", "Score")),
"ColorByScore should be a single character or NULL."
)
# Color by score must be an acceptable input
expect_error(
coverage_plot(PC, ColorByScore = "test"),
'Acceptable values for ColorByScore are "QValue" or "Score."'
)
# Interactive must be a logical input
expect_error(
coverage_plot(PC, Interactive = "FALSE"),
"Interactive must be a single logical value TRUE or FALSE."
)
# Create a coverage plot------------------------------------------------------
# Create a static plot with no colorbyscore
CovPlot1 <- coverage_plot(PC, Interactive = NA)
expect_true(inherits(CovPlot1, "ggplot"))
# Create an interactive plot with colorbyscore with Score
CovPlot2 <- coverage_plot(PC, ColorByScore = "Score", Interactive = TRUE)
expect_true(inherits(CovPlot2, "plotly"))
# Create a static plot where the requested colorbyscore is NA
suppressMessages(CovPlot3 <- coverage_plot(PC, "QValue"))
expect_true(inherits(CovPlot3, "ggplot"))
# Modify plot coverage to have Q-Values and make an interactive plot
PC$PeptidesByPosition$`Q Value` <- runif(nrow(PC$PeptidesByPosition))
CovPlot4 <- coverage_plot(PC, "QValue", TRUE)
expect_true(inherits(CovPlot4, "plotly"))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.