Description Usage Arguments Details Value Author(s) See Also Examples
replaceLetterAt
first makes a copy of a sequence (or set of
sequences) and then replaces some of the original letters by new
letters at the specified locations.
.inplaceReplaceLetterAt
is the IN PLACE version of
replaceLetterAt
: it will modify the original
sequence in place i.e. without copying it first.
Note that in place modification of a sequence is fundamentally
dangerous because it alters all objects defined in your session
that make reference to the modified sequence.
NEVER use .inplaceReplaceLetterAt
, unless you know what
you are doing!
1 2 3 4 | replaceLetterAt(x, at, letter, if.not.extending="replace", verbose=FALSE)
## NEVER USE THIS FUNCTION!
.inplaceReplaceLetterAt(x, at, letter)
|
x |
A DNAString or rectangular DNAStringSet object. |
at |
The locations where the replacements must occur. If If |
letter |
The new letters. If If |
if.not.extending |
What to do if the new letter is not "extending" the old letter?
The new letter "extends" the old letter if both are IUPAC letters
and the new letter is as specific or less specific than the old
one (e.g. M extends A, Y extends Y, but Y doesn't extend S).
Possible values are Note that the gap ( Also note that |
verbose |
When |
.inplaceReplaceLetterAt
semantic is equivalent to calling
replaceLetterAt
with if.not.extending="merge"
and verbose=FALSE
.
Never use .inplaceReplaceLetterAt
!
It is used by the injectSNPs
function
in the BSgenome package, as part of the "lazy sequence loading"
mechanism, for altering the original sequences of a
BSgenome object at "sequence-load time".
This alteration consists in injecting the IUPAC ambiguity letters
representing the SNPs into the just loaded sequence, which is the
only time where in place modification of the external data of
an XString object is safe.
A DNAString or DNAStringSet object of the same shape
(i.e. length and width) as the orignal object x
for replaceLetterAt
.
H. Pagès
The replaceAt
function for extracting or replacing
arbitrary subsequences from/in a sequence or set of sequences.
IUPAC_CODE_MAP
for the mapping between IUPAC
nucleotide ambiguity codes and their meaning.
The chartr
and injectHardMask
functions.
The DNAString and DNAStringSet class.
The injectSNPs
function and the
BSgenome class in the BSgenome package.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ## Replace letters of a DNAString object:
replaceLetterAt(DNAString("AAMAA"), c(5, 1, 3, 1), "TYNC")
replaceLetterAt(DNAString("AAMAA"), c(5, 1, 3, 1), "TYNC", if.not.extending="merge")
## Replace letters of a DNAStringSet object (sorry for the totally
## artificial example with absolutely no biological meaning):
library(drosophila2probe)
probes <- DNAStringSet(drosophila2probe)
at <- matrix(c(TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE),
nrow=length(probes), ncol=width(probes)[1],
byrow=TRUE)
letter_subject <- DNAString(paste(rep.int("-", width(probes)[1]), collapse=""))
letter <- as(Views(letter_subject, start=1, end=rowSums(at)), "XStringSet")
replaceLetterAt(probes, at, letter)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.