# Generated by roxytest: do not edit by hand!
# File R/best_practice.R: @testexamples
test_that("[unknown alias] @ L210", {
data("simulated_catalogs")
# Here I reduce the values for n_bootstrap and n_nmf_run
# for reducing the run time.
# In practice, you should keep default or increase the values
# for better estimation.
#
# The input data here is simulated from 10 mutational signatures
# e1 <- bp_extract_signatures(
# t(simulated_catalogs$set1),
# range = 8:12,
# n_bootstrap = 5,
# n_nmf_run = 10
# )
#
# To avoid computation in examples,
# Here just load the result
# (e1$signature and e1$exposure set to NA to reduce package size)
load(system.file("extdata", "e1.RData", package = "sigminer"))
# See the survey for different signature numbers
# The suggested solution is marked as red dot
# with highest integrated score.
p1 <- bp_show_survey(e1)
p1
# You can also exclude plotting and highlighting the score
p2 <- bp_show_survey(e1, add_score = FALSE)
p2
# You can also plot a simplified version
p3 <- bp_show_survey2(e1, highlight = 10)
p3
# Obtain the suggested solution from extraction result
obj_suggested <- bp_get_sig_obj(e1, e1$suggested)
obj_suggested
# If you think the suggested signature number is not right
# Just pick up the solution you want
obj_s8 <- bp_get_sig_obj(e1, 8)
# Track the reconstructed profile similarity
rec_sim <- get_sig_rec_similarity(obj_s8, t(simulated_catalogs$set1))
rec_sim
# After extraction, you can assign the signatures
# to reference COSMIC signatures
# More see ?get_sig_similarity
sim <- get_sig_similarity(obj_suggested)
# Visualize the match result
if (require(pheatmap)) {
pheatmap::pheatmap(sim$similarity)
}
# You already got the activities of signatures
# in obj_suggested, however, you can still
# try to optimize the result.
# NOTE: the optimization step may not truly optimize the result!
expo <- bp_attribute_activity(e1, return_class = "data.table")
expo$abs_activity
expect_is(e1, "ExtractionResult")
expect_is(p1, "ggplot")
expect_is(p2, "ggplot")
expect_is(p2, "ggplot")
expect_is(obj_suggested, "Signature")
expect_is(obj_s8, "Signature")
expect_is(sim, "list")
expect_is(rec_sim, "data.table")
expect_is(expo, "list")
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.