simulate_signature()
- Simulate signatures from signature pool.
simulate_catalogue()
- Simulate catalogs from signature/catalog pool.
simulate_catalogue_matrix()
- Simulate a bootstrapped catalog matrix.
simulate_signature(x, weights = NULL)
simulate_catalogue(x, n, weights = NULL)
simulate_catalogue_matrix(x)
a matrix
.
# Generate a catalog
set.seed(1234)
catalog <- as.integer(table(sample(1:96, 1000, replace = TRUE)))
names(catalog) <- paste0("comp", 1:96)
# Generate a signature
sig <- catalog / sum(catalog)
# Simulate catalogs
x1 <- simulate_catalogue(catalog, 10) # 10 mutations
x1
#> comp1 comp2 comp3 comp4 comp5 comp6 comp7 comp8 comp9 comp10 comp11
#> 0 0 0 0 0 0 0 0 0 0 0
#> comp12 comp13 comp14 comp15 comp16 comp17 comp18 comp19 comp20 comp21 comp22
#> 0 0 0 0 0 0 1 0 0 0 0
#> comp23 comp24 comp25 comp26 comp27 comp28 comp29 comp30 comp31 comp32 comp33
#> 1 0 0 0 0 0 0 0 0 0 0
#> comp34 comp35 comp36 comp37 comp38 comp39 comp40 comp41 comp42 comp43 comp44
#> 0 0 0 0 1 0 0 0 0 1 0
#> comp45 comp46 comp47 comp48 comp49 comp50 comp51 comp52 comp53 comp54 comp55
#> 0 0 0 0 0 0 0 0 0 0 1
#> comp56 comp57 comp58 comp59 comp60 comp61 comp62 comp63 comp64 comp65 comp66
#> 0 0 0 0 0 0 1 0 1 0 0
#> comp67 comp68 comp69 comp70 comp71 comp72 comp73 comp74 comp75 comp76 comp77
#> 0 0 0 0 0 1 1 0 0 0 0
#> comp78 comp79 comp80 comp81 comp82 comp83 comp84 comp85 comp86 comp87 comp88
#> 0 0 0 0 0 0 0 1 0 0 0
#> comp89 comp90 comp91 comp92 comp93 comp94 comp95 comp96
#> 0 0 0 0 0 0 0 0
x2 <- simulate_catalogue(catalog, 100) # 100 mutations
x2
#> comp1 comp2 comp3 comp4 comp5 comp6 comp7 comp8 comp9 comp10 comp11
#> 1 2 2 0 2 1 3 0 0 1 1
#> comp12 comp13 comp14 comp15 comp16 comp17 comp18 comp19 comp20 comp21 comp22
#> 2 0 0 1 0 1 0 2 2 0 1
#> comp23 comp24 comp25 comp26 comp27 comp28 comp29 comp30 comp31 comp32 comp33
#> 3 3 0 0 0 0 0 0 1 1 1
#> comp34 comp35 comp36 comp37 comp38 comp39 comp40 comp41 comp42 comp43 comp44
#> 0 1 0 0 1 1 1 1 0 1 2
#> comp45 comp46 comp47 comp48 comp49 comp50 comp51 comp52 comp53 comp54 comp55
#> 2 0 0 2 4 1 0 1 1 0 2
#> comp56 comp57 comp58 comp59 comp60 comp61 comp62 comp63 comp64 comp65 comp66
#> 2 1 0 0 1 1 2 1 1 2 3
#> comp67 comp68 comp69 comp70 comp71 comp72 comp73 comp74 comp75 comp76 comp77
#> 2 4 2 1 1 3 2 0 0 2 0
#> comp78 comp79 comp80 comp81 comp82 comp83 comp84 comp85 comp86 comp87 comp88
#> 1 2 0 0 0 0 0 0 1 0 0
#> comp89 comp90 comp91 comp92 comp93 comp94 comp95 comp96
#> 1 0 1 1 2 3 3 2
x3 <- simulate_catalogue(catalog, 1000) # 1000 mutations
x3
#> comp1 comp2 comp3 comp4 comp5 comp6 comp7 comp8 comp9 comp10 comp11
#> 8 9 10 9 10 13 10 10 7 10 10
#> comp12 comp13 comp14 comp15 comp16 comp17 comp18 comp19 comp20 comp21 comp22
#> 6 6 14 14 7 10 11 5 14 11 14
#> comp23 comp24 comp25 comp26 comp27 comp28 comp29 comp30 comp31 comp32 comp33
#> 14 10 9 10 7 8 7 11 12 11 10
#> comp34 comp35 comp36 comp37 comp38 comp39 comp40 comp41 comp42 comp43 comp44
#> 4 5 7 14 8 16 19 7 15 11 9
#> comp45 comp46 comp47 comp48 comp49 comp50 comp51 comp52 comp53 comp54 comp55
#> 7 7 21 11 11 9 8 6 7 3 27
#> comp56 comp57 comp58 comp59 comp60 comp61 comp62 comp63 comp64 comp65 comp66
#> 14 19 8 17 5 11 8 9 6 23 7
#> comp67 comp68 comp69 comp70 comp71 comp72 comp73 comp74 comp75 comp76 comp77
#> 17 25 6 11 9 15 14 10 3 5 9
#> comp78 comp79 comp80 comp81 comp82 comp83 comp84 comp85 comp86 comp87 comp88
#> 7 16 10 8 7 5 14 15 5 1 11
#> comp89 comp90 comp91 comp92 comp93 comp94 comp95 comp96
#> 25 11 15 11 12 8 6 3
# Similar with a signature
x4 <- simulate_catalogue(sig, 10) # 10 mutations
x4
#> comp1 comp2 comp3 comp4 comp5 comp6 comp7 comp8 comp9 comp10 comp11
#> 1 0 0 0 0 1 0 0 0 0 0
#> comp12 comp13 comp14 comp15 comp16 comp17 comp18 comp19 comp20 comp21 comp22
#> 0 0 0 0 0 0 1 0 0 0 0
#> comp23 comp24 comp25 comp26 comp27 comp28 comp29 comp30 comp31 comp32 comp33
#> 0 0 0 0 0 0 0 2 0 0 0
#> comp34 comp35 comp36 comp37 comp38 comp39 comp40 comp41 comp42 comp43 comp44
#> 0 0 0 0 0 0 0 0 0 0 0
#> comp45 comp46 comp47 comp48 comp49 comp50 comp51 comp52 comp53 comp54 comp55
#> 0 0 0 0 1 0 0 0 0 0 0
#> comp56 comp57 comp58 comp59 comp60 comp61 comp62 comp63 comp64 comp65 comp66
#> 1 0 0 0 0 0 0 0 0 0 0
#> comp67 comp68 comp69 comp70 comp71 comp72 comp73 comp74 comp75 comp76 comp77
#> 0 0 0 0 0 1 0 0 0 1 0
#> comp78 comp79 comp80 comp81 comp82 comp83 comp84 comp85 comp86 comp87 comp88
#> 0 0 0 0 0 0 0 0 0 0 0
#> comp89 comp90 comp91 comp92 comp93 comp94 comp95 comp96
#> 1 0 0 0 0 0 0 0
# Load SBS signature
load(system.file("extdata", "toy_mutational_signature.RData",
package = "sigminer", mustWork = TRUE
))
s <- t(sig2$Signature.norm)
# Generate a signature from multiple signatures/catalogs
s1 <- simulate_signature(s)
s1
#> A[C>A]A A[C>A]C A[C>A]G A[C>A]T C[C>A]A
#> 3.035538e-03 5.666337e-03 8.094768e-04 1.618954e-03 3.642645e-03
#> C[C>A]C C[C>A]G C[C>A]T G[C>A]A G[C>A]C
#> 3.035538e-03 2.630799e-03 3.642645e-03 3.035538e-03 1.618954e-03
#> G[C>A]G G[C>A]T T[C>A]A T[C>A]C T[C>A]G
#> 3.968254e-02 1.821323e-03 1.781272e-02 4.452122e-03 1.416584e-03
#> T[C>A]T A[C>G]A A[C>G]C A[C>G]G A[C>G]T
#> 5.261599e-03 2.833169e-03 1.214215e-03 6.349206e-02 1.618954e-03
#> C[C>G]A C[C>G]C C[C>G]G C[C>G]T G[C>G]A
#> 2.630799e-03 8.094768e-04 3.035538e-03 5.555556e-02 2.226061e-03
#> G[C>G]C G[C>G]G G[C>G]T T[C>G]A T[C>G]C
#> 1.214215e-03 1.416584e-03 1.214215e-03 1.011846e-03 1.618954e-03
#> T[C>G]G T[C>G]T A[C>T]A A[C>T]C A[C>T]G
#> 2.226061e-03 1.821323e-03 1.011846e-02 9.916090e-03 4.472359e-02
#> A[C>T]T C[C>T]A C[C>T]C C[C>T]G C[C>T]T
#> 5.059230e-03 7.690029e-03 6.071076e-03 3.743830e-02 1.153504e-02
#> G[C>T]A G[C>T]C G[C>T]G G[C>T]T T[C>T]A
#> 4.210279e-02 9.713721e-03 3.683119e-02 9.713721e-03 7.892398e-03
#> T[C>T]C T[C>T]G T[C>T]T A[T>A]A A[T>A]C
#> 8.701875e-03 1.700305e-01 5.059230e-03 1.260064e-163 2.023692e-03
#> A[T>A]G A[T>A]T C[T>A]A C[T>A]C C[T>A]G
#> 8.096690e-03 6.071076e-04 1.789676e-63 4.108828e-03 2.428430e-03
#> C[T>A]T G[T>A]A G[T>A]C G[T>A]G G[T>A]T
#> 1.011846e-03 3.238676e-03 1.821323e-03 8.094768e-04 4.761905e-02
#> T[T>A]A T[T>A]C T[T>A]G T[T>A]T A[T>C]A
#> 2.662527e-79 6.477352e-03 6.477352e-03 1.011846e-03 5.666337e-03
#> A[T>C]C A[T>C]G A[T>C]T C[T>C]A C[T>C]C
#> 1.781272e-02 5.261599e-03 5.666337e-03 1.416584e-03 3.440276e-03
#> C[T>C]G C[T>C]T G[T>C]A G[T>C]C G[T>C]G
#> 3.076742e-02 2.428430e-03 1.965575e-03 1.295470e-02 2.226061e-03
#> G[T>C]T T[T>C]A T[T>C]C T[T>C]G T[T>C]T
#> 2.226061e-03 3.238676e-03 1.618954e-03 2.023692e-03 3.845015e-03
#> A[T>G]A A[T>G]C A[T>G]G A[T>G]T C[T>G]A
#> 1.011846e-03 3.238676e-03 9.930162e-04 6.071076e-04 2.023692e-04
#> C[T>G]C C[T>G]G C[T>G]T G[T>G]A G[T>G]C
#> 1.618954e-03 2.023692e-03 3.968254e-02 2.380952e-02 6.071076e-04
#> G[T>G]G G[T>G]T T[T>G]A T[T>G]C T[T>G]G
#> 1.214215e-03 3.238676e-03 2.380952e-02 1.011846e-03 3.238676e-03
#> T[T>G]T
#> 3.968254e-02
s2 <- simulate_signature(s, weights = 1:3)
s2
#> A[C>A]A A[C>A]C A[C>A]G A[C>A]T C[C>A]A
#> 3.035538e-03 5.666337e-03 8.094768e-04 1.618954e-03 3.642645e-03
#> C[C>A]C C[C>A]G C[C>A]T G[C>A]A G[C>A]C
#> 3.035538e-03 2.630799e-03 3.642645e-03 3.035538e-03 1.618954e-03
#> G[C>A]G G[C>A]T T[C>A]A T[C>A]C T[C>A]G
#> 1.984127e-02 1.821323e-03 2.671908e-02 4.452122e-03 1.416584e-03
#> T[C>A]T A[C>G]A A[C>G]C A[C>G]G A[C>G]T
#> 5.261599e-03 2.833169e-03 1.214215e-03 3.174603e-02 1.618954e-03
#> C[C>G]A C[C>G]C C[C>G]G C[C>G]T G[C>G]A
#> 2.630799e-03 8.094768e-04 3.035538e-03 2.777778e-02 2.226061e-03
#> G[C>G]C G[C>G]G G[C>G]T T[C>G]A T[C>G]C
#> 1.214215e-03 1.416584e-03 1.214215e-03 1.011846e-03 1.618954e-03
#> T[C>G]G T[C>G]T A[C>T]A A[C>T]C A[C>T]G
#> 2.226061e-03 1.821323e-03 1.011846e-02 9.916090e-03 4.472359e-02
#> A[C>T]T C[C>T]A C[C>T]C C[C>T]G C[C>T]T
#> 5.059230e-03 7.690029e-03 6.071076e-03 3.743830e-02 1.153504e-02
#> G[C>T]A G[C>T]C G[C>T]G G[C>T]T T[C>T]A
#> 6.315418e-02 9.713721e-03 3.683119e-02 9.713721e-03 7.892398e-03
#> T[C>T]C T[C>T]G T[C>T]T A[T>A]A A[T>A]C
#> 8.701875e-03 2.550457e-01 5.059230e-03 1.260064e-163 2.023692e-03
#> A[T>A]G A[T>A]T C[T>A]A C[T>A]C C[T>A]G
#> 1.214504e-02 6.071076e-04 1.789676e-63 5.531565e-03 2.428430e-03
#> C[T>A]T G[T>A]A G[T>A]C G[T>A]G G[T>A]T
#> 1.011846e-03 4.858014e-03 1.821323e-03 8.094768e-04 2.380952e-02
#> T[T>A]A T[T>A]C T[T>A]G T[T>A]T A[T>C]A
#> 3.993791e-79 9.716028e-03 9.716028e-03 1.011846e-03 5.666337e-03
#> A[T>C]C A[T>C]G A[T>C]T C[T>C]A C[T>C]C
#> 2.671908e-02 5.261599e-03 5.666337e-03 1.416584e-03 3.440276e-03
#> C[T>C]G C[T>C]T G[T>C]A G[T>C]C G[T>C]G
#> 4.615113e-02 2.428430e-03 2.510545e-03 1.943206e-02 2.226061e-03
#> G[T>C]T T[T>C]A T[T>C]C T[T>C]G T[T>C]T
#> 2.226061e-03 4.858014e-03 1.618954e-03 2.023692e-03 3.845015e-03
#> A[T>G]A A[T>G]C A[T>G]G A[T>G]T C[T>G]A
#> 1.011846e-03 4.858014e-03 1.329164e-03 6.071076e-04 2.023692e-04
#> C[T>G]C C[T>G]G C[T>G]T G[T>G]A G[T>G]C
#> 1.618954e-03 2.023692e-03 1.984127e-02 1.190476e-02 6.071076e-04
#> G[T>G]G G[T>G]T T[T>G]A T[T>G]C T[T>G]G
#> 1.214215e-03 4.858014e-03 1.190476e-02 1.011846e-03 4.858014e-03
#> T[T>G]T
#> 1.984127e-02
# Generate a catalog from multiple signatures/catalogs
c1 <- simulate_catalogue(s, 100, weights = 1:3)
c1
#> A[C>A]A A[C>A]C A[C>A]G A[C>A]T C[C>A]A C[C>A]C C[C>A]G C[C>A]T G[C>A]A G[C>A]C
#> 0 1 0 0 0 1 1 0 1 0
#> G[C>A]G G[C>A]T T[C>A]A T[C>A]C T[C>A]G T[C>A]T A[C>G]A A[C>G]C A[C>G]G A[C>G]T
#> 1 0 2 0 0 0 0 0 1 0
#> C[C>G]A C[C>G]C C[C>G]G C[C>G]T G[C>G]A G[C>G]C G[C>G]G G[C>G]T T[C>G]A T[C>G]C
#> 1 1 0 0 0 0 0 0 0 0
#> T[C>G]G T[C>G]T A[C>T]A A[C>T]C A[C>T]G A[C>T]T C[C>T]A C[C>T]C C[C>T]G C[C>T]T
#> 0 0 1 0 7 1 2 0 4 0
#> G[C>T]A G[C>T]C G[C>T]G G[C>T]T T[C>T]A T[C>T]C T[C>T]G T[C>T]T A[T>A]A A[T>A]C
#> 5 2 6 2 1 1 25 1 0 0
#> A[T>A]G A[T>A]T C[T>A]A C[T>A]C C[T>A]G C[T>A]T G[T>A]A G[T>A]C G[T>A]G G[T>A]T
#> 1 0 0 0 1 0 0 0 0 2
#> T[T>A]A T[T>A]C T[T>A]G T[T>A]T A[T>C]A A[T>C]C A[T>C]G A[T>C]T C[T>C]A C[T>C]C
#> 0 1 1 0 1 2 0 0 0 0
#> C[T>C]G C[T>C]T G[T>C]A G[T>C]C G[T>C]G G[T>C]T T[T>C]A T[T>C]C T[T>C]G T[T>C]T
#> 6 0 1 1 0 0 1 1 0 2
#> A[T>G]A A[T>G]C A[T>G]G A[T>G]T C[T>G]A C[T>G]C C[T>G]G C[T>G]T G[T>G]A G[T>G]C
#> 0 1 0 0 0 0 0 5 1 0
#> G[T>G]G G[T>G]T T[T>G]A T[T>G]C T[T>G]G T[T>G]T
#> 0 0 2 1 0 1