The function performs a signatures decomposition of a given mutational catalogue V with known signatures W by solving the minimization problem min(||W*H - V||) where W and V are known.

sig_fit(
  catalogue_matrix,
  sig,
  sig_index = NULL,
  sig_db = c("legacy", "SBS", "DBS", "ID", "TSB", "SBS_Nik_lab", "RS_Nik_lab",
    "RS_BRCA560", "RS_USARC", "CNS_USARC", "CNS_TCGA", "CNS_TCGA176", "CNS_PCAWG176",
    "SBS_hg19", "SBS_hg38", "SBS_mm9", "SBS_mm10", "DBS_hg19", "DBS_hg38", "DBS_mm9",
    "DBS_mm10", "SBS_Nik_lab_Organ", "RS_Nik_lab_Organ", "latest_SBS_GRCh37",
    "latest_DBS_GRCh37", "latest_ID_GRCh37", "latest_SBS_GRCh38", "latest_DBS_GRCh38",
    "latest_SBS_mm9", "latest_DBS_mm9", "latest_SBS_mm10", "latest_DBS_mm10",
    "latest_SBS_rn6", "latest_DBS_rn6", "latest_CN_GRCh37", 
    
    "latest_RNA-SBS_GRCh37", "latest_SV_GRCh38"),
  db_type = c("", "human-exome", "human-genome"),
  show_index = TRUE,
  method = c("QP", "NNLS", "SA"),
  auto_reduce = FALSE,
  type = c("absolute", "relative"),
  return_class = c("matrix", "data.table"),
  return_error = FALSE,
  rel_threshold = 0,
  mode = c("SBS", "DBS", "ID", "copynumber"),
  true_catalog = NULL,
  ...
)

Arguments

catalogue_matrix

a numeric matrix V with row representing components and columns representing samples, typically you can get nmf_matrix from sig_tally() and transpose it by t().

sig

a Signature object obtained either from sig_extract or sig_auto_extract, or just a raw signature matrix/data.frame with row representing components (motifs) and column representing signatures.

sig_index

a vector for signature index. "ALL" for all signatures.

sig_db

default 'legacy', it can be 'legacy' (for COSMIC v2 'SBS'), 'SBS', 'DBS', 'ID' and 'TSB' (for COSMIV v3.1 signatures) for small scale mutations. For more specific details, it can also be 'SBS_hg19', 'SBS_hg38', 'SBS_mm9', 'SBS_mm10', 'DBS_hg19', 'DBS_hg38', 'DBS_mm9', 'DBS_mm10' to use COSMIC v3 reference signatures from Alexandrov, Ludmil B., et al. (2020) (reference #1). In addition, it can be one of "SBS_Nik_lab_Organ", "RS_Nik_lab_Organ", "SBS_Nik_lab", "RS_Nik_lab" to refer reference signatures from Degasperi, Andrea, et al. (2020) (reference #2); "RS_BRCA560", "RS_USARC" to reference signatures from BRCA560 and USARC cohorts; "CNS_USARC" (40 categories), "CNS_TCGA" (48 categories) to reference copy number signatures from USARC cohort and TCGA; "CNS_TCGA176" (176 categories) and "CNS_PCAWG176" (176 categories) to reference copy number signatures from PCAWG and TCGA separately. UPDATE, the latest version of reference version can be automatically downloaded and loaded from https://cancer.sanger.ac.uk/signatures/downloads/ when a option with latest_ prefix is specified (e.g. "latest_SBS_GRCh37"). Note: the signature profile for different genome builds are basically same. And specific database (e.g. 'SBS_mm10') contains less signatures than all COSMIC signatures (because some signatures are not detected from Alexandrov, Ludmil B., et al. (2020)). For all available options, check the parameter setting.

db_type

only used when sig_db is enabled. "" for keeping default, "human-exome" for transforming to exome frequency of component, and "human-genome" for transforming to whole genome frequency of component. Currently only works for 'SBS'.

show_index

if TRUE, show valid indices.

method

method to solve the minimazation problem. 'NNLS' for non-negative least square; 'QP' for quadratic programming; 'SA' for simulated annealing.

auto_reduce

if TRUE, try reducing the input reference signatures to increase the cosine similarity of reconstructed profile to observed profile.

type

'absolute' for signature exposure and 'relative' for signature relative exposure.

return_class

string, 'matrix' or 'data.table'.

return_error

if TRUE, also return sample error (Frobenius norm) and cosine similarity between observed sample profile (asa. spectrum) and reconstructed profile. NOTE: it is better to obtain the error when the type is 'absolute', because the error is affected by relative exposure accuracy.

rel_threshold

numeric vector, a signature with relative exposure lower than (equal is included, i.e. <=) this value will be set to 0 (both absolute exposure and relative exposure). In this case, sum of signature contribution may not equal to 1.

mode

signature type for plotting, now supports 'copynumber', 'SBS', 'DBS', 'ID' and 'RS' (genome rearrangement signature).

true_catalog

used by sig_fit_bootstrap, user never use it.

...

control parameters passing to argument control in GenSA function when use method 'SA'.

Value

The exposure result either in matrix or data.table format. If return_error set TRUE, a list is returned.

Details

The method 'NNLS' solves the minimization problem with nonnegative least-squares constraints. The method 'QP' and 'SA' are modified from SignatureEstimation package. See references for details. Of note, when fitting exposures for copy number signatures, only components of feature CN is used.

References

Daniel Huebschmann, Zuguang Gu and Matthias Schlesner (2019). YAPSA: Yet Another Package for Signature Analysis. R package version 1.12.0.

Huang X, Wojtowicz D, Przytycka TM. Detecting presence of mutational signatures in cancer with confidence. Bioinformatics. 2018;34(2):330–337. doi:10.1093/bioinformatics/btx604

Kim, Jaegil, et al. "Somatic ERCC2 mutations are associated with a distinct genomic signature in urothelial tumors." Nature genetics 48.6 (2016): 600.

Examples

# \donttest{

# For mutational signatures ----------------
# SBS is used for illustration, similar
# operations can be applied to DBS, INDEL, CN, RS, etc.

# Load simulated data
data("simulated_catalogs")
data = simulated_catalogs$set1
data[1:5, 1:5]
#>         Sample_1 Sample_2 Sample_3 Sample_4 Sample_5
#> A[C>A]A      911      195       95      131       33
#> A[C>A]C      761      175       51       71       10
#> A[C>A]G       88       19       12       14        2
#> A[C>A]T      744      174       55       77       14
#> C[C>A]A      883      225      142      170       55

# Fitting with all COSMIC v2 reference signatures
sig_fit(data, sig_index = "ALL")
#>  [2024-08-04 14:44:52.714294]: Started.
#>  [2024-08-04 14:44:52.716068]: Signature index detected.
#>  [2024-08-04 14:44:52.717448]: Checking signature database in package.
#>  [2024-08-04 14:44:52.71987]: Checking signature index.
#>  [2024-08-04 14:44:52.721265]: Valid index for db 'legacy':
#> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#>  [2024-08-04 14:44:52.722724]: Database and index checked.
#>  [2024-08-04 14:44:52.724327]: Signature normalized.
#>  [2024-08-04 14:44:52.725697]: Checking row number for catalog matrix and signature matrix.
#>  [2024-08-04 14:44:52.727009]: Checked.
#>  [2024-08-04 14:44:52.728322]: Checking rownames for catalog matrix and signature matrix.
#>  [2024-08-04 14:44:52.729666]: Matrix V and W don't have same orders. Try reordering...
#>  [2024-08-04 14:44:52.7311]: Checked.
#>  [2024-08-04 14:44:52.732512]: Method 'QP' detected.
#>  [2024-08-04 14:44:52.733961]: Corresponding function generated.
#>  [2024-08-04 14:44:52.7353]: Calling function.
#>  [2024-08-04 14:44:52.737009]: Fitting sample: Sample_1
#>  [2024-08-04 14:44:52.738683]: Fitting sample: Sample_2
#>  [2024-08-04 14:44:52.740212]: Fitting sample: Sample_3
#>  [2024-08-04 14:44:52.741813]: Fitting sample: Sample_4
#>  [2024-08-04 14:44:52.743363]: Fitting sample: Sample_5
#>  [2024-08-04 14:44:52.744917]: Fitting sample: Sample_6
#>  [2024-08-04 14:44:52.746477]: Fitting sample: Sample_7
#>  [2024-08-04 14:44:52.747995]: Fitting sample: Sample_8
#>  [2024-08-04 14:44:52.749542]: Fitting sample: Sample_9
#>  [2024-08-04 14:44:52.751054]: Fitting sample: Sample_10
#>  [2024-08-04 14:44:52.752588]: Fitting sample: Sample_11
#>  [2024-08-04 14:44:52.754441]: Fitting sample: Sample_12
#>  [2024-08-04 14:44:52.755956]: Fitting sample: Sample_13
#>  [2024-08-04 14:44:52.757516]: Fitting sample: Sample_14
#>  [2024-08-04 14:44:52.759066]: Fitting sample: Sample_15
#>  [2024-08-04 14:44:52.760595]: Fitting sample: Sample_16
#>  [2024-08-04 14:44:52.762135]: Fitting sample: Sample_17
#>  [2024-08-04 14:44:52.76365]: Fitting sample: Sample_18
#>  [2024-08-04 14:44:52.765161]: Fitting sample: Sample_19
#>  [2024-08-04 14:44:52.766698]: Fitting sample: Sample_20
#>  [2024-08-04 14:44:52.768184]: Fitting sample: Sample_21
#>  [2024-08-04 14:44:52.769712]: Fitting sample: Sample_22
#>  [2024-08-04 14:44:52.771227]: Fitting sample: Sample_23
#>  [2024-08-04 14:44:52.772797]: Fitting sample: Sample_24
#>  [2024-08-04 14:44:52.774349]: Fitting sample: Sample_25
#>  [2024-08-04 14:44:52.775883]: Fitting sample: Sample_26
#>  [2024-08-04 14:44:52.777424]: Fitting sample: Sample_27
#>  [2024-08-04 14:44:52.778927]: Fitting sample: Sample_28
#>  [2024-08-04 14:44:52.780445]: Fitting sample: Sample_29
#>  [2024-08-04 14:44:52.781975]: Fitting sample: Sample_30
#>  [2024-08-04 14:44:52.783481]: Done.
#>  [2024-08-04 14:44:52.784839]: Generating output signature exposures.
#>  [2024-08-04 14:44:52.787091]: Done.
#>  [2024-08-04 14:44:52.788568]: 0.074 secs elapsed.
#>               Sample_1    Sample_2    Sample_3    Sample_4    Sample_5
#> COSMIC_1      0.000000    0.000000   12.316692    0.000000    0.000000
#> COSMIC_2      0.000000 3349.510152    0.000000    0.000000  948.379212
#> COSMIC_3  13596.457821    0.000000    6.574699 1755.900808  125.782093
#> COSMIC_4     15.264857    0.000000    2.708319    0.000000    0.000000
#> COSMIC_5     88.759109    0.000000 3035.361542 1671.687846    0.000000
#> COSMIC_6     50.489937 3138.613536 3408.708042    0.000000    0.000000
#> COSMIC_7      0.000000    0.000000    0.000000    0.780399    0.322276
#> COSMIC_8  13410.973058 4399.640806    5.111720    0.502994    0.000000
#> COSMIC_9      0.000000    0.000000    0.000000    0.000000    0.000000
#> COSMIC_10     2.502093    0.000000    0.000000    0.000000    2.649920
#> COSMIC_11     0.000000    0.000000    0.000000    0.000000    0.628539
#> COSMIC_12 14636.867322 3173.628918 1112.660642 2644.810440    0.000000
#> COSMIC_13     3.345820 4740.202983 2489.698611 3604.349332 1027.188236
#> COSMIC_14     0.000000    7.622208    1.644765    0.000000    0.000000
#> COSMIC_15     0.000000    0.000000    6.356134    0.542811    0.000000
#> COSMIC_16    10.838333    0.000000    3.569317    2.729935    0.000000
#> COSMIC_17   788.136285    0.000000    0.000000    0.000000   11.345102
#> COSMIC_18     0.000000    0.000000  660.528061  890.441688  557.937060
#> COSMIC_19     0.000000    0.750380    5.703897    2.305603    0.000000
#> COSMIC_20     0.000000    0.000000   11.826130    0.000000    0.000000
#> COSMIC_21    19.999782    0.605214    0.000000    0.000000    0.000000
#> COSMIC_22     0.000000    1.412315    2.326967    1.470566    0.000000
#> COSMIC_23     0.000000    0.000000    0.000000    0.000000    0.000000
#> COSMIC_24     0.000000    0.000000    0.000000    0.000000    1.734102
#> COSMIC_25     0.000000    2.339510    0.000000    0.000000    0.000000
#> COSMIC_26     0.000000    5.829081    0.000000   10.477579    0.000000
#> COSMIC_27     0.000000    0.690230    0.413775    0.000000    0.617212
#> COSMIC_28   128.579595    3.154668    0.000000    0.000000   11.570903
#> COSMIC_29     7.785988    0.000000    0.000000    0.000000    6.845345
#> COSMIC_30     0.000000    0.000000    4.490687    0.000000    0.000000
#>             Sample_6   Sample_7    Sample_8    Sample_9   Sample_10   Sample_11
#> COSMIC_1    1.593571   4.880078 1236.351733    0.000000    1.014648  878.357543
#> COSMIC_2  447.638410   0.000000  239.380593    0.000000 1325.806777  624.216936
#> COSMIC_3  287.957097   0.000000  294.616206 1910.527717 1527.088437    5.201832
#> COSMIC_4    0.115174   0.000000    0.000000    0.344221    0.000000    4.241885
#> COSMIC_5    0.000000 336.238603   97.850592 1253.756212 3348.758707 2309.500447
#> COSMIC_6  351.904226 253.679248    0.000000   72.341307    0.000000  646.758198
#> COSMIC_7    0.000000   0.000000    1.451300    1.291309    1.070439    0.000000
#> COSMIC_8  243.207761   4.231027    0.000000    0.000000 2518.120558    0.000000
#> COSMIC_9    0.000000   0.000000    0.000000    0.000000    0.000000    0.000000
#> COSMIC_10   0.105083   0.000000    0.000000    0.565740    0.652112    0.000000
#> COSMIC_11   1.573701   0.000000    0.000000    0.000000    0.395463    0.000000
#> COSMIC_12   0.000000   1.558663    2.680746    0.000000    0.000000    9.303593
#> COSMIC_13   0.412038 399.409491    0.000000  711.486825    0.000000  746.132722
#> COSMIC_14   0.036217   1.724017    0.000000    0.322584    0.000000    0.000000
#> COSMIC_15   0.000000   1.955241    0.000000    2.737638    1.470945    3.294826
#> COSMIC_16   0.000000   0.000000    0.000000    7.874248    0.000000    6.060704
#> COSMIC_17   0.000000 162.051155    0.000000 4107.930816    0.000000    0.000000
#> COSMIC_18 262.002399 429.270451  508.415723    0.000000  978.795305    1.757806
#> COSMIC_19   0.000000   0.000000    0.000000    0.000000    1.812196    4.046976
#> COSMIC_20   0.000000   0.000000    2.418327    0.000000    0.000000    4.132387
#> COSMIC_21   0.000000   1.423649    0.000000    0.000000    0.000000    0.000000
#> COSMIC_22   0.000000   0.000000    0.000000    0.000000    0.000000    1.185078
#> COSMIC_23   0.000000   0.000000    0.000000    1.486023    0.000000    0.000000
#> COSMIC_24   0.690493   0.070519    0.000000    0.000000    0.000000    0.000000
#> COSMIC_25   0.000000   0.000000    0.000000    0.000000    1.230116    0.761657
#> COSMIC_26   0.000000   0.507859    0.000000    0.000000    0.000000    4.676707
#> COSMIC_27   0.000000   0.000000    0.000000    0.000000    0.000000    0.000000
#> COSMIC_28   7.940466   0.000000    8.063004   49.575537    6.784297    0.000000
#> COSMIC_29   7.823365   0.000000    0.771775    3.759826    0.000000    0.000000
#> COSMIC_30   0.000000   0.000000    0.000000    0.000000    0.000000    6.370705
#>              Sample_12  Sample_13   Sample_14   Sample_15   Sample_16
#> COSMIC_1      6.837473   2.883482    1.812292  508.701296    0.000000
#> COSMIC_2      0.000000   0.366162 1119.406113    0.000000    0.000000
#> COSMIC_3  15860.219425   4.421433    6.574966   18.115040 1677.967550
#> COSMIC_4      0.000000   0.000000    0.000000    0.000000    0.000000
#> COSMIC_5   6692.477024   0.000000 1074.779287 4438.808139  334.878313
#> COSMIC_6      0.000000  88.673686  158.223498    0.000000    0.000000
#> COSMIC_7      0.000000   0.498306    0.216809    0.000000    0.000000
#> COSMIC_8      9.812595 427.338774    0.000000   12.690741    2.945048
#> COSMIC_9      0.000000   0.000000    0.000000    0.000000    0.000000
#> COSMIC_10     0.000000   0.306919    0.000000    0.000000    1.439702
#> COSMIC_11     0.000000   0.000000    0.000000    1.578921    0.000000
#> COSMIC_12 12747.006106 510.641670  998.007438   23.461748 1867.930943
#> COSMIC_13  4219.832742 725.821797  826.863849 3260.970572  698.766395
#> COSMIC_14     0.000000   0.000000    0.000000    0.000000    0.000000
#> COSMIC_15     0.862951   0.343456    0.000000    0.153861    0.000000
#> COSMIC_16     6.352880  11.781069   11.383645   18.382613   10.442240
#> COSMIC_17     0.000000   0.000000    0.138013 1642.620944    0.000000
#> COSMIC_18 10389.077591 336.244681    0.000000  824.282503 3089.548636
#> COSMIC_19     8.116437   0.000000    0.000000    2.757814    0.000000
#> COSMIC_20     0.268375   0.000000    2.720388    5.982007    0.000000
#> COSMIC_21     0.000000   0.000000    0.000000    0.000000    6.680742
#> COSMIC_22     5.430861   0.000000    0.000000    4.857105    0.000000
#> COSMIC_23     0.000000   0.000000    0.000000    0.000000    0.000000
#> COSMIC_24     0.834280   0.000000    1.417995    2.584883    0.000000
#> COSMIC_25     0.000000   4.803570    0.000000    0.000000    0.000000
#> COSMIC_26     5.146132   0.000000    3.721977    8.602417    0.345477
#> COSMIC_27     0.818058   0.619339    0.761797    0.000000    0.000000
#> COSMIC_28     0.000000   2.255656    0.000000    0.000000   34.627985
#> COSMIC_29     0.000000   0.000000    0.000000    0.000000    0.426970
#> COSMIC_30    14.907068   0.000000    4.971933   13.449397    0.000000
#>              Sample_17   Sample_18    Sample_19  Sample_20   Sample_21
#> COSMIC_1   8316.462448  449.235151  4386.555077 363.844840    2.290543
#> COSMIC_2   2279.911970  188.412956     0.000000   0.976010    0.000000
#> COSMIC_3      0.000000    0.000000    10.619926   0.000000 4153.467439
#> COSMIC_4      0.000000    0.000000     0.000000   0.000000    2.701635
#> COSMIC_5      0.000000    0.000000 10084.344976 269.259689  658.647006
#> COSMIC_6   5025.247765    0.000000     0.000000   0.000000  678.815968
#> COSMIC_7      0.747681    0.000000     0.000000   0.000000    0.000000
#> COSMIC_8      0.000000 2273.138539    14.053514   0.000000 4977.312139
#> COSMIC_9      0.000000    0.000000     0.000000   2.240584    0.000000
#> COSMIC_10     0.000000    0.744366     0.000000   0.546513    2.916468
#> COSMIC_11     0.000000    0.000000     3.265850   0.000000    0.000000
#> COSMIC_12 10187.187402    0.000000  7976.495356 894.404021    0.000000
#> COSMIC_13     0.554193  611.961539  2670.903273   0.000000 2783.340620
#> COSMIC_14     0.000000    0.130862     0.843056   0.000000    0.000000
#> COSMIC_15     2.799945    0.000000     1.940155   0.000000    2.830738
#> COSMIC_16     0.000000    0.000000     0.000000   4.445176    0.000000
#> COSMIC_17  1856.568846 2002.188974     0.000000 171.786377    0.000000
#> COSMIC_18     0.422052    0.000000  7727.188645 864.379911    0.000000
#> COSMIC_19     0.000000    0.000000     5.532711   0.000000    7.724353
#> COSMIC_20     0.000000    0.000000     0.000000   2.817051    0.000000
#> COSMIC_21     2.655370    0.000000     0.000000   3.740846    0.000000
#> COSMIC_22     0.000000    0.000000     4.687859   1.469317    0.000000
#> COSMIC_23     0.000000    0.000000     0.000000   1.620364    0.000000
#> COSMIC_24     0.442328    0.000000     1.042670   0.000000    0.264848
#> COSMIC_25     0.000000    0.000000     0.000000   0.000000    0.000000
#> COSMIC_26     0.000000    0.000000     0.000000   0.000000    0.000000
#> COSMIC_27     0.000000    0.000000     0.000000   0.186345    0.868987
#> COSMIC_28     0.000000   41.821921     0.000000  11.010071   50.943245
#> COSMIC_29     0.000000    4.365692     0.000000   3.883271    9.876013
#> COSMIC_30     0.000000    0.000000     4.526931   0.389614    0.000000
#>              Sample_22   Sample_23    Sample_24   Sample_25   Sample_26
#> COSMIC_1   6540.916420    6.159738     0.055064 1452.748133 1094.123285
#> COSMIC_2      0.000000    0.000000     0.000000 1077.063506    0.025763
#> COSMIC_3   9515.382232    5.609259  9861.205426    0.000000    0.000000
#> COSMIC_4      5.436190    0.000000     1.031979    0.000000    0.000000
#> COSMIC_5  19242.733385  716.821835 18259.774984    0.000000    0.000000
#> COSMIC_6   2303.560317  590.443877     0.000000 1077.149896 2593.375058
#> COSMIC_7      0.000000    0.000000     0.547807    0.000000    0.000000
#> COSMIC_8    649.560645  397.525523  1011.946226    0.000000 1027.564189
#> COSMIC_9      0.000000    0.000000     0.000000    0.000000    0.000000
#> COSMIC_10     4.076000    0.000000     0.000000    0.000000    0.600252
#> COSMIC_11     0.000000    0.366592     0.032034    0.000000    0.000000
#> COSMIC_12     0.000000   11.509237     0.000000    0.000000    0.000000
#> COSMIC_13     2.206680    0.000000 11882.297110    0.000000  629.765176
#> COSMIC_14     1.424192    0.000000     0.000000    4.153187    0.000000
#> COSMIC_15     0.000000    2.597857     0.008799    5.873210    0.000000
#> COSMIC_16     0.000000    0.480866     0.000000    0.000000    0.000000
#> COSMIC_17     0.000000  715.327401     0.000000 2647.566963  586.764687
#> COSMIC_18     0.000000 1952.671547  4876.507688 3890.903392    0.615152
#> COSMIC_19     2.685663    3.146145     1.567203    0.000000    0.000000
#> COSMIC_20     0.000000    3.430529     0.000000    6.541714    0.000000
#> COSMIC_21     0.000000    0.000000     0.000000    0.000000    1.270163
#> COSMIC_22     0.000000    2.222490     0.000000    0.000000    0.000000
#> COSMIC_23     4.809075    0.000000     0.000000    0.000000    0.000000
#> COSMIC_24     0.000000    3.288456     0.000000    0.000000    0.000000
#> COSMIC_25     0.000000    0.000000     0.000000    0.000000    0.000000
#> COSMIC_26     0.000000    0.398648     0.115265    0.000000    0.000000
#> COSMIC_27     0.000000    0.000000     0.000000    0.000000    0.000000
#> COSMIC_28    77.893251    0.000000     0.000000    0.000000    9.215891
#> COSMIC_29     6.315948    0.000000     0.000000    0.000000    1.680384
#> COSMIC_30     0.000000    0.000000     0.910415    0.000000    0.000000
#>             Sample_27   Sample_28   Sample_29   Sample_30
#> COSMIC_1     0.000000    0.500188  607.006162    3.733558
#> COSMIC_2     0.000000    0.000000    0.000000    0.000000
#> COSMIC_3    17.937813  201.260807  165.569996    0.000000
#> COSMIC_4     2.513001    2.925134    6.355168    0.000000
#> COSMIC_5  1491.103136 1189.447225    0.000000    0.000000
#> COSMIC_6     3.892577    0.000000    0.000000  673.361426
#> COSMIC_7     0.000000    0.000000    0.000000    0.724157
#> COSMIC_8  2179.372379    0.000000  960.287135  881.374297
#> COSMIC_9     1.022470    0.000000    0.000000    3.264570
#> COSMIC_10    1.467921    0.999990    0.000000    0.981160
#> COSMIC_11    0.000000    0.000000    0.062670    0.000000
#> COSMIC_12 2830.082067  356.938310  844.711035 1000.685511
#> COSMIC_13 2910.433262    1.442665    3.363711    0.000000
#> COSMIC_14    0.000000    0.000000    0.000000    0.000000
#> COSMIC_15    0.000000    0.000000    0.000000    0.000000
#> COSMIC_16    7.868604    8.495648    0.000000    0.000000
#> COSMIC_17    0.065766    0.000000 1048.224909  341.855428
#> COSMIC_18  639.739510 1192.979715    0.000000    0.392853
#> COSMIC_19    0.000000    0.000000    2.545339    1.095533
#> COSMIC_20    0.000000    0.438308    2.757058    0.000000
#> COSMIC_21    0.439556    3.331728    2.698298    0.060492
#> COSMIC_22    0.000000    0.000000    0.372904    0.000000
#> COSMIC_23    0.000000    0.000000    0.000000    0.000000
#> COSMIC_24    0.000000    2.817830    0.935905    0.000000
#> COSMIC_25    3.769250    0.000000    0.000000    3.310930
#> COSMIC_26    0.000000    2.716184    0.000000    0.000000
#> COSMIC_27    0.292688    0.475940    0.000000    0.000000
#> COSMIC_28    0.000000    8.230327    0.000000    8.160085
#> COSMIC_29    0.000000    0.000000    0.000000    0.000000
#> COSMIC_30    0.000000    0.000000    3.109709    0.000000
# Check ?sig_fit for sig_db options
# e.g., use the COSMIC SBS v3
sig_fit(data, sig_index = "ALL", sig_db = "SBS")
#>  [2024-08-04 14:44:52.792202]: Started.
#>  [2024-08-04 14:44:52.793705]: Signature index detected.
#>  [2024-08-04 14:44:52.795076]: Checking signature database in package.
#>  [2024-08-04 14:44:52.798386]: Checking signature index.
#>  [2024-08-04 14:44:52.799865]: Valid index for db 'SBS':
#> 1 2 3 4 5 6 7a 7b 7c 7d 8 9 10a 10b 11 12 13 14 15 16 17a 17b 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 84 85 86 87 88 89 90
#>  [2024-08-04 14:44:52.80159]: Database and index checked.
#>  [2024-08-04 14:44:52.803625]: Signature normalized.
#>  [2024-08-04 14:44:52.805068]: Checking row number for catalog matrix and signature matrix.
#>  [2024-08-04 14:44:52.806484]: Checked.
#>  [2024-08-04 14:44:52.807817]: Checking rownames for catalog matrix and signature matrix.
#>  [2024-08-04 14:44:52.809186]: Matrix V and W don't have same orders. Try reordering...
#>  [2024-08-04 14:44:52.81069]: Checked.
#>  [2024-08-04 14:44:52.812097]: Method 'QP' detected.
#>  [2024-08-04 14:44:52.813494]: Corresponding function generated.
#>  [2024-08-04 14:44:52.814839]: Calling function.
#>  [2024-08-04 14:44:52.816531]: Fitting sample: Sample_1
#>  [2024-08-04 14:44:52.819893]: Fitting sample: Sample_2
#>  [2024-08-04 14:44:52.823678]: Fitting sample: Sample_3
#>  [2024-08-04 14:44:52.827028]: Fitting sample: Sample_4
#>  [2024-08-04 14:44:52.830553]: Fitting sample: Sample_5
#>  [2024-08-04 14:44:52.834314]: Fitting sample: Sample_6
#>  [2024-08-04 14:44:52.837776]: Fitting sample: Sample_7
#>  [2024-08-04 14:44:52.841288]: Fitting sample: Sample_8
#>  [2024-08-04 14:44:52.844759]: Fitting sample: Sample_9
#>  [2024-08-04 14:44:52.848353]: Fitting sample: Sample_10
#>  [2024-08-04 14:44:52.851695]: Fitting sample: Sample_11
#>  [2024-08-04 14:44:52.855032]: Fitting sample: Sample_12
#>  [2024-08-04 14:44:52.858595]: Fitting sample: Sample_13
#>  [2024-08-04 14:44:52.862153]: Fitting sample: Sample_14
#>  [2024-08-04 14:44:52.86558]: Fitting sample: Sample_15
#>  [2024-08-04 14:44:52.868911]: Fitting sample: Sample_16
#>  [2024-08-04 14:44:52.872537]: Fitting sample: Sample_17
#>  [2024-08-04 14:44:52.876085]: Fitting sample: Sample_18
#>  [2024-08-04 14:44:52.879736]: Fitting sample: Sample_19
#>  [2024-08-04 14:44:52.883405]: Fitting sample: Sample_20
#>  [2024-08-04 14:44:52.8871]: Fitting sample: Sample_21
#>  [2024-08-04 14:44:52.890651]: Fitting sample: Sample_22
#>  [2024-08-04 14:44:52.893972]: Fitting sample: Sample_23
#>  [2024-08-04 14:44:52.897363]: Fitting sample: Sample_24
#>  [2024-08-04 14:44:52.900674]: Fitting sample: Sample_25
#>  [2024-08-04 14:44:52.904116]: Fitting sample: Sample_26
#>  [2024-08-04 14:44:52.907596]: Fitting sample: Sample_27
#>  [2024-08-04 14:44:52.911031]: Fitting sample: Sample_28
#>  [2024-08-04 14:44:52.91458]: Fitting sample: Sample_29
#>  [2024-08-04 14:44:52.918061]: Fitting sample: Sample_30
#>  [2024-08-04 14:44:52.921463]: Done.
#>  [2024-08-04 14:44:52.923605]: Generating output signature exposures.
#>  [2024-08-04 14:44:52.926977]: Done.
#>  [2024-08-04 14:44:52.929136]: 0.137 secs elapsed.
#>           Sample_1    Sample_2    Sample_3    Sample_4    Sample_5   Sample_6
#> SBS1     446.06618  352.314782  168.179569    0.000000    5.994249  25.885569
#> SBS2       0.00000 3425.967684  416.028733  640.708332  910.549175 344.154284
#> SBS3    3771.33903    0.000000  529.937946  846.042672    0.000000  73.000551
#> SBS4       0.00000    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS5       0.00000    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS6       0.00000 1726.029066 2043.106593    0.000000    0.000000 204.770660
#> SBS7a     80.53353   31.357883   96.283573    0.000000   14.013953   9.759239
#> SBS7b      0.00000    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS7c      0.00000    0.000000    9.552791   13.184604    0.000000   0.000000
#> SBS7d      0.00000    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS8   10694.42205 3007.207116  241.938865  523.427765    0.000000 186.857134
#> SBS9       0.00000    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS10a   153.11952    1.416355    0.000000    0.000000    0.000000   0.000000
#> SBS10b     0.00000    0.000000    0.000000    0.000000    0.000000   9.750629
#> SBS11      0.00000    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS12   6574.02430 1225.580812  802.817948 1287.869219    0.000000   6.894609
#> SBS13      0.00000 4656.694903 2134.082718 3156.021470 1048.843041  67.457769
#> SBS14     28.40582  205.282129  141.193981    0.000000    0.000000  14.360009
#> SBS15      0.00000  243.401641  285.680515   85.001522    0.492277  10.182468
#> SBS16      0.00000   26.701935  156.635587   28.033701    0.000000  16.904165
#> SBS17a     0.00000    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS17b   633.73405   89.498911   88.722111   55.729454    5.409310   4.165818
#> SBS18    759.74051    0.000000  538.012825  685.037228  483.659079 308.830495
#> SBS19    992.13906  332.607459  132.973567  197.661357   13.525765  16.975074
#> SBS20      0.00000  542.428688  538.347687   60.203392    0.000000  55.499404
#> SBS21    674.43422  227.167678  141.056290  149.539709    0.000000   6.656367
#> SBS22      0.00000    0.000000  116.105848   85.886136    5.663501   0.000000
#> SBS23      0.00000    0.000000   78.592222    0.000000    0.000000   0.000000
#> SBS24      0.00000    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS25      0.00000    0.000000    0.000000    0.000000    4.577926   9.073294
#> SBS26   1368.51363  675.253249  311.575696  432.320720    0.000000   0.000000
#> SBS27      0.00000    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS28      0.00000   11.237706   51.069161    1.403327    4.411267  10.817382
#> SBS29      0.00000  103.345568  260.388505  176.475073   23.588253   5.965772
#> SBS30     28.26495  133.174428   60.370199  274.593445   13.364214   0.045889
#> SBS31      0.00000    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS32    582.70432    0.000000    0.000000    0.000000    0.000000   7.419328
#> SBS33     74.60755    0.000000    0.000000   11.095022    0.000000   0.000000
#> SBS34    163.81922   32.572782   38.025511    2.880772    0.000000   0.000000
#> SBS35      0.00000    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS36      0.00000    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS37     45.71330    0.000000   43.451880    0.000000    0.000000   0.000000
#> SBS38     95.69621   27.303541    0.000000    0.000000   28.717133   5.517314
#> SBS39   4669.90834  413.444300  495.025206  981.152408   37.940224  98.709340
#> SBS40   4839.36935    0.000000    0.000000    0.000000    0.000000  16.563255
#> SBS41    402.41959  306.407425    0.000000  139.922437    0.000000   0.000000
#> SBS42      0.00000    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS43    476.83270   89.510008   33.200380   93.713704    7.627752  12.787340
#> SBS44    800.69479    0.000000    0.000000   30.143590    0.000000   0.000000
#> SBS45      0.00000    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS46   2667.89235  472.188567  206.830069  343.326092   25.375581  20.077460
#> SBS47      0.00000    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS48      0.00000    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS49      0.00000   12.251611   42.858293    0.000000    0.000000   4.059684
#> SBS50    143.97597    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS51      0.00000    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS52      0.00000    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS53      0.00000   45.504335    4.587349   87.644537    8.234425   0.000000
#> SBS54    464.72114  333.495978  412.021703  149.746217    0.000000  29.980835
#> SBS55    128.38732    0.000000   17.731337    0.000000    0.000000   6.235518
#> SBS56      0.00000    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS57      0.00000    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS58    334.00510    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS59      0.00000    0.000000   26.671728   47.236094   22.587013   3.198901
#> SBS60      0.00000    0.000000    0.000000    0.000000    2.440548   0.000000
#> SBS84      0.00000    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS85      0.00000    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS86      0.00000   74.653461   41.588576    0.000000   25.721078  16.886622
#> SBS87      0.00000    0.000000   63.557111    0.000000    0.000000   3.557824
#> SBS88      0.00000    0.000000    1.797925    0.000000    2.264237   0.000000
#> SBS89    618.90584    0.000000    0.000000    0.000000    0.000000   0.000000
#> SBS90     45.61003    0.000000    0.000000    0.000000    0.000000   0.000000
#>          Sample_7   Sample_8    Sample_9   Sample_10  Sample_11   Sample_12
#> SBS1    22.282475 537.811662  111.823576  158.293396 454.206109     0.00000
#> SBS2    71.991947 183.018549  157.000784  947.247238 566.548529   805.65037
#> SBS3     0.000000 143.899490    0.000000    0.000000   0.000000  6184.00074
#> SBS4     0.000000   0.000000    0.000000    0.000000   0.000000     0.00000
#> SBS5     0.000000   0.000000    0.000000  903.074564   0.000000     0.00000
#> SBS6   134.862279  44.825275   54.854165    0.000000 534.236805     0.00000
#> SBS7a   12.390872   0.000000   69.774383   55.049491  46.277416   159.64607
#> SBS7b    0.000000   0.000000    0.000000    0.000000   0.000000     0.00000
#> SBS7c    0.000000   0.000000   18.597067    0.000000   0.000000     8.01225
#> SBS7d    0.000000  11.646995   24.273000    0.000000   5.394268     0.00000
#> SBS8     0.000000  46.345664  752.023973 1726.187855 182.572187  3085.33988
#> SBS9     0.000000   0.000000    0.000000    0.000000   0.000000     0.00000
#> SBS10a   0.000000   0.000000    0.000000   25.722906   0.000000     0.00000
#> SBS10b   0.000000  64.443724   85.060103    2.968258  41.641692     0.00000
#> SBS11    0.000000   0.000000    0.000000    0.000000   0.000000     0.00000
#> SBS12   20.024290  40.777575    0.000000  313.261304 304.806769  6665.67297
#> SBS13  342.294209  36.903526  618.547019  123.896219 709.031907  3698.10516
#> SBS14    0.000000   0.000000    6.393714   32.313379  56.934479     0.00000
#> SBS15   27.412567   0.000000    0.000000    0.000000  14.409081     0.00000
#> SBS16   21.376273  49.207382   43.774168  165.034005 166.120986   200.88922
#> SBS17a  30.455635   0.000000  822.375525    2.517252   0.000000     0.00000
#> SBS17b  83.545702   2.816105 1995.236792   50.873045  41.974652   272.36890
#> SBS18  422.824481 602.084768   59.882419 1358.752476  19.009159 11057.12324
#> SBS19   12.408097  48.015048  172.717375  169.932277 118.193294   970.86051
#> SBS20   50.695857   0.000000    0.000000    0.000000  46.093320     0.00000
#> SBS21    8.783053  26.942837    0.000000    0.000000  51.083282   745.05904
#> SBS22   11.882019   2.636566    0.000000   19.390117  59.053621   490.51076
#> SBS23    3.688235   0.000000    0.000000    0.000000   0.000000     0.00000
#> SBS24    0.000000   0.000000    0.000000    0.000000   0.000000     0.00000
#> SBS25   30.355093   0.000000  257.444434  326.561438  77.093342     0.00000
#> SBS26   27.409536   0.000000    0.000000    0.000000  10.841186   923.79026
#> SBS27    0.000000   0.000000    0.000000    0.000000   0.000000     0.00000
#> SBS28    0.000000   0.000000    0.000000    0.000000   0.000000    14.44337
#> SBS29   27.575693  46.107948    0.000000    0.000000 118.269963   509.55429
#> SBS30   13.698437 128.585141  455.947345  108.207348 230.267852  1008.02779
#> SBS31    0.000000   0.000000    0.000000    0.000000   0.000000     0.00000
#> SBS32    0.000000   0.000000    0.000000  110.800641   0.000000     0.00000
#> SBS33    0.000000   1.878902    3.327825    0.000000   0.000000    33.75485
#> SBS34    0.000000   0.921931    0.000000   52.744061  33.554375     0.00000
#> SBS35    0.000000   0.000000    0.000000    0.000000   0.000000     0.00000
#> SBS36    0.000000   0.000000    0.000000    0.000000   0.000000     0.00000
#> SBS37    0.139980   0.000000  346.544066   80.444489  87.335575   423.62339
#> SBS38    2.881911   0.000000    0.000000    0.000000   0.000000    44.98554
#> SBS39   98.537850  46.354419 1171.321287  961.678364 274.919586  6302.87792
#> SBS40    0.000000  82.379062   52.899760 1069.312766 432.680915  1611.84753
#> SBS41    0.000000   0.000000   46.316697    0.000000   0.000000     0.00000
#> SBS42    0.000000  51.687712    0.000000    0.000000  70.503752     0.00000
#> SBS43    6.868222  10.215896   99.515868    0.000000   0.000000   586.08394
#> SBS44    0.000000  38.032543    0.000000  148.834240  76.628999   709.29531
#> SBS45    0.000000   0.000000    0.000000    0.000000   0.000000     0.00000
#> SBS46   32.187431  42.702520  344.814521  326.281258 131.710817  1719.69606
#> SBS47    0.000000   0.000000    0.000000    0.000000   0.000000     0.00000
#> SBS48    0.000000   2.696820    0.000000    3.243888   0.427387     0.00000
#> SBS49    4.502460   0.000000    0.000000    0.000000   4.302329     0.00000
#> SBS50    0.000000   0.000000    5.589561   57.802376   0.000000     0.00000
#> SBS51    0.000000  12.081070    0.000000    0.000000   0.000000     0.00000
#> SBS52    0.000000   0.172794    0.000000    0.000000   0.000000     0.00000
#> SBS53   10.365112   6.245482    0.000000    0.000000   0.000000   408.17094
#> SBS54   34.031074  19.374629  193.897934   26.152249 144.294493   899.65197
#> SBS55    4.295673   6.462695   61.642802   84.973562  26.553492   220.06937
#> SBS56    0.000000   0.000000    0.000000    2.141215  20.306141     0.00000
#> SBS57    0.000000   0.000000    0.000000    0.000000   0.000000     0.00000
#> SBS58    0.000000   0.000000   38.156071    0.000000   0.000000     0.00000
#> SBS59   15.640245   0.000000   24.927538   16.528503   0.000000   208.88834
#> SBS60    0.000000   0.000000    0.000000    0.000000   0.000000     0.00000
#> SBS84    0.000000   9.483127    0.000000    7.077683  45.488530     0.00000
#> SBS85    0.000000   0.000000    0.000000    0.000000   0.000000     0.00000
#> SBS86    0.000000  28.019974    0.000000   67.590799  53.233710     0.00000
#> SBS87    7.991066  17.222170   29.320231    0.000000   0.000000     0.00000
#> SBS88    3.602225   0.000000    0.000000   40.716475   0.000000     0.00000
#> SBS89    0.000000   0.000000    0.000000  167.394862   0.000000     0.00000
#> SBS90    0.000000   0.000000    0.000000    0.000000   0.000000     0.00000
#>         Sample_13  Sample_14   Sample_15   Sample_16  Sample_17   Sample_18
#> SBS1    28.001829  32.192936  306.827718    0.000000 3768.83346  339.680283
#> SBS2   134.544443 988.792807  550.127522  163.748275 1763.48657  293.046081
#> SBS3    27.754255  59.724612    0.000000  870.820214    0.00000    0.000000
#> SBS4     0.000000   0.000000    0.000000    0.000000  549.77782    0.000000
#> SBS5     0.000000   0.000000  174.813970    0.000000    0.00000    0.000000
#> SBS6     7.846333 135.073945  191.795767    0.000000 3912.75669    0.000000
#> SBS7a    0.000000  31.443795   78.993069   19.321636  147.51575    2.606657
#> SBS7b    0.000000   0.000000    0.000000    0.000000    0.00000    0.000000
#> SBS7c    3.931945   0.550038   28.913647    3.962225   34.41563   19.927144
#> SBS7d    0.000000   0.000000    3.740986    0.000000    0.00000   15.357364
#> SBS8   271.669355 194.303767  413.159576  104.067645 1313.15753 1426.620135
#> SBS9     0.000000   0.000000    0.000000    0.000000    0.00000    0.000000
#> SBS10a   0.000000   0.000000    0.000000    0.000000    0.00000   14.075468
#> SBS10b   0.000000   5.034643    0.000000    0.000000  497.14044   66.038580
#> SBS11    0.000000   0.000000    0.000000    0.000000    0.00000    0.000000
#> SBS12  199.802691 529.670206  386.074220  876.799245 4260.22235    0.000000
#> SBS13  636.096640 876.428834 2796.783863  611.170635  305.12018  569.672029
#> SBS14    0.000000  16.249060   41.575151    0.000000    0.00000   35.332573
#> SBS15   29.754648   3.102191   33.512358    0.000000    0.00000    0.000000
#> SBS16    0.000000  46.548339  249.448229    5.676878    0.00000   24.323727
#> SBS17a   0.000000   0.000000  302.834378    0.000000  129.11193  411.929867
#> SBS17b   5.531471  26.832580  850.430656   14.949794 1035.22385  974.709046
#> SBS18  315.312203  25.944850  847.661354 3170.336034    0.00000  178.789240
#> SBS19   32.444005 122.880074  207.207897  108.293262  969.02642  103.898398
#> SBS20   34.678629   4.941801    0.000000    0.000000  748.15868    0.000000
#> SBS21   34.167632  58.567700   34.163499  119.366888  809.51047    0.000000
#> SBS22    6.136127  41.278138   93.139137   80.829564    0.00000    0.000000
#> SBS23    0.000000   0.000000    0.000000    0.000000    0.00000    0.000000
#> SBS24    0.000000  26.573935    0.000000    0.000000  270.11766    0.000000
#> SBS25    0.000000   0.000000  296.198796    0.000000    0.00000   15.144629
#> SBS26   84.243212 171.407581   92.291742  173.750835 1536.70282    0.000000
#> SBS27    0.000000   0.000000    0.000000    0.000000    0.00000    0.000000
#> SBS28    0.000000   0.000000    0.000000   21.147276    0.00000    0.000000
#> SBS29   18.912710  15.244739  182.196469  108.856508   26.00825    0.000000
#> SBS30   10.798087 140.607690  503.657207   25.596949  788.99021  168.616351
#> SBS31    0.000000   0.000000    0.000000    0.000000    0.00000    0.000000
#> SBS32    0.000000   0.000000    0.000000    0.000000    0.00000   84.655713
#> SBS33    0.000000   5.713271    0.000000    0.000000   85.73891    0.000000
#> SBS34    2.189698   7.599702   43.804497    0.000000  102.82132   36.485559
#> SBS35    0.000000   0.000000    0.000000    0.000000    0.00000    0.000000
#> SBS36    0.000000   0.000000    0.000000    0.000000  259.24275    0.000000
#> SBS37    0.000000  25.197289  288.315048    0.000000    0.00000  160.147632
#> SBS38    9.332443   0.000000    0.000000   75.290621    0.00000    0.000000
#> SBS39   68.781644 144.015309  980.349565  607.706490    0.00000  216.281382
#> SBS40    0.000000  64.039981    0.000000    0.000000  870.76706    0.000000
#> SBS41   21.796491  40.795855   22.260438    0.000000    0.00000   20.375135
#> SBS42    0.000000   0.000000    0.000000    0.000000  321.62150    0.000000
#> SBS43   13.152285  12.929337    0.000000  104.533541  123.42461   28.622352
#> SBS44    0.000000  77.360275    0.000000    0.000000  130.97719    0.000000
#> SBS45    0.000000   0.000000    0.000000    0.000000   61.07298    0.000000
#> SBS46   61.389024 156.897641  396.162303  200.076291 1852.04462  165.417732
#> SBS47    0.000000   0.000000    0.000000    0.000000    0.00000    0.000000
#> SBS48    0.000000   0.000000    0.000000    0.000000   25.90892    0.000000
#> SBS49    0.000000   2.525869    0.000000   10.346805   17.46214    0.000000
#> SBS50    0.000000   0.000000    0.000000    0.000000    0.00000   37.419504
#> SBS51    0.000000   0.000000    0.000000    0.000000    0.00000    0.000000
#> SBS52    0.000000   0.000000    0.000000    0.000000   11.00697    0.000000
#> SBS53   17.890481   7.681697   11.629275   58.806127    0.00000    0.000000
#> SBS54   28.447591  76.502615  210.877981  118.741754  816.36626   71.480806
#> SBS55    0.000000   0.000000   57.589435    7.764625    0.00000   23.857029
#> SBS56    0.000000   0.000000    0.000000    0.000000    0.00000    0.000000
#> SBS57    0.000000   0.000000    0.000000    0.000000    0.00000    0.000000
#> SBS58    0.000000   0.000000    0.000000    0.000000    0.00000   13.990064
#> SBS59   12.394129   0.000000   35.175459   64.039886    0.00000    0.000000
#> SBS60    0.000000   0.000000    1.156692    0.000000    0.00000    0.000000
#> SBS84    0.000000   0.000000   55.998385    0.000000    0.00000    0.000000
#> SBS85    0.000000   0.000000    0.000000    0.000000    0.00000    0.000000
#> SBS86    0.000000  36.346898    0.000000    0.000000   91.49678    0.000000
#> SBS87    0.000000   0.000000    0.000000    0.000000   37.77131    0.000000
#> SBS88    0.000000   0.000000   19.133710    0.000000    0.00000   37.766637
#> SBS89    0.000000   0.000000    0.000000    0.000000    0.00000   12.844511
#> SBS90    0.000000   0.000000    0.000000    0.000000    0.00000    2.888371
#>         Sample_19  Sample_20   Sample_21   Sample_22   Sample_23   Sample_24
#> SBS1   2039.96413 149.158926  286.642351 3607.798297   64.813752   258.64970
#> SBS2    445.80008  13.538846  490.209770    0.000000   29.791716  1941.03529
#> SBS3    678.52730 169.659789 1068.273153 3921.433569    0.000000  3183.74145
#> SBS4      0.00000   0.000000    0.000000    0.000000    0.000000     0.00000
#> SBS5    201.85371   0.000000    0.000000 4030.270929   12.474698     0.00000
#> SBS6    417.35098  25.618342  129.473906 1516.347817  302.044684   315.32997
#> SBS7a   133.10227   3.344145    0.000000    0.000000   14.830055   139.85363
#> SBS7b     0.00000   0.000000    0.000000  260.023779   49.090467     0.00000
#> SBS7c    25.69606   6.172160    0.000000    0.000000    0.000000     0.00000
#> SBS7d    52.27566   0.000000    0.000000    3.906008   14.841736     0.00000
#> SBS8   1040.78581  29.602216 3384.145192 3682.760308  167.949333  3361.33783
#> SBS9      0.00000   0.000000    0.000000    0.000000    0.000000     0.00000
#> SBS10a    0.00000   0.000000    7.837407    0.000000    0.000000     0.00000
#> SBS10b  120.25710  19.063797    0.000000  215.971775    4.815127     0.00000
#> SBS11     0.00000   0.000000    0.000000    0.000000    0.000000     0.00000
#> SBS12  4681.57550 377.313258   22.330920 1826.753963   26.915648  2263.77573
#> SBS13  2149.95080   0.000000 2443.237730    0.000000    0.000000 10264.02086
#> SBS14     0.00000   0.000000  198.887944   95.039818    0.000000   247.25276
#> SBS15     0.00000   0.000000  118.877164    0.000000   33.665517   240.66544
#> SBS16   549.16383   1.970066  120.545561  912.347449   80.202308   992.92106
#> SBS17a    0.00000  13.180932    9.827664    0.000000  144.120515     0.00000
#> SBS17b  202.08236  91.997549   69.766747  367.148242  351.623623   343.39896
#> SBS18  8697.20643 932.812046  198.986888  408.409474 2102.526390  5241.52426
#> SBS19   968.68842  75.833193  131.918504  714.956053   32.960581   622.83147
#> SBS20     0.00000   2.976527    0.000000    0.000000  107.462006     0.00000
#> SBS21   576.84560  47.030647    0.000000  203.966450   26.326930    49.51724
#> SBS22   502.35846  32.686480    0.000000  530.214364   39.459208   491.53506
#> SBS23     0.00000   0.000000    0.000000    0.000000    0.000000     0.00000
#> SBS24     0.00000   0.000000    0.000000  345.054470    0.000000     0.00000
#> SBS25     0.00000   0.000000    0.000000    0.000000   81.637871   428.00593
#> SBS26  1314.17646 182.324101    0.000000    0.000000   14.955289     0.00000
#> SBS27     0.00000   0.000000    0.000000    0.000000    0.000000     0.00000
#> SBS28     0.00000   0.000000   17.709407  196.736072    0.000000    85.54777
#> SBS29   697.36208  61.226818    0.000000   79.651009   65.803910   620.90145
#> SBS30  1308.97875  72.536829   27.856473 1672.430828    0.000000  1850.79197
#> SBS31     0.00000   0.000000    0.000000    0.000000    0.000000     0.00000
#> SBS32     0.00000   0.000000  168.914809    0.000000   28.444934     0.00000
#> SBS33    34.21223   4.326822    0.000000    0.000000    0.000000     0.00000
#> SBS34    89.32408   0.000000   44.871504  239.198619    0.000000   136.04087
#> SBS35     0.00000   0.000000    0.000000    0.000000    0.000000     0.00000
#> SBS36     0.00000   0.000000    0.000000  970.050452    0.000000     0.00000
#> SBS37   243.31956   0.000000   94.901735 1355.740141   53.064000   997.58414
#> SBS38     0.00000   0.000000   15.619834    0.000000   20.502614     0.00000
#> SBS39  2033.14621   2.492142 1795.540572 4557.112712  163.341544  6684.12750
#> SBS40   507.37936   0.000000  698.355023  921.745663    0.000000   631.20712
#> SBS41     0.00000   0.000000  214.408512    0.000000    0.000000   165.81377
#> SBS42   387.17367   1.843926    0.000000  215.393710    0.000000     0.00000
#> SBS43    77.22160  19.283081   81.674594    0.000000   38.458833    17.81008
#> SBS44   334.40110   0.000000  327.136899 1428.965561    0.000000   196.31151
#> SBS45     0.00000   0.000000    0.000000    0.000000    0.000000     0.00000
#> SBS46  1187.63294 149.120705  374.743621 1243.993328   82.355773  1204.33307
#> SBS47     0.00000   0.000000    0.000000    0.000000    0.000000     0.00000
#> SBS48    17.09584   3.043544    0.000000   42.086791    3.255971     0.00000
#> SBS49    20.54985   2.861795    0.000000    0.000000   12.742081     0.00000
#> SBS50     0.00000   0.000000   74.725290  285.809203    0.000000     0.00000
#> SBS51     0.00000   0.000000    0.000000  177.941426    0.000000     0.00000
#> SBS52     0.00000   0.000000    0.000000   13.832885    0.000000     0.00000
#> SBS53   245.01094  30.934044    0.000000    0.000000   30.052391    70.33150
#> SBS54   680.59053  43.892390   63.077704  775.743274  112.637111   777.30314
#> SBS55   133.63464   0.000000   65.723138  399.837615   19.689125   404.77848
#> SBS56     0.00000   0.000000    0.000000   75.157938    0.000000     0.00000
#> SBS57     0.00000   0.000000    0.000000    0.000000    0.000000     0.00000
#> SBS58     0.00000   0.000000    0.000000    0.000000    0.000000     0.00000
#> SBS59    61.18227   8.445741    0.221444    0.000000   40.352963   163.47821
#> SBS60     0.00000   0.000000    0.000000    0.000000    0.000000    10.53115
#> SBS84    13.79664   0.000000    0.000000  862.070844    0.000000   522.16438
#> SBS85     0.00000   0.000000    0.000000    0.000000    0.000000     0.00000
#> SBS86     0.00000   0.000000   16.304181  201.099164    0.000000    92.05212
#> SBS87    22.32674  22.709145    0.000000    0.000000   38.791296     0.00000
#> SBS88     0.00000   0.000000  142.860995    0.000000    0.000000   341.17166
#> SBS89     0.00000   0.000000  426.393365    0.000000    0.000000   538.32346
#> SBS90     0.00000   0.000000    0.000000    0.000000    0.000000     0.00000
#>         Sample_25   Sample_26   Sample_27   Sample_28  Sample_29  Sample_30
#> SBS1    715.26298  634.542555   97.144930   17.132813 331.946933  78.026773
#> SBS2    915.44808  117.860979  522.154264    0.000000  12.821998   5.844568
#> SBS3      0.00000  135.332768   98.776505  128.519753   0.000000   0.000000
#> SBS4      0.00000    0.000000    0.000000    0.000000   0.000000   0.000000
#> SBS5      0.00000    0.000000    0.000000  161.996986   0.000000   0.000000
#> SBS6    689.16873 1541.241453    0.000000    0.000000   3.783462 383.761328
#> SBS7a    41.41883   38.677954    0.000000   11.908640  20.280163  16.964497
#> SBS7b    99.59051    0.000000    0.000000    0.000000   0.000000   0.000000
#> SBS7c     0.00000    0.000000    6.486657    0.000000   8.811085   3.691475
#> SBS7d    34.15372    2.395097    0.000000    3.955165   9.851980   0.000000
#> SBS8      0.00000  681.108432 1719.614316   71.572480 806.281840 662.859786
#> SBS9      0.00000    0.000000    0.000000    0.000000   0.000000   0.000000
#> SBS10a    0.00000   11.579627    0.000000    0.000000   3.388724  11.896212
#> SBS10b  118.53761   72.047259    0.000000    0.000000  48.151659   9.716146
#> SBS11     0.00000    0.000000    0.000000    0.000000   0.000000   0.000000
#> SBS12     0.00000    0.000000 1331.874170  256.765098 385.215644 384.698087
#> SBS13   142.54453  549.553092 2521.993959    0.000000   3.829160   0.000000
#> SBS14     0.00000   89.353574    3.976861    0.000000   0.000000   0.000000
#> SBS15     0.00000  164.337312   45.066962    0.000000   0.000000  28.937012
#> SBS16    47.89028   49.917611   54.130287   59.299428   0.000000   0.000000
#> SBS17a  527.28234  109.877255    0.000000    0.000000 193.647345  49.848785
#> SBS17b 1249.35844  316.036119   56.818127   17.498466 513.666816 184.072296
#> SBS18  4092.66460    0.000000  719.675872 1323.070156 115.834518  59.643639
#> SBS19   102.12862   57.870410  247.806564   56.428808 118.162708  79.374590
#> SBS20   139.14226  418.962491   48.086652   10.474487   0.000000 134.360464
#> SBS21    54.80644   84.178097  141.601596   33.725442  44.775909  67.720297
#> SBS22     0.00000    0.000000   18.652217   65.052251   0.000000   0.000000
#> SBS23     0.00000   26.746002    0.000000    0.000000   0.000000   0.000000
#> SBS24     0.00000    0.000000    0.000000    0.000000   0.000000   0.000000
#> SBS25   123.31873    0.000000    0.000000    0.000000   0.000000   0.000000
#> SBS26     0.00000   57.640211  563.624099   56.823231  92.462481 157.644444
#> SBS27     0.00000    0.000000    0.000000    0.000000   0.000000   0.000000
#> SBS28     0.00000   22.171820    0.000000    6.174538   0.000000   4.644259
#> SBS29   109.12476  107.511515   48.474971   51.301875   0.000000   0.000000
#> SBS30   112.84759    0.000000  228.071677   83.378787 145.874416   0.000000
#> SBS31     0.00000    0.000000    0.000000    0.000000   0.000000   0.000000
#> SBS32     0.00000    4.184894    0.000000    5.789955  35.307072  35.069669
#> SBS33     0.00000    0.000000    8.064016    0.000000   5.887511   0.000000
#> SBS34     0.00000   19.802653   39.593289    0.000000  18.082041  11.071147
#> SBS35     0.00000    0.000000    0.000000    0.000000   0.000000   0.000000
#> SBS36     0.00000    0.000000    0.000000    0.000000  18.240594   0.000000
#> SBS37     0.00000   16.316036   19.850480   60.193346  57.875193  28.620718
#> SBS38    71.42720    0.000000   15.461803    0.000000   0.000000   0.000000
#> SBS39     0.00000    0.000000  585.025564  219.133568 196.540684  56.636237
#> SBS40     0.00000  147.034337    0.000000    0.000000   0.000000  96.191112
#> SBS41     0.00000    0.000000  156.209343    0.000000   0.000000  25.061704
#> SBS42     0.00000    0.000000    0.000000    0.000000   0.000000   0.000000
#> SBS43   116.79137   35.157954   44.196808    4.243583  41.828618  26.257371
#> SBS44     0.00000    0.000000   78.587032    0.000000  53.753195   0.000000
#> SBS45     0.00000    0.000000    0.000000    0.000000   0.000000   7.222362
#> SBS46   170.67822   94.349848  383.875257   90.990960 223.105675 180.740558
#> SBS47     0.00000    0.000000    0.000000    0.000000   0.000000   0.000000
#> SBS48    10.63455    0.000000    0.000000    4.317328   1.643012   1.461703
#> SBS49    24.09664   18.294508    0.000000    2.687782   0.000000   3.089554
#> SBS50     0.00000    0.000000    0.000000    0.000000   0.000000   0.000000
#> SBS51     0.00000    0.000000    0.000000    2.970443   0.000000   0.000000
#> SBS52     0.00000    0.000000    0.000000    0.000000   0.000000   0.000000
#> SBS53    34.59448    0.000000   45.956342   33.204852   0.000000   2.130033
#> SBS54   205.88736  231.161914  116.190376   62.468310  69.307871 101.437669
#> SBS55     0.00000    3.962804    0.000000   26.370852   0.000000   0.000000
#> SBS56     0.00000    0.000000    0.000000    0.000000   0.000000   0.000000
#> SBS57     0.00000    0.000000    0.000000    0.000000   0.000000   0.000000
#> SBS58     0.00000    0.000000    0.000000    0.000000  54.231690  15.996187
#> SBS59    78.94552    0.000000   26.476898   18.953207   0.000000   3.123757
#> SBS60     0.00000    0.000000    0.000000    0.000000   0.000000   0.000000
#> SBS84     0.00000    0.000000    0.000000   21.867725   0.000000   0.000000
#> SBS85     0.00000    0.000000    0.000000    0.000000   0.000000   0.000000
#> SBS86    35.40706   34.931998    0.000000    0.000000   2.568502   0.000000
#> SBS87    98.84852   50.861422    0.000000    2.794004   7.374950   1.185562
#> SBS88     0.00000    0.000000    0.000000    1.935681   0.000000   0.000000
#> SBS89     0.00000    0.000000   96.482104    0.000000   0.000000   0.000000
#> SBS90     0.00000    0.000000    0.000000    0.000000   3.466548   0.000000

# Fitting with specified signatures
# opt 1. use selected reference signatures
sig_fit(data, sig_index = c(1, 5, 9, 2, 13), sig_db = "SBS")
#>  [2024-08-04 14:44:52.937356]: Started.
#>  [2024-08-04 14:44:52.939675]: Signature index detected.
#>  [2024-08-04 14:44:52.941836]: Checking signature database in package.
#>  [2024-08-04 14:44:52.946859]: Checking signature index.
#>  [2024-08-04 14:44:52.949281]: Valid index for db 'SBS':
#> 1 2 3 4 5 6 7a 7b 7c 7d 8 9 10a 10b 11 12 13 14 15 16 17a 17b 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 84 85 86 87 88 89 90
#>  [2024-08-04 14:44:52.951558]: Database and index checked.
#>  [2024-08-04 14:44:52.953944]: Signature normalized.
#>  [2024-08-04 14:44:52.956054]: Checking row number for catalog matrix and signature matrix.
#>  [2024-08-04 14:44:52.958142]: Checked.
#>  [2024-08-04 14:44:52.960174]: Checking rownames for catalog matrix and signature matrix.
#>  [2024-08-04 14:44:52.962236]: Matrix V and W don't have same orders. Try reordering...
#>  [2024-08-04 14:44:52.964396]: Checked.
#>  [2024-08-04 14:44:52.966454]: Method 'QP' detected.
#>  [2024-08-04 14:44:52.968473]: Corresponding function generated.
#>  [2024-08-04 14:44:52.97054]: Calling function.
#>  [2024-08-04 14:44:52.973019]: Fitting sample: Sample_1
#>  [2024-08-04 14:44:52.975243]: Fitting sample: Sample_2
#>  [2024-08-04 14:44:52.977415]: Fitting sample: Sample_3
#>  [2024-08-04 14:44:52.979546]: Fitting sample: Sample_4
#>  [2024-08-04 14:44:52.981683]: Fitting sample: Sample_5
#>  [2024-08-04 14:44:52.983794]: Fitting sample: Sample_6
#>  [2024-08-04 14:44:52.985927]: Fitting sample: Sample_7
#>  [2024-08-04 14:44:52.988038]: Fitting sample: Sample_8
#>  [2024-08-04 14:44:52.990175]: Fitting sample: Sample_9
#>  [2024-08-04 14:44:52.992294]: Fitting sample: Sample_10
#>  [2024-08-04 14:44:52.994452]: Fitting sample: Sample_11
#>  [2024-08-04 14:44:52.996574]: Fitting sample: Sample_12
#>  [2024-08-04 14:44:52.998715]: Fitting sample: Sample_13
#>  [2024-08-04 14:44:53.000821]: Fitting sample: Sample_14
#>  [2024-08-04 14:44:53.002985]: Fitting sample: Sample_15
#>  [2024-08-04 14:44:53.005169]: Fitting sample: Sample_16
#>  [2024-08-04 14:44:53.00735]: Fitting sample: Sample_17
#>  [2024-08-04 14:44:53.00952]: Fitting sample: Sample_18
#>  [2024-08-04 14:44:53.011661]: Fitting sample: Sample_19
#>  [2024-08-04 14:44:53.01384]: Fitting sample: Sample_20
#>  [2024-08-04 14:44:53.016013]: Fitting sample: Sample_21
#>  [2024-08-04 14:44:53.018194]: Fitting sample: Sample_22
#>  [2024-08-04 14:44:53.020355]: Fitting sample: Sample_23
#>  [2024-08-04 14:44:53.022581]: Fitting sample: Sample_24
#>  [2024-08-04 14:44:53.024775]: Fitting sample: Sample_25
#>  [2024-08-04 14:44:53.027068]: Fitting sample: Sample_26
#>  [2024-08-04 14:44:53.029295]: Fitting sample: Sample_27
#>  [2024-08-04 14:44:53.031051]: Fitting sample: Sample_28
#>  [2024-08-04 14:44:53.03253]: Fitting sample: Sample_29
#>  [2024-08-04 14:44:53.034003]: Fitting sample: Sample_30
#>  [2024-08-04 14:44:53.035446]: Done.
#>  [2024-08-04 14:44:53.036796]: Generating output signature exposures.
#>  [2024-08-04 14:44:53.039095]: Done.
#>  [2024-08-04 14:44:53.040685]: 0.103 secs elapsed.
#>         Sample_1  Sample_2  Sample_3  Sample_4   Sample_5  Sample_6  Sample_7
#> SBS1      0.0000 1115.5174 1181.6736    0.0000   27.23392 135.53666 111.05359
#> SBS5  34648.4926 9164.1835 6994.8599 5987.5245  515.60495 925.41428 752.16786
#> SBS9   7392.4247  714.1404  197.4413  812.2540  154.66961 123.51378 304.12381
#> SBS2      0.0000 3232.6125  289.5227  530.6185  916.24722 334.59501  66.95528
#> SBS13   719.0828 4597.5462 2106.5026 3255.6029 1081.24431  93.94027 362.69946
#>         Sample_8  Sample_9 Sample_10 Sample_11  Sample_12  Sample_13  Sample_14
#> SBS1   587.99786  147.1861  162.0096  671.2564     0.0000   36.54608   47.55306
#> SBS5  1384.80775 1446.2158 6936.2449 3157.4381 38419.2774 1134.71898 2205.32076
#> SBS9   151.54187 5555.3650 1307.8428  128.8525  6490.2218  189.47990  129.34338
#> SBS2   195.57640  267.6864  941.5376  575.5768   219.4109  109.66959  969.59018
#> SBS13   72.07613  707.5467  365.3650  722.8763  4839.0899  646.58545  859.19262
#>       Sample_15   Sample_16 Sample_17 Sample_18  Sample_19   Sample_20
#> SBS1   389.1707    4.650708  5234.915  343.9873  2130.8985  170.232187
#> SBS5  4320.0186 5663.703313 18611.358 1355.8435 24967.9758 1906.299465
#> SBS9  2615.9872 1186.572686  2250.317 2964.4311  3200.6463  513.459715
#> SBS2   586.5852   63.627029  1576.411  322.9761   194.9891    0.000000
#> SBS13 2876.2383  807.446263     0.000  584.7621  2397.4903    7.008633
#>       Sample_21  Sample_22   Sample_23  Sample_24 Sample_25  Sample_26
#> SBS1   360.1966  4063.8892  301.202136   395.6656 1236.0071 1425.94080
#> SBS5  8066.6174 30202.4192 2611.606854 27744.4555 3755.3214 3251.66786
#> SBS9  1734.3629  3602.2796 1424.399907  4734.8930 3944.5535  681.38344
#> SBS2   370.9525     0.0000    7.180995  1730.8578  950.3892   78.28026
#> SBS13 2799.8706   488.4119   67.610108 11290.1281  275.7287  507.72764
#>        Sample_27  Sample_28  Sample_29 Sample_30
#> SBS1    14.46626   39.49534  310.50110  230.3621
#> SBS5  6222.00235 2402.07223 1791.75036 2052.8025
#> SBS9   908.90204  480.48944 1525.63702  635.8353
#> SBS2   398.21552    0.00000   20.11152    0.0000
#> SBS13 2546.41383   50.94299    0.00000    0.0000
# opt 2. use user specified signatures
ref = get_sig_db()$db
ref[1:5, 1:5]
#>            COSMIC_1    COSMIC_2   COSMIC_3 COSMIC_4    COSMIC_5
#> A[C>A]A 0.011098326 0.000682708 0.02217231   0.0365 0.014941548
#> A[C>A]C 0.009149341 0.000619107 0.01787168   0.0309 0.008960918
#> A[C>A]G 0.001490070 0.000099279 0.00213834   0.0183 0.002207846
#> A[C>A]T 0.006233885 0.000323891 0.01626515   0.0243 0.009206905
#> A[C>G]A 0.001801068 0.000263481 0.02400262   0.0097 0.011671022
ref = ref[, 1:10]
# The `sig` used here can be result object from `sig_extract`
# or any reference matrix with similar structure (96-motif)
v1 = sig_fit(data, sig = ref)
#>  [2024-08-04 14:44:53.046826]: Started.
#>  [2024-08-04 14:44:53.048593]: Signature index not detected.
#>  [2024-08-04 14:44:53.050102]: Signature matrix/data.frame detected.
#>  [2024-08-04 14:44:53.051504]: Database and index checked.
#>  [2024-08-04 14:44:53.053025]: Signature normalized.
#>  [2024-08-04 14:44:53.054404]: Checking row number for catalog matrix and signature matrix.
#>  [2024-08-04 14:44:53.055758]: Checked.
#>  [2024-08-04 14:44:53.05711]: Checking rownames for catalog matrix and signature matrix.
#>  [2024-08-04 14:44:53.058516]: Matrix V and W don't have same orders. Try reordering...
#>  [2024-08-04 14:44:53.059984]: Checked.
#>  [2024-08-04 14:44:53.061364]: Method 'QP' detected.
#>  [2024-08-04 14:44:53.062811]: Corresponding function generated.
#>  [2024-08-04 14:44:53.064145]: Calling function.
#>  [2024-08-04 14:44:53.065906]: Fitting sample: Sample_1
#>  [2024-08-04 14:44:53.067444]: Fitting sample: Sample_2
#>  [2024-08-04 14:44:53.068951]: Fitting sample: Sample_3
#>  [2024-08-04 14:44:53.070498]: Fitting sample: Sample_4
#>  [2024-08-04 14:44:53.071999]: Fitting sample: Sample_5
#>  [2024-08-04 14:44:53.073534]: Fitting sample: Sample_6
#>  [2024-08-04 14:44:53.075011]: Fitting sample: Sample_7
#>  [2024-08-04 14:44:53.07654]: Fitting sample: Sample_8
#>  [2024-08-04 14:44:53.078043]: Fitting sample: Sample_9
#>  [2024-08-04 14:44:53.079506]: Fitting sample: Sample_10
#>  [2024-08-04 14:44:53.080959]: Fitting sample: Sample_11
#>  [2024-08-04 14:44:53.082431]: Fitting sample: Sample_12
#>  [2024-08-04 14:44:53.083911]: Fitting sample: Sample_13
#>  [2024-08-04 14:44:53.085437]: Fitting sample: Sample_14
#>  [2024-08-04 14:44:53.086899]: Fitting sample: Sample_15
#>  [2024-08-04 14:44:53.088344]: Fitting sample: Sample_16
#>  [2024-08-04 14:44:53.089827]: Fitting sample: Sample_17
#>  [2024-08-04 14:44:53.091295]: Fitting sample: Sample_18
#>  [2024-08-04 14:44:53.092766]: Fitting sample: Sample_19
#>  [2024-08-04 14:44:53.094285]: Fitting sample: Sample_20
#>  [2024-08-04 14:44:53.095757]: Fitting sample: Sample_21
#>  [2024-08-04 14:44:53.09727]: Fitting sample: Sample_22
#>  [2024-08-04 14:44:53.098742]: Fitting sample: Sample_23
#>  [2024-08-04 14:44:53.100275]: Fitting sample: Sample_24
#>  [2024-08-04 14:44:53.101813]: Fitting sample: Sample_25
#>  [2024-08-04 14:44:53.103574]: Fitting sample: Sample_26
#>  [2024-08-04 14:44:53.105102]: Fitting sample: Sample_27
#>  [2024-08-04 14:44:53.10664]: Fitting sample: Sample_28
#>  [2024-08-04 14:44:53.108167]: Fitting sample: Sample_29
#>  [2024-08-04 14:44:53.109751]: Fitting sample: Sample_30
#>  [2024-08-04 14:44:53.111289]: Done.
#>  [2024-08-04 14:44:53.112765]: Generating output signature exposures.
#>  [2024-08-04 14:44:53.115199]: Done.
#>  [2024-08-04 14:44:53.116843]: 0.07 secs elapsed.
v1
#>            Sample_1   Sample_2  Sample_3   Sample_4  Sample_5  Sample_6
#> COSMIC_1      0.000   489.8588  209.7209    0.00000    0.0000   0.00000
#> COSMIC_2      0.000  4772.1359  790.7404 1141.34400 1260.9176 451.61921
#> COSMIC_3   9388.300 11304.1621 6409.2694 9437.97961 1368.1160 147.53218
#> COSMIC_4      0.000     0.0000    0.0000    0.00000    0.0000 240.12278
#> COSMIC_5  22269.534     0.0000    0.0000    0.00000    0.0000   0.00000
#> COSMIC_6      0.000  2257.8431 3298.0989    0.00000    0.0000 336.85671
#> COSMIC_7      0.000     0.0000    0.0000    0.00000    0.0000   0.00000
#> COSMIC_8   9477.314     0.0000    0.0000    0.00000    0.0000 379.85216
#> COSMIC_9   1624.851     0.0000    0.0000    0.00000    0.0000  10.06643
#> COSMIC_10     0.000     0.0000   62.1704    6.67638   65.9664  46.95054
#>            Sample_7   Sample_8   Sample_9  Sample_10 Sample_11  Sample_12
#> COSMIC_1   28.74367 1215.66688    0.00000    0.00000  992.0793     0.0000
#> COSMIC_2  127.57118  248.22883  345.66245 1341.62106  866.9798  1382.2258
#> COSMIC_3  949.82786   59.47163 2109.15735 1104.17431 2267.4729 22983.0181
#> COSMIC_4  146.21151  450.56797    0.00000  868.66564    0.0000  7513.7174
#> COSMIC_5    0.00000   15.81582    0.00000 3114.99239  454.5275 15707.0752
#> COSMIC_6  205.95216    0.00000    0.00000    0.00000  674.9405     0.0000
#> COSMIC_7    0.00000    0.00000   65.11657    0.00000    0.0000     0.0000
#> COSMIC_8    0.00000  271.96232    0.00000 3037.45580    0.0000     0.0000
#> COSMIC_9   48.50970   40.22707 5604.06363   76.50516    0.0000   911.1828
#> COSMIC_10  90.18391   90.05947    0.00000  169.58564    0.0000  1470.7807
#>             Sample_13 Sample_14  Sample_15 Sample_16 Sample_17 Sample_18
#> COSMIC_1    27.553530    0.0000  607.73052    0.0000  7142.931  450.8810
#> COSMIC_2   220.197356 1383.6365 1089.11552  249.5889  2234.646  428.5266
#> COSMIC_3  1803.765880 1913.0862 7718.95869 2417.0770     0.000 1803.5497
#> COSMIC_4     2.444918    0.0000    0.00000 2525.5503     0.000    0.0000
#> COSMIC_5     0.000000  793.4116    0.00000 1120.9350 11397.113    0.0000
#> COSMIC_6     0.000000  120.8657    0.00000    0.0000  4817.624    0.0000
#> COSMIC_7     0.000000    0.0000    0.00000    0.0000     0.000    0.0000
#> COSMIC_8     0.000000    0.0000    0.00000  593.4937     0.000  175.8705
#> COSMIC_9     0.000000    0.0000 1273.97434  321.6396  2080.685 2713.1722
#> COSMIC_10   63.038316    0.0000   98.22093  497.7156     0.000    0.0000
#>            Sample_19   Sample_20  Sample_21    Sample_22  Sample_23  Sample_24
#> COSMIC_1   3442.8664  252.686817   521.6661  6532.753069   27.78616   585.9699
#> COSMIC_2    909.0835    6.731634   794.8881     0.000000   37.07453  3737.3080
#> COSMIC_3   3388.9789    0.000000 11487.9198  9577.877624    0.00000 40624.6240
#> COSMIC_4   5785.5234  643.570806     0.0000     0.000000 1646.68130     0.0000
#> COSMIC_5  17067.4485 1174.973238     0.0000 19202.665730    0.00000     0.0000
#> COSMIC_6      0.0000    0.000000     0.0000  2318.605839  532.00164     0.0000
#> COSMIC_7      0.0000    0.000000     0.0000     0.391064    0.00000     0.0000
#> COSMIC_8    647.0108   61.792741   426.2269   604.885135  733.46374     0.0000
#> COSMIC_9    391.0308  322.926794     0.0000   112.692931 1097.40415     0.0000
#> COSMIC_10  1260.0576  134.317970   101.2992     7.128609  337.58848   948.0980
#>           Sample_25  Sample_26 Sample_27   Sample_28   Sample_29 Sample_30
#> COSMIC_1  1415.0938 1196.88834  127.7639    0.000000  522.352549    0.0000
#> COSMIC_2  1152.5880  199.49602  896.7186    9.999714   32.439082    0.0000
#> COSMIC_3     0.0000 1575.30113 8949.9313    0.000000  185.293182    0.0000
#> COSMIC_4  2893.4527    0.00000    0.0000 1009.607682    0.000000    0.0000
#> COSMIC_5     0.0000    0.00000    0.0000 1226.700289 1030.830037 1449.4794
#> COSMIC_6   827.5402 2436.90356    0.0000    0.000000    9.451177  559.2979
#> COSMIC_7     0.0000    0.00000    0.0000    0.000000    0.000000    0.0000
#> COSMIC_8     0.0000    0.00000    0.0000  433.980720  245.162304  369.9575
#> COSMIC_9  3201.4470  523.89832    0.0000   91.131812 1622.471669  540.2652
#> COSMIC_10  671.8784   12.51264  115.5862  201.579783    0.000000    0.0000

# If possible, auto-reduce the reference signatures
# for better fitting data from a sample
v2 = sig_fit(data, sig = ref, auto_reduce = TRUE)
#>  [2024-08-04 14:44:53.120702]: Started.
#>  [2024-08-04 14:44:53.122493]: Signature index not detected.
#>  [2024-08-04 14:44:53.124123]: Signature matrix/data.frame detected.
#>  [2024-08-04 14:44:53.125714]: Database and index checked.
#>  [2024-08-04 14:44:53.127366]: Signature normalized.
#>  [2024-08-04 14:44:53.128816]: Checking row number for catalog matrix and signature matrix.
#>  [2024-08-04 14:44:53.130289]: Checked.
#>  [2024-08-04 14:44:53.131691]: Checking rownames for catalog matrix and signature matrix.
#>  [2024-08-04 14:44:53.133116]: Matrix V and W don't have same orders. Try reordering...
#>  [2024-08-04 14:44:53.13469]: Checked.
#>  [2024-08-04 14:44:53.136127]: Method 'QP' detected.
#>  [2024-08-04 14:44:53.137574]: Corresponding function generated.
#>  [2024-08-04 14:44:53.138984]: Calling function.
#>  [2024-08-04 14:44:53.140747]: Fitting sample: Sample_1
#>  [2024-08-04 14:44:53.142389]: The cosine similarity is very high, just return result.
#>  [2024-08-04 14:44:53.143843]: Fitting sample: Sample_2
#>  [2024-08-04 14:44:53.145437]: Start optimizing...
#>  [2024-08-04 14:44:53.146953]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.148377]: Fitting sample: Sample_2
#>  [2024-08-04 14:44:53.150042]: Stop optimizing at exposure level: 0.001, 6 signatures dropped.
#>  [2024-08-04 14:44:53.151488]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.152912]: Fitting sample: Sample_3
#>  [2024-08-04 14:44:53.154498]: Start optimizing...
#>  [2024-08-04 14:44:53.155961]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.157408]: Fitting sample: Sample_3
#>  [2024-08-04 14:44:53.158954]: Stop optimizing at exposure level: 0.001, 5 signatures dropped.
#>  [2024-08-04 14:44:53.160388]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.161865]: Fitting sample: Sample_4
#>  [2024-08-04 14:44:53.163415]: Start optimizing...
#>  [2024-08-04 14:44:53.164878]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.166359]: Fitting sample: Sample_4
#>  [2024-08-04 14:44:53.167873]: Stop optimizing at exposure level: 0.001, 8 signatures dropped.
#>  [2024-08-04 14:44:53.169313]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.170739]: Fitting sample: Sample_5
#>  [2024-08-04 14:44:53.172262]: Start optimizing...
#>  [2024-08-04 14:44:53.173745]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.175178]: Fitting sample: Sample_5
#>  [2024-08-04 14:44:53.176693]: Stop optimizing at exposure level: 0.001, 7 signatures dropped.
#>  [2024-08-04 14:44:53.178165]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.179597]: Fitting sample: Sample_6
#>  [2024-08-04 14:44:53.18111]: The cosine similarity is very high, just return result.
#>  [2024-08-04 14:44:53.182583]: Fitting sample: Sample_7
#>  [2024-08-04 14:44:53.184183]: Start optimizing...
#>  [2024-08-04 14:44:53.185669]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.187086]: Fitting sample: Sample_7
#>  [2024-08-04 14:44:53.188588]: Stop optimizing at exposure level: 0.001, 3 signatures dropped.
#>  [2024-08-04 14:44:53.190025]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.191432]: Fitting sample: Sample_8
#>  [2024-08-04 14:44:53.192927]: The cosine similarity is very high, just return result.
#>  [2024-08-04 14:44:53.194384]: Fitting sample: Sample_9
#>  [2024-08-04 14:44:53.195895]: Start optimizing...
#>  [2024-08-04 14:44:53.197356]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.198764]: Fitting sample: Sample_9
#>  [2024-08-04 14:44:53.200272]: Stop optimizing at exposure level: 0.001, 6 signatures dropped.
#>  [2024-08-04 14:44:53.201711]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.203138]: Fitting sample: Sample_10
#>  [2024-08-04 14:44:53.204766]: The cosine similarity is very high, just return result.
#>  [2024-08-04 14:44:53.206229]: Fitting sample: Sample_11
#>  [2024-08-04 14:44:53.207723]: Start optimizing...
#>  [2024-08-04 14:44:53.2092]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.210652]: Fitting sample: Sample_11
#>  [2024-08-04 14:44:53.21227]: Stop optimizing at exposure level: 0.001, 5 signatures dropped.
#>  [2024-08-04 14:44:53.21371]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.215138]: Fitting sample: Sample_12
#>  [2024-08-04 14:44:53.216645]: Start optimizing...
#>  [2024-08-04 14:44:53.218119]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.219514]: Fitting sample: Sample_12
#>  [2024-08-04 14:44:53.221049]: Stop optimizing at exposure level: 0.001, 4 signatures dropped.
#>  [2024-08-04 14:44:53.222513]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.223946]: Fitting sample: Sample_13
#>  [2024-08-04 14:44:53.225532]: Start optimizing...
#>  [2024-08-04 14:44:53.226982]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.2284]: Fitting sample: Sample_13
#>  [2024-08-04 14:44:53.229973]: Stop optimizing at exposure level: 0.001, 5 signatures dropped.
#>  [2024-08-04 14:44:53.231441]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.232901]: Fitting sample: Sample_14
#>  [2024-08-04 14:44:53.234504]: Start optimizing...
#>  [2024-08-04 14:44:53.235968]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.237413]: Fitting sample: Sample_14
#>  [2024-08-04 14:44:53.238938]: Stop optimizing at exposure level: 0.001, 6 signatures dropped.
#>  [2024-08-04 14:44:53.240421]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.24226]: Fitting sample: Sample_15
#>  [2024-08-04 14:44:53.244189]: Start optimizing...
#>  [2024-08-04 14:44:53.246016]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.247503]: Fitting sample: Sample_15
#>  [2024-08-04 14:44:53.249068]: Stop optimizing at exposure level: 0.001, 5 signatures dropped.
#>  [2024-08-04 14:44:53.250533]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.251994]: Fitting sample: Sample_16
#>  [2024-08-04 14:44:53.253558]: Start optimizing...
#>  [2024-08-04 14:44:53.255]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.269706]: Fitting sample: Sample_16
#>  [2024-08-04 14:44:53.271405]: Stop optimizing at exposure level: 0.001, 3 signatures dropped.
#>  [2024-08-04 14:44:53.272815]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.274244]: Fitting sample: Sample_17
#>  [2024-08-04 14:44:53.275723]: The cosine similarity is very high, just return result.
#>  [2024-08-04 14:44:53.277086]: Fitting sample: Sample_18
#>  [2024-08-04 14:44:53.278585]: Start optimizing...
#>  [2024-08-04 14:44:53.27998]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.281373]: Fitting sample: Sample_18
#>  [2024-08-04 14:44:53.282816]: Stop optimizing at exposure level: 0.001, 5 signatures dropped.
#>  [2024-08-04 14:44:53.284176]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.285608]: Fitting sample: Sample_19
#>  [2024-08-04 14:44:53.28707]: Start optimizing...
#>  [2024-08-04 14:44:53.288445]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.289822]: Fitting sample: Sample_19
#>  [2024-08-04 14:44:53.291264]: Stop optimizing at exposure level: 0.001, 2 signatures dropped.
#>  [2024-08-04 14:44:53.29262]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.294016]: Fitting sample: Sample_20
#>  [2024-08-04 14:44:53.295506]: Start optimizing...
#>  [2024-08-04 14:44:53.296881]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.298263]: Fitting sample: Sample_20
#>  [2024-08-04 14:44:53.299694]: Stop optimizing at exposure level: 0.001, 3 signatures dropped.
#>  [2024-08-04 14:44:53.301047]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.302451]: Fitting sample: Sample_21
#>  [2024-08-04 14:44:53.303922]: Start optimizing...
#>  [2024-08-04 14:44:53.305347]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.306699]: Fitting sample: Sample_21
#>  [2024-08-04 14:44:53.308142]: Stop optimizing at exposure level: 0.001, 5 signatures dropped.
#>  [2024-08-04 14:44:53.309547]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.310941]: Fitting sample: Sample_22
#>  [2024-08-04 14:44:53.312412]: The cosine similarity is very high, just return result.
#>  [2024-08-04 14:44:53.313878]: Fitting sample: Sample_23
#>  [2024-08-04 14:44:53.315367]: Start optimizing...
#>  [2024-08-04 14:44:53.316778]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.318177]: Fitting sample: Sample_23
#>  [2024-08-04 14:44:53.319669]: Stop optimizing at exposure level: 0.001, 3 signatures dropped.
#>  [2024-08-04 14:44:53.321039]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.322554]: Fitting sample: Sample_24
#>  [2024-08-04 14:44:53.324054]: Start optimizing...
#>  [2024-08-04 14:44:53.325501]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.326874]: Fitting sample: Sample_24
#>  [2024-08-04 14:44:53.328346]: Stop optimizing at exposure level: 0.001, 6 signatures dropped.
#>  [2024-08-04 14:44:53.329754]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.331151]: Fitting sample: Sample_25
#>  [2024-08-04 14:44:53.332627]: Start optimizing...
#>  [2024-08-04 14:44:53.334075]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.335469]: Fitting sample: Sample_25
#>  [2024-08-04 14:44:53.336971]: Stop optimizing at exposure level: 0.001, 4 signatures dropped.
#>  [2024-08-04 14:44:53.338402]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.339784]: Fitting sample: Sample_26
#>  [2024-08-04 14:44:53.341301]: The cosine similarity is very high, just return result.
#>  [2024-08-04 14:44:53.342684]: Fitting sample: Sample_27
#>  [2024-08-04 14:44:53.344161]: Start optimizing...
#>  [2024-08-04 14:44:53.345632]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.346998]: Fitting sample: Sample_27
#>  [2024-08-04 14:44:53.348461]: Stop optimizing at exposure level: 0.001, 6 signatures dropped.
#>  [2024-08-04 14:44:53.349887]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.351282]: Fitting sample: Sample_28
#>  [2024-08-04 14:44:53.352774]: Start optimizing...
#>  [2024-08-04 14:44:53.35428]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.355667]: Fitting sample: Sample_28
#>  [2024-08-04 14:44:53.357174]: Stop optimizing at exposure level: 0.001, 4 signatures dropped.
#>  [2024-08-04 14:44:53.358587]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.359979]: Fitting sample: Sample_29
#>  [2024-08-04 14:44:53.361498]: Start optimizing...
#>  [2024-08-04 14:44:53.362919]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.364282]: Fitting sample: Sample_29
#>  [2024-08-04 14:44:53.365834]: Stop optimizing at exposure level: 0.001, 3 signatures dropped.
#>  [2024-08-04 14:44:53.367232]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.36862]: Fitting sample: Sample_30
#>  [2024-08-04 14:44:53.370151]: Start optimizing...
#>  [2024-08-04 14:44:53.371586]: Dropping reference signatures with relative exposure <0.001
#>  [2024-08-04 14:44:53.372959]: Fitting sample: Sample_30
#>  [2024-08-04 14:44:53.374475]: Stop optimizing at exposure level: 0.001, 6 signatures dropped.
#>  [2024-08-04 14:44:53.375848]: Cosine similarity with 0 improved.
#>  [2024-08-04 14:44:53.377263]: Done.
#>  [2024-08-04 14:44:53.378633]: Generating output signature exposures.
#>  [2024-08-04 14:44:53.380875]: Done.
#>  [2024-08-04 14:44:53.38249]: 0.262 secs elapsed.
v2
#>            Sample_1   Sample_2  Sample_3 Sample_4  Sample_5  Sample_6  Sample_7
#> COSMIC_1      0.000   489.8588  209.7209    0.000    0.0000   0.00000  28.74367
#> COSMIC_2      0.000  4772.1359  790.7404 1141.894 1260.9176 451.61921 127.57118
#> COSMIC_3   9388.300 11304.1621 6409.2694 9444.106 1368.1160 147.53218 949.82786
#> COSMIC_4      0.000     0.0000    0.0000    0.000    0.0000 240.12278 146.21151
#> COSMIC_5  22269.534     0.0000    0.0000    0.000    0.0000   0.00000   0.00000
#> COSMIC_6      0.000  2257.8431 3298.0989    0.000    0.0000 336.85671 205.95216
#> COSMIC_7      0.000     0.0000    0.0000    0.000    0.0000   0.00000   0.00000
#> COSMIC_8   9477.314     0.0000    0.0000    0.000    0.0000 379.85216   0.00000
#> COSMIC_9   1624.851     0.0000    0.0000    0.000    0.0000  10.06643  48.50970
#> COSMIC_10     0.000     0.0000   62.1704    0.000   65.9664  46.95054  90.18391
#>             Sample_8   Sample_9  Sample_10 Sample_11  Sample_12   Sample_13
#> COSMIC_1  1215.66688    0.00000    0.00000  992.0793     0.0000   27.553530
#> COSMIC_2   248.22883  345.66245 1341.62106  866.9798  1382.2258  220.197356
#> COSMIC_3    59.47163 2109.15735 1104.17431 2267.4729 22983.0181 1803.765880
#> COSMIC_4   450.56797    0.00000  868.66564    0.0000  7513.7174    2.444918
#> COSMIC_5    15.81582    0.00000 3114.99239  454.5275 15707.0752    0.000000
#> COSMIC_6     0.00000    0.00000    0.00000  674.9405     0.0000    0.000000
#> COSMIC_7     0.00000   65.11657    0.00000    0.0000     0.0000    0.000000
#> COSMIC_8   271.96232    0.00000 3037.45580    0.0000     0.0000    0.000000
#> COSMIC_9    40.22707 5604.06363   76.50516    0.0000   911.1828    0.000000
#> COSMIC_10   90.05947    0.00000  169.58564    0.0000  1470.7807   63.038316
#>           Sample_14  Sample_15 Sample_16 Sample_17 Sample_18  Sample_19
#> COSMIC_1     0.0000  607.73052    0.0000  7142.931  450.8810  3442.8664
#> COSMIC_2  1383.6365 1089.11552  249.5889  2234.646  428.5266   909.0835
#> COSMIC_3  1913.0862 7718.95869 2417.0770     0.000 1803.5497  3388.9789
#> COSMIC_4     0.0000    0.00000 2525.5503     0.000    0.0000  5785.5234
#> COSMIC_5   793.4116    0.00000 1120.9350 11397.113    0.0000 17067.4485
#> COSMIC_6   120.8657    0.00000    0.0000  4817.624    0.0000     0.0000
#> COSMIC_7     0.0000    0.00000    0.0000     0.000    0.0000     0.0000
#> COSMIC_8     0.0000    0.00000  593.4937     0.000  175.8705   647.0108
#> COSMIC_9     0.0000 1273.97434  321.6396  2080.685 2713.1722   391.0308
#> COSMIC_10    0.0000   98.22093  497.7156     0.000    0.0000  1260.0576
#>             Sample_20  Sample_21    Sample_22  Sample_23  Sample_24 Sample_25
#> COSMIC_1   252.686817   521.6661  6532.753069   27.78616   585.9699 1415.0938
#> COSMIC_2     6.731634   794.8881     0.000000   37.07453  3737.3080 1152.5880
#> COSMIC_3     0.000000 11487.9198  9577.877624    0.00000 40624.6240    0.0000
#> COSMIC_4   643.570806     0.0000     0.000000 1646.68130     0.0000 2893.4527
#> COSMIC_5  1174.973238     0.0000 19202.665730    0.00000     0.0000    0.0000
#> COSMIC_6     0.000000     0.0000  2318.605839  532.00164     0.0000  827.5402
#> COSMIC_7     0.000000     0.0000     0.391064    0.00000     0.0000    0.0000
#> COSMIC_8    61.792741   426.2269   604.885135  733.46374     0.0000    0.0000
#> COSMIC_9   322.926794     0.0000   112.692931 1097.40415     0.0000 3201.4470
#> COSMIC_10  134.317970   101.2992     7.128609  337.58848   948.0980  671.8784
#>            Sample_26 Sample_27   Sample_28   Sample_29 Sample_30
#> COSMIC_1  1196.88834  127.7639    0.000000  522.352549    0.0000
#> COSMIC_2   199.49602  896.7186    9.999714   32.439082    0.0000
#> COSMIC_3  1575.30113 8949.9313    0.000000  185.293182    0.0000
#> COSMIC_4     0.00000    0.0000 1009.607682    0.000000    0.0000
#> COSMIC_5     0.00000    0.0000 1226.700289 1030.830037 1449.4794
#> COSMIC_6  2436.90356    0.0000    0.000000    9.451177  559.2979
#> COSMIC_7     0.00000    0.0000    0.000000    0.000000    0.0000
#> COSMIC_8     0.00000    0.0000  433.980720  245.162304  369.9575
#> COSMIC_9   523.89832    0.0000   91.131812 1622.471669  540.2652
#> COSMIC_10   12.51264  115.5862  201.579783    0.000000    0.0000

all.equal(v1, v2)
#> [1] "Mean relative difference: 0.001157504"

# Some samples reported signatures dropped
# but its original activity values are 0s,
# so the data remain same (0 -> 0)
all.equal(v1[, 2], v2[, 2])
#> [1] TRUE

# For COSMIC_10, 6.67638 -> 0
v1[, 4]; v2[, 4]
#>   COSMIC_1   COSMIC_2   COSMIC_3   COSMIC_4   COSMIC_5   COSMIC_6   COSMIC_7 
#>    0.00000 1141.34400 9437.97961    0.00000    0.00000    0.00000    0.00000 
#>   COSMIC_8   COSMIC_9  COSMIC_10 
#>    0.00000    0.00000    6.67638 
#>  COSMIC_1  COSMIC_2  COSMIC_3  COSMIC_4  COSMIC_5  COSMIC_6  COSMIC_7  COSMIC_8 
#>     0.000  1141.894  9444.106     0.000     0.000     0.000     0.000     0.000 
#>  COSMIC_9 COSMIC_10 
#>     0.000     0.000 
all.equal(v1[, 4], v2[, 4])
#> [1] "Mean relative difference: 0.00126136"

# For general purpose -----------------------

W <- matrix(c(1, 2, 3, 4, 5, 6), ncol = 2)
colnames(W) <- c("sig1", "sig2")
W <- apply(W, 2, function(x) x / sum(x))

H <- matrix(c(2, 5, 3, 6, 1, 9, 1, 2), ncol = 4)
colnames(H) <- paste0("samp", 1:4)

V <- W %*% H
V
#>         samp1 samp2    samp3 samp4
#> [1,] 1.666667   2.1 2.566667   0.7
#> [2,] 2.333333   3.0 3.333333   1.0
#> [3,] 3.000000   3.9 4.100000   1.3

if (requireNamespace("quadprog", quietly = TRUE)) {
  H_infer <- sig_fit(V, W, method = "QP")
  H_infer
  H

  H_dt <- sig_fit(V, W, method = "QP", auto_reduce = TRUE, return_class = "data.table")
  H_dt

  ## Show results
  show_sig_fit(H_infer)
  show_sig_fit(H_dt)

  ## Get clusters/groups
  H_dt_rel <- sig_fit(V, W, return_class = "data.table", type = "relative")
  z <- get_groups(H_dt_rel, method = "k-means")
  show_groups(z)
}
#>  [2024-08-04 14:44:53.394578]: Started.
#>  [2024-08-04 14:44:53.396351]: Signature index not detected.
#>  [2024-08-04 14:44:53.397891]: Signature matrix/data.frame detected.
#>  [2024-08-04 14:44:53.399314]: Database and index checked.
#>  [2024-08-04 14:44:53.400762]: Signature normalized.
#>  [2024-08-04 14:44:53.40214]: Checking row number for catalog matrix and signature matrix.
#>  [2024-08-04 14:44:53.403488]: Checked.
#>  [2024-08-04 14:44:53.4051]: Method 'QP' detected.
#>  [2024-08-04 14:44:53.406483]: Corresponding function generated.
#>  [2024-08-04 14:44:53.407822]: Calling function.
#>  [2024-08-04 14:44:53.40954]: Fitting sample: samp1
#>  [2024-08-04 14:44:53.411074]: Fitting sample: samp2
#>  [2024-08-04 14:44:53.412497]: Fitting sample: samp3
#>  [2024-08-04 14:44:53.413974]: Fitting sample: samp4
#>  [2024-08-04 14:44:53.415424]: Done.
#>  [2024-08-04 14:44:53.416785]: Generating output signature exposures.
#>  [2024-08-04 14:44:53.418723]: Done.
#>  [2024-08-04 14:44:53.420151]: 0.026 secs elapsed.
#>  [2024-08-04 14:44:53.421618]: Started.
#>  [2024-08-04 14:44:53.42296]: Signature index not detected.
#>  [2024-08-04 14:44:53.424321]: Signature matrix/data.frame detected.
#>  [2024-08-04 14:44:53.425695]: Database and index checked.
#>  [2024-08-04 14:44:53.427125]: Signature normalized.
#>  [2024-08-04 14:44:53.428476]: Checking row number for catalog matrix and signature matrix.
#>  [2024-08-04 14:44:53.42989]: Checked.
#>  [2024-08-04 14:44:53.431218]: Method 'QP' detected.
#>  [2024-08-04 14:44:53.432547]: Corresponding function generated.
#>  [2024-08-04 14:44:53.433916]: Calling function.
#>  [2024-08-04 14:44:53.435509]: Fitting sample: samp1
#>  [2024-08-04 14:44:53.437042]: The cosine similarity is very high, just return result.
#>  [2024-08-04 14:44:53.438488]: Fitting sample: samp2
#>  [2024-08-04 14:44:53.439959]: The cosine similarity is very high, just return result.
#>  [2024-08-04 14:44:53.441366]: Fitting sample: samp3
#>  [2024-08-04 14:44:53.442826]: The cosine similarity is very high, just return result.
#>  [2024-08-04 14:44:53.444197]: Fitting sample: samp4
#>  [2024-08-04 14:44:53.445733]: The cosine similarity is very high, just return result.
#>  [2024-08-04 14:44:53.447104]: Done.
#>  [2024-08-04 14:44:53.448448]: Generating output signature exposures.
#>  [2024-08-04 14:44:53.458266]: Done.
#>  [2024-08-04 14:44:53.460099]: 0.038 secs elapsed.
#>  [2024-08-04 14:44:53.461886]: Started.
#>  [2024-08-04 14:44:53.463283]: Checking input format.
#>  [2024-08-04 14:44:53.472363]: Checked.
#>  [2024-08-04 14:44:53.474108]: Checking filters.
#>  [2024-08-04 14:44:53.475566]: Checked.
#>  [2024-08-04 14:44:53.480137]: Plotting.
#>  [2024-08-04 14:44:53.514821]: 0.053 secs elapsed.
#>  [2024-08-04 14:44:53.516798]: Started.
#>  [2024-08-04 14:44:53.518325]: Checking input format.
#>  [2024-08-04 14:44:53.519788]: Checked.
#>  [2024-08-04 14:44:53.521174]: Checking filters.
#>  [2024-08-04 14:44:53.522582]: Checked.
#>  [2024-08-04 14:44:53.527352]: Plotting.
#>  [2024-08-04 14:44:53.560861]: 0.044 secs elapsed.
#>  [2024-08-04 14:44:53.562776]: Started.
#>  [2024-08-04 14:44:53.564254]: Signature index not detected.
#>  [2024-08-04 14:44:53.565683]: Signature matrix/data.frame detected.
#>  [2024-08-04 14:44:53.567054]: Database and index checked.
#>  [2024-08-04 14:44:53.568487]: Signature normalized.
#>  [2024-08-04 14:44:53.569924]: Checking row number for catalog matrix and signature matrix.
#>  [2024-08-04 14:44:53.571286]: Checked.
#>  [2024-08-04 14:44:53.572623]: Method 'QP' detected.
#>  [2024-08-04 14:44:53.574]: Corresponding function generated.
#>  [2024-08-04 14:44:53.575338]: Calling function.
#>  [2024-08-04 14:44:53.576908]: Fitting sample: samp1
#>  [2024-08-04 14:44:53.578411]: Fitting sample: samp2
#>  [2024-08-04 14:44:53.57983]: Fitting sample: samp3
#>  [2024-08-04 14:44:53.581251]: Fitting sample: samp4
#>  [2024-08-04 14:44:53.582856]: Done.
#>  [2024-08-04 14:44:53.584222]: Generating output signature exposures.
#>  [2024-08-04 14:44:53.59396]: Done.
#>  [2024-08-04 14:44:53.595741]: 0.033 secs elapsed.
#>  [2024-08-04 14:44:53.597293]: Started.
#>  [2024-08-04 14:44:53.598678]: A 'data.table' detected.
#>  [2024-08-04 14:44:53.600028]: Method checked.
#>  [2024-08-04 14:44:53.601605]: Exposure should be relative checked.
#>  [2024-08-04 14:44:53.603197]: Running k-means with 2 clusters...
#>  [2024-08-04 14:44:53.605265]: Generating a table of group and signature contribution (stored in 'map_table' attr):
#>      sig1    sig2
#> 1 0.31746 0.68254
#> 2 0.10000 0.90000
#>  [2024-08-04 14:44:53.606779]: Assigning a group to a signature with the maximum fraction...
#>  [2024-08-04 14:44:53.610518]: Summarizing...
#> 	group #1: 3 samples with sig2 enriched.
#> 	group #2: 1 samples with sig2 enriched.
#> ! [2024-08-04 14:44:53.612502]: The 'enrich_sig' column is set to dominant signature in one group, please check and make it consistent with biological meaning (correct it by hand if necessary).
#>  [2024-08-04 14:44:53.613947]: 0.017 secs elapsed.


# if (requireNamespace("GenSA", quietly = TRUE)) {
#   H_infer <- sig_fit(V, W, method = "SA")
#   H_infer
#   H
#
#   H_dt <- sig_fit(V, W, method = "SA", return_class = "data.table")
#   H_dt
#
#   ## Modify arguments to method
#   sig_fit(V, W, method = "SA", maxit = 10, temperature = 100)
#
#   ## Show results
#   show_sig_fit(H_infer)
#   show_sig_fit(H_dt)
# }
# }