Learn R Programming

mutSignatures (version 2.1.1)

leadZeros: Add Leading Zeros to Numbers.

Description

Internal function to convert a numeric vector into a character vector, where all elements have the same number of characters (nchar). This is obtained by pasting a series of leading zeros (or other character) to each number in the input vector.

Usage

leadZeros(n, m, char = "0", na.value = NA)

Arguments

n

numeric vector whose numbers are to be transformed

m

maximum number that will be used to define how many leading zeros to attach

char

string (typically, a single character). This character is used to fill the leading space. Defaults to 0.

na.value

value used to fill mising values. Defaults to NA

Value

numeric vector of length equal to length(n), where all numbers are converted to character and modified by attaching the required number of leading zeros (characters).

Details

This is one of the core functions included in the original mutSignatures R library, and in the WTSI MATLAB framework. This is an internal function.

References

More information and examples about mutational signature analysis can be found here:

  1. GitHub Repo: https://github.com/dami82/mutSignatures/

  2. More info and examples about the mutSignatures R library: https://www.data-pulse.com/dev_site/mutsignatures/

  3. Sci Rep paper, introducing mutS: https://www.nature.com/articles/s41598-020-75062-0/

  4. Oncogene paper, Mutational Signatures Operative in Bladder Cancer: https://www.nature.com/articles/s41388-017-0099-6

  5. WTSI framework: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3588146/

Examples

Run this code
# NOT RUN {
n = c(5:12, NA, 9:11)
m = 111
mutSignatures:::leadZeros(n=n, m=m)    

# }

Run the code above in your browser using DataLab