[英]R package ape: extract the first two nucleotide in the codon
我有一個包含DNA序列的fasta文件。 我想刪除每個密碼子的第三個核苷酸。 我以為我可以在子設置步驟中選擇前2個核苷酸。
我使用ape和seqinr包在R中工作
>read.dna("test3", format="fasta")-> test3
>test3
1 DNA sequences in binary format stored in a matrix.
All sequences of same length: 888
Labels: XX_00004
Base composition:
a c g t
0.223 0.222 0.293 0.262
使用功能seq
我可以在每個密碼子中單獨選擇第一個,第二個和第三個核苷酸,但是我不能選擇第一個和第二個。
>test3[seq(1, length(test3), by = 3)]
1 DNA sequence in binary format stored in a vector.
Sequence length: 296
Base composition:
a c g t
0.256 0.249 0.374 0.121
>test3[seq(1:2, length(test3), by = 3)]
Error in seq.default(1:2, length(test3), by = 3) :
'from' must be of length 1
> test3[seq(from=1, to=2, length(test3), by = 3)]
Error in seq.default(from = 1, to = 2, length(test3), by = 3) :
too many arguments
任何建議如何做到這一點?
您可以通過排除第三個來選擇第一個和第二個:
test3[-seq(3, length(test3), by = 3)]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.