replaceLetterAt(Biostrings)
replaceLetterAt()所属R语言包:Biostrings
Replacing letters in a sequence (or set of sequences)
更换序列中的字母(或序列)
译者:生物统计家园网 机器人LoveR
描述----------Description----------
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.
replaceLetterAt第一序列(或序列)的副本,然后替换一些新的信件,在指定地点的原始信件。
.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!
.inplaceReplaceLetterAt是就地版本replaceLetterAt:它会先复制它没有修改的地方,即在原始序列。请注意,在地方一个序列的修改基本上是危险的,因为它改变在会议中定义的所有对象,使修改后的顺序。不要使用.inplaceReplaceLetterAt,除非你知道你在做什么!
用法----------Usage----------
replaceLetterAt(x, at, letter, if.not.extending="replace", verbose=FALSE)
## NEVER USE THIS FUNCTION!
.inplaceReplaceLetterAt(x, at, letter)
参数----------Arguments----------
参数:x
A DNAString or rectangular DNAStringSet object.
一个DNAString或长方形DNAStringSet的对象。
参数:at
The locations where the replacements must occur. If x is a DNAString object, then at is typically an integer vector with no NAs but a logical vector or Rle object is valid too. Locations can be repeated and in this case the last replacement to occur at a given location prevails. If x is a rectangular DNAStringSet object, then at must be a matrix of logicals with the same dimensions as x.
更换必须发生的位置。如果x是DNAString的对象,那么at通常是一个整数向量没有NAS但或RLE对象的一个逻辑向量是有效的。位置可以重复,在这种情况下,最后更换发生在一个给定的位置为准。如果x是长方形DNAStringSet的对象,那么at必须是一个逻辑值作为x尺寸相同的矩阵。
参数:letter
The new letters. If x is a DNAString object, then letter must be a DNAString object or a character vector (with no NAs) with a total number of letters (sum(nchar(letter))) equal to the number of locations specified in at. If x is a rectangular DNAStringSet object, then letter must be a DNAStringSet object or a character vector of the same length as x. In addition, the number of letters in each element of letter must match the number of locations specified in the corresponding row of at (all(width(letter) == rowSums(at))).
新的信件。如果x是DNAString的对象,那么letter必须是一个DNAString对象或一个字母的总数(sum(nchar(letter)))位置的数量等于一个字符向量(无NAS)指定at。如果x是长方形DNAStringSet的对象,那么letter必须是一个DNAStringSet对象或作为x相同长度的字符向量。此外,在每个letter元素的数目字母必须符合相应的行中指定的地点at(all(width(letter) == rowSums(at)))。
参数: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 "replace" (the default) for replacing in all cases, "skip" for not replacing when the new letter does not extend the old letter, "merge" for merging the new IUPAC letter with the old one, and "error" for raising an error. Note that the gap ("-") and hard masking ("+") letters are not extending or extended by any other letter. Also note that "merge" is the only value for the if.not.extending argument that guarantees the final result to be independent on the order the replacement is performed (although this is only relevant when at contains duplicated locations, otherwise the result is of course always independent on the order, whatever the value of if.not.extending is).
如果没有新的信件是“扩大”老信怎么办?新信“延伸”的旧信,如果双方的IUPAC字母和新的信是具体或小于旧的具体(例如M扩展,Y扩展Y,但Y不延长)。可能的值是"replace"(默认)在所有情况下更换,"skip"不更换新信时不延长老信,"merge"合并的新的IUPAC信与旧人,和"error"引发错误。需要注意的是差距("-")和硬掩蔽("+")字母不延长或延长任何其他字母。还注意到,"merge"是if.not.extending参数,保证最后的结果是独立的执行顺序更换为唯一的价值(虽然这是有关at包含重复的地点,否则其结果是当然总是独立的顺序,任何值if.not.extending)。
参数:verbose
When TRUE, a warning will report the number of skipped or merged letters.
当TRUE,预警报告跳过或合并的字母数。
Details
详情----------Details----------
.inplaceReplaceLetterAt semantic is equivalent to calling replaceLetterAt with if.not.extending="merge" and verbose=FALSE.
.inplaceReplaceLetterAt语义等同于调用replaceLetterAt用if.not.extending="merge"和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.
从来没有使用.inplaceReplaceLetterAt!它是用来injectSNPs在BSgenome包功能,机制“懒加载顺序”,“序列负荷时间”改变原一个BSgenome对象序列的一部分。这种改变包括在注射IUPAC模糊字母代表的SNPs到刚刚加载的序列,这是唯一的一次,在外部数据一个XString对象的修改地方是安全的。
值----------Value----------
A DNAString or DNAStringSet object of the same shape (i.e. length and width) as the orignal object x for replaceLetterAt.
一个相同的形状(即长度和宽度)的原对象xreplaceLetterAtDNAString或DNAStringSet对象。
作者(S)----------Author(s)----------
H. Pages
参见----------See Also----------
IUPAC_CODE_MAP, chartr, injectHardMask, DNAString, DNAStringSet, injectSNPs, BSgenome
IUPAC_CODE_MAP,chartr,injectHardMask,DNAString,DNAStringSet,injectSNPs,BSgenome
举例----------Examples----------
## Replace letters of a DNAString object:[#替换一个DNAString对象字母:]
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[#替换一个DNAStringSet对象的字母(对不起,完全]
## 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)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|