Skip to content

Commit 959bb6c

Browse files
committed
update docs
1 parent ec7805c commit 959bb6c

12 files changed

+220
-6
lines changed

NEWS.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# sigminer 2.3.1
22

3+
- Updated `sig_fit()` related documents for better usage (#454).
34
- Added `cluster_col` to `show_group_enrichment()`.
45
- Fixed the bug that error returned when `cluster_row = TRUE` & `return_list = TRUE` in function `show_group_enrichment()`.
56
- Fixed the error in generating DBS and INDEL matrix when only one sample input (#453).

R/sig_fit.R

+46
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,52 @@
4949
#' Nature genetics 48.6 (2016): 600.
5050
#' @examples
5151
#' \donttest{
52+
#'
53+
#' # For mutational signatures ----------------
54+
#' # SBS is used for illustration, similar
55+
#' # operations can be applied to DBS, INDEL, CN, RS, etc.
56+
#'
57+
#' # Load simulated data
58+
#' data("simulated_catalogs")
59+
#' data = simulated_catalogs$set1
60+
#' data[1:5, 1:5]
61+
#'
62+
#' # Fitting with all COSMIC v2 reference signatures
63+
#' sig_fit(data, sig_index = "ALL")
64+
#' # Check ?sig_fit for sig_db options
65+
#' # e.g., use the COSMIC SBS v3
66+
#' sig_fit(data, sig_index = "ALL", sig_db = "SBS")
67+
#'
68+
#' # Fitting with specified signatures
69+
#' # opt 1. use selected reference signatures
70+
#' sig_fit(data, sig_index = c(1, 5, 9, 2, 13), sig_db = "SBS")
71+
#' # opt 2. use user specified signatures
72+
#' ref = get_sig_db()$db
73+
#' ref[1:5, 1:5]
74+
#' ref = ref[, 1:10]
75+
#' # The `sig` used here can be result object from `sig_extract`
76+
#' # or any reference matrix with similar structure (96-motif)
77+
#' v1 = sig_fit(data, sig = ref)
78+
#' v1
79+
#'
80+
#' # If possible, auto-reduce the reference signatures
81+
#' # for better fitting data from a sample
82+
#' v2 = sig_fit(data, sig = ref, auto_reduce = TRUE)
83+
#' v2
84+
#'
85+
#' all.equal(v1, v2)
86+
#'
87+
#' # Some samples reported signatures dropped
88+
#' # but its original activity values are 0s,
89+
#' # so the data remain same (0 -> 0)
90+
#' all.equal(v1[, 2], v2[, 2])
91+
#'
92+
#' # For COSMIC_10, 6.67638 -> 0
93+
#' v1[, 4]; v2[, 4]
94+
#' all.equal(v1[, 4], v2[, 4])
95+
#'
96+
#' # For general purpose -----------------------
97+
#'
5298
#' W <- matrix(c(1, 2, 3, 4, 5, 6), ncol = 2)
5399
#' colnames(W) <- c("sig1", "sig2")
54100
#' W <- apply(W, 2, function(x) x / sum(x))

R/sig_fit_bootstrap.R

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
#' @keywords bootstrap
2323
#' @seealso [report_bootstrap_p_value], [sig_fit], [sig_fit_bootstrap_batch]
2424
#' @examples
25+
#'
26+
#' # This function is designed for processing
27+
#' # one sample, thus is not very useful in practice
28+
#' # please check `sig_fit_bootstrap_batch`
29+
#'
30+
#' # For general purpose -------------------
2531
#' W <- matrix(c(1, 2, 3, 4, 5, 6), ncol = 2)
2632
#' colnames(W) <- c("sig1", "sig2")
2733
#' W <- apply(W, 2, function(x) x / sum(x))

R/sig_fit_bootstrap_batch.R

+19
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,25 @@
2323
#' @seealso [sig_fit], [sig_fit_bootstrap]
2424
#'
2525
#' @examples
26+
#' # For mutational signatures ----------------
27+
#' # SBS is used for illustration, similar
28+
#' # operations can be applied to DBS, INDEL, CN, RS, etc.
29+
#'
30+
#' # Load simulated data
31+
#' data("simulated_catalogs")
32+
#' data = simulated_catalogs$set1
33+
#' data[1:5, 1:5]
34+
#'
35+
#' # Fitting with COSMIC reference signatures
36+
#' \donttest{
37+
#' # Generally set n = 100
38+
#' rv = sig_fit_bootstrap_batch(data,
39+
#' sig_index = c(1, 5, 9, 2, 13),
40+
#' sig_db = "SBS", n = 10)
41+
#' rv
42+
#' }
43+
#'
44+
#' # For general purpose --------------------
2645
#' W <- matrix(c(1, 2, 3, 4, 5, 6), ncol = 2)
2746
#' colnames(W) <- c("sig1", "sig2")
2847
#' W <- apply(W, 2, function(x) x / sum(x))

man/scoring.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/sig_auto_extract.Rd

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/sig_fit.Rd

+46
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/sig_fit_bootstrap.Rd

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/sig_fit_bootstrap_batch.Rd

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-roxytest-testexamples-sig_fit.R

+47-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,55 @@
22

33
# File R/sig_fit.R: @testexamples
44

5-
test_that("Function sig_fit() @ L99", {
5+
test_that("Function sig_fit() @ L145", {
66

77

8+
9+
# For mutational signatures ----------------
10+
# SBS is used for illustration, similar
11+
# operations can be applied to DBS, INDEL, CN, RS, etc.
12+
13+
# Load simulated data
14+
data("simulated_catalogs")
15+
data = simulated_catalogs$set1
16+
data[1:5, 1:5]
17+
18+
# Fitting with all COSMIC v2 reference signatures
19+
sig_fit(data, sig_index = "ALL")
20+
# Check ?sig_fit for sig_db options
21+
# e.g., use the COSMIC SBS v3
22+
sig_fit(data, sig_index = "ALL", sig_db = "SBS")
23+
24+
# Fitting with specified signatures
25+
# opt 1. use selected reference signatures
26+
sig_fit(data, sig_index = c(1, 5, 9, 2, 13), sig_db = "SBS")
27+
# opt 2. use user specified signatures
28+
ref = get_sig_db()$db
29+
ref[1:5, 1:5]
30+
ref = ref[, 1:10]
31+
# The `sig` used here can be result object from `sig_extract`
32+
# or any reference matrix with similar structure (96-motif)
33+
v1 = sig_fit(data, sig = ref)
34+
v1
35+
36+
# If possible, auto-reduce the reference signatures
37+
# for better fitting data from a sample
38+
v2 = sig_fit(data, sig = ref, auto_reduce = TRUE)
39+
v2
40+
41+
all.equal(v1, v2)
42+
43+
# Some samples reported signatures dropped
44+
# but its original activity values are 0s,
45+
# so the data remain same (0 -> 0)
46+
all.equal(v1[, 2], v2[, 2])
47+
48+
# For COSMIC_10, 6.67638 -> 0
49+
v1[, 4]; v2[, 4]
50+
all.equal(v1[, 4], v2[, 4])
51+
52+
# For general purpose -----------------------
53+
854
W <- matrix(c(1, 2, 3, 4, 5, 6), ncol = 2)
955
colnames(W) <- c("sig1", "sig2")
1056
W <- apply(W, 2, function(x) x / sum(x))

tests/testthat/test-roxytest-testexamples-sig_fit_bootstrap.R

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22

33
# File R/sig_fit_bootstrap.R: @testexamples
44

5-
test_that("Function sig_fit_bootstrap() @ L61", {
5+
test_that("Function sig_fit_bootstrap() @ L67", {
66

7+
8+
# This function is designed for processing
9+
# one sample, thus is not very useful in practice
10+
# please check `sig_fit_bootstrap_batch`
11+
12+
# For general purpose -------------------
713
W <- matrix(c(1, 2, 3, 4, 5, 6), ncol = 2)
814
colnames(W) <- c("sig1", "sig2")
915
W <- apply(W, 2, function(x) x / sum(x))

tests/testthat/test-roxytest-testexamples-sig_fit_bootstrap_batch.R

+20-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,27 @@
22

33
# File R/sig_fit_bootstrap_batch.R: @testexamples
44

5-
test_that("Function sig_fit_bootstrap_batch() @ L44", {
5+
test_that("Function sig_fit_bootstrap_batch() @ L63", {
66

7+
# For mutational signatures ----------------
8+
# SBS is used for illustration, similar
9+
# operations can be applied to DBS, INDEL, CN, RS, etc.
10+
11+
# Load simulated data
12+
data("simulated_catalogs")
13+
data = simulated_catalogs$set1
14+
data[1:5, 1:5]
15+
16+
# Fitting with COSMIC reference signatures
17+
18+
# Generally set n = 100
19+
rv = sig_fit_bootstrap_batch(data,
20+
sig_index = c(1, 5, 9, 2, 13),
21+
sig_db = "SBS", n = 10)
22+
rv
23+
24+
25+
# For general purpose --------------------
726
W <- matrix(c(1, 2, 3, 4, 5, 6), ncol = 2)
827
colnames(W) <- c("sig1", "sig2")
928
W <- apply(W, 2, function(x) x / sum(x))

0 commit comments

Comments
 (0)