make_PWMs: Make a PWM-resembling matrix out of a given n-vector

View source: R/make_sinuc_PWMs.R

make_PWMsR Documentation

Make a PWM-resembling matrix out of a given n-vector

Description

The given matrix (or simply a vector) is reshaped to have four rows for four nucleotides and a relevant number of columns.

Usage

make_PWMs(vec, add_pseudo_counts = TRUE, scale = TRUE, sinuc = TRUE)

Arguments

vec

A vector that will be reshaped into a PWM matrix of DNA sequences. Note that the matrix is formed by row.

add_pseudo_counts

Logical, taking values TRUE or FALSE, specifying whether or not pseudocounts are added to the matrix.

scale

Logical, taking values TRUE or FALSE, specifying whether or not the matrix is scaled column-wise, i.e., all columns summed to 1.

sinuc

Logical. Specify TRUE for mononucleotides (default), FALSE to for dinucleotides.

Value

A PWM. If sinuc is 'TRUE', the PWM has 4 rows corresponding to the 4 nucleotides (A, C, G, T) and the relevant number of columns (i.e., number of elements in given vector/4). If dinucleotide is selected, by setting 'sinuc' to 'FALSE', the PWM has 16 rows corresponding to the dinucleotide combinations of the four nucleotides (A, C, G, T) and the relevant number of columns (i.e., number of elements in given vector/16).

Examples


## Mononucleotides case
## Make a dummy PWM of dimensions 4 * 10 from a vector
vec <- runif(4*10)
pwm <- seqArchR::make_PWMs(vec = vec, add_pseudo_counts = FALSE)

## Dinucleotides case
res <- readRDS(system.file("extdata", "example_seqArchRresult.rds",
         package = "seqArchR", mustWork = TRUE))

pwm <- seqArchR::make_PWMs(get_clBasVec_m(res,iter=1)[,1],
                        add_pseudo_counts = FALSE, sinuc = FALSE)


snikumbh/seqArchR documentation built on March 11, 2024, 7:06 p.m.