if (FALSE) {
# Create a PSSM (position-specific scoring matrix) with frequency values
pssm <- matrix(
c(
0.7, 0.1, 0.1, 0.1, # Position 1: mostly A
0.1, 0.7, 0.1, 0.1, # Position 2: mostly C
0.1, 0.1, 0.7, 0.1, # Position 3: mostly G
0.1, 0.1, 0.1, 0.7 # Position 4: mostly T
),
ncol = 4, byrow = TRUE
)
colnames(pssm) <- c("A", "C", "G", "T")
# Example sequences
seqs <- c("ACGTACGTACGT", "GGGGACGTCCCC", "TTTTTTTTTTT")
# Score sequences using log-sum-exp (default mode)
gseq.pwm(seqs, pssm, mode = "lse")
# Get maximum score
gseq.pwm(seqs, pssm, mode = "max")
# Find position of best match
gseq.pwm(seqs, pssm, mode = "pos")
# Find position with strand information
gseq.pwm(seqs, pssm, mode = "pos", bidirect = TRUE, return_strand = TRUE)
# Count matches above threshold
gseq.pwm(seqs, pssm, mode = "count", score.thresh = 0.5)
# Score only a region of interest
gseq.pwm(seqs, pssm, mode = "max", start_pos = 3, end_pos = 10)
# Allow matches to extend beyond ROI boundaries
gseq.pwm(seqs, pssm, mode = "count", start_pos = 5, end_pos = 8, extend = TRUE)
# Spatial weighting example: higher weight in the center
spatial_weights <- c(0.5, 1.0, 2.0, 1.0, 0.5)
gseq.pwm(seqs, pssm,
mode = "lse",
spat.factor = spatial_weights,
spat.bin = 2
)
}
Run the code above in your browser using DataLab