在将比对导入R之后,如何检索单个DNA序列?

在将比对导入R之后,如何检索单个DNA序列?,r,bioinformatics,fasta,R,Bioinformatics,Fasta,我将FASTA格式的对齐方式导入到R中 read.dna(file.choose(),format="fasta",skip=0) 我的路线看起来像这样 Seq1 ATGCGGGAATGGACTCATGCATCG Seq2 ATTCGATCTTGCTAGCTAGCTCGT Seq3 ATATCGATGTCGATCGATCGACGA 如果我想从这个序列中调用单个序列(例如Seq2),我需要做什么?我不知道read.dna()从哪里来(有超过6000个CRAN包,将近1000个包)。你可

我将FASTA格式的对齐方式导入到R中

    read.dna(file.choose(),format="fasta",skip=0)
我的路线看起来像这样

Seq1 ATGCGGGAATGGACTCATGCATCG
Seq2 ATTCGATCTTGCTAGCTAGCTCGT
Seq3 ATATCGATGTCGATCGATCGACGA

如果我想从这个序列中调用单个序列(例如Seq2),我需要做什么?

我不知道
read.dna()
从哪里来(有超过6000个CRAN包,将近1000个包)。你可以用这个包和

library(Biostrings)
dna = readDNAStringSet("path/to.fasta")
并做许多有用的事情,包括。如果最后需要一个字符向量,那么

as.character(dna[1])


我猜您正在使用
ape
包。使用
?read.dna

library(ape)
cat(">No305",
"NTTCGAAAAACACACCCACTACTAAAANTTATCAGTCACT",
">No304",
"ATTCGAAAAACACACCCACTACTAAAAATTATCAACCACT",
">No306",
"ATTCGAAAAACACACCCACTACTAAAAATTATCAATCACT",
file = "exdna.txt", sep = "\n")
ex.dna4 <- read.dna("exdna.txt", format = "fasta")

ex.dna4[dimnames(ex.dna4)[[1]]=='No304',]
#1 DNA sequences in binary format stored in a matrix.

#All sequences of same length: 40 

#Labels: No304 

#Base composition:
#    a     c     g     t 
#0.475 0.300 0.025 0.200 

as.character(ex.dna4[dimnames(ex.dna4)[[1]]=='No304'])
#[1] "a" "t" "t" "c" "g" "a" "a" "a" "a" "a" "c" "a" "c" "a" "c" "c" "c" "a" "c"
#[20] "t" "a" "c" "t" "a" "a" "a" "a" "a" "t" "t" "a" "t" "c" "a" "a" "c" "c" "a"
#[39] "c" "t"
库(ape)
猫(“>No305”,
“NTTCGAAAACACACACTACTAAANTTATACAGTCACT”,
“>No304”,
“attcgaaaacacacctactaaaattacacact”,
“>No306”,
“ATTCGAAAAAACACTACTAAAATTATCATCAT”,
file=“exdna.txt”,sep=“\n”)
ex.dna4
library(ape)
cat(">No305",
"NTTCGAAAAACACACCCACTACTAAAANTTATCAGTCACT",
">No304",
"ATTCGAAAAACACACCCACTACTAAAAATTATCAACCACT",
">No306",
"ATTCGAAAAACACACCCACTACTAAAAATTATCAATCACT",
file = "exdna.txt", sep = "\n")
ex.dna4 <- read.dna("exdna.txt", format = "fasta")

ex.dna4[dimnames(ex.dna4)[[1]]=='No304',]
#1 DNA sequences in binary format stored in a matrix.

#All sequences of same length: 40 

#Labels: No304 

#Base composition:
#    a     c     g     t 
#0.475 0.300 0.025 0.200 

as.character(ex.dna4[dimnames(ex.dna4)[[1]]=='No304'])
#[1] "a" "t" "t" "c" "g" "a" "a" "a" "a" "a" "c" "a" "c" "a" "c" "c" "c" "a" "c"
#[20] "t" "a" "c" "t" "a" "a" "a" "a" "a" "t" "t" "a" "t" "c" "a" "a" "c" "c" "a"
#[39] "c" "t"