r-使用seqinr以序列名称提取子集对齐



我正在尝试从序列A序列对齐(对准对象)中提取一组对齐序列。

alignment(S4对象)的dput()下方

structure(list(nb = 39, nam = c("Lip4", "pdb|5FRD|A", "pdb|1M33|A", 
"pdb|5H3H|B", "pdb|1HL7|B", "pdb|1A8S|A", "pdb|1WPR|B", "pdb|4JYM|A", 
"pdb|2OCI|A", "pdb|1XRO|A", "pdb|3OOS|A", "pdb|2RHW|A", "pdb|2WUF|B", 
"pdb|1IUP|A", "pdb|4LXI|A", "GBD36331.1", "ADV62823.1", "KRA67074.1", 
"WP_030056103.1", "OHD12261.1", "WP_084594117.1", "WP_091643197.1", 
"OGO52173.1", "KFN38864.1", "GBC76610.1", "PKN85453.1", "ACU30832.1", 
"KPJ59441.1", "WP_028052179.1", "OGN93027.1", "OGO32450.1", "PSN93892.1", 
"ESQ22364.1", "WP_069806679.1", "WP_013336464.1", "WP_066315780.1", 
"KRT77961.1", "OIO07272.1", "WP_009823005.1"), seq = list("ygglgwvdnrggsadlgvsmggaplllplgdpilhf", 
    "-----w-dlpngsay-ghslggapllyplgdpilhf", "wgglgwldlpggsaxagwslggapltlplgdpwsh-", 
    "vggmgfydyrggsadlgfsmggagllldlgdpilhy", "ygglgwvdrrggsadlgfsmgtlglfvplgdpvyhf", 
    "yggfgwvdrrggsadlgfstggvgallplgdpvlhf", "-ggfgwvdyvggsadlghsvgagplmlplcdpllhy", 
    "-gglgwvdnmggtsdlghsvsagpimlphsdplvhh", "ygglgfvdprggsadlgwsdggapmi-plgdpvlhf", 
    "ykptgyvdqfggsvelgssyggaqlviplgdpilhf", "------vnlkggsidlghsaggaqivlpfgdpilhf", 
    "yggmgwvdspgnsaalgnamggaplllkfgdpilhf", "ygglgwvdqpggsaalgnalggapllvplgdpilhf", 
    "ygglgyvdmvggtvhlgnafggasml-plgdpilhf", "ygglgrvdmvggtthlgnamggaplllplgdpighf", 
    "-gglgvvelrgarvdlgvsfggapvalplgdpihhf", "-ggmglvslrggsadlgvsfggvplllplgdpifhc", 
    "ygglgwvfqiggsvylgesfggvp-llplgdpifhf", "ygglgwvylrghssdlgwsyggvglllplgdpllhf", 
    "ygglgwvdnrggsadaglsmggaplllplgdpilhf", "fgglgwvdnrggtadagvsmggaplllplgdpilhf", 
    "ygglgwvdnrggsadagvsmggapmllplgdpllhf", "ygglgwvdnrdgsadlgvsmggapllvplgdpilhf", 
    "ygglgwvdnrggsadlgismggaplllplgdpllhf", "ygglgwtdnrggsadlghsmggaplllplgdpilhf", 
    "ygglgwvdnrggsadlglsmggapllapmadplmhf", "----gwcdnrggsadlgvsmggapvllplgdpiehf", 
    "ygglgwvdnrggtadqgvsvggapllvplgdpilhf", "yggcgwldnrggsadlgismggaplllplgdhilhf", 
    "ygglgfvdnrggsadvgismggaplllplgdpilhf", "yggmgyldnrggsadigasmggaplllplgdsilhf", 
    "ygglgwldnrggsadlgvsmggaplllplgdpilhf", "ygglgwldnrggstdlgvsmggadlllplgdnilhf", 
    "ygglgwldnrggsvdlgvsmggaplllplgdpilhf", "ygglgwldnrggsadlgfsmggaglllptgdpifhh", 
    "ygglgwvdnrggtadqgvsmggapllvklgdpiehf", "ygglgwvdnrggsadlgaslggaplllplgdpilhf", 
    "ygglgwvdnrggsadlgaslggaallpplgdpilhf", "ygglgwvdnrggsgdlgwslgglgallplgdpilhf"), 
    com = NA), class = "alignment")

我正在尝试这样的方法:

library(seqinr)
fas <- read.alignment("data.fa")
n <- c("OGO52173.1", "KFN38864.1", "GBC76610.1")
sub_fas <- fas[ fas$nam %in% n ]

,但我的 dput()显示了下面显示的另一种对象:

structure(list(39, c("Lip4", "pdb|5FRD|A", "pdb|1M33|A", "pdb|5H3H|B", 
"pdb|1HL7|B", "pdb|1A8S|A", "pdb|1WPR|B", "pdb|4JYM|A", "pdb|2OCI|A", 
"pdb|1XRO|A", "pdb|3OOS|A", "pdb|2RHW|A", "pdb|2WUF|B", "pdb|1IUP|A", 
"pdb|4LXI|A", "GBD36331.1", "ADV62823.1", "KRA67074.1", "WP_030056103.1", 
"OHD12261.1", "WP_084594117.1", "WP_091643197.1", "OGO52173.1", 
"KFN38864.1", "GBC76610.1", "PKN85453.1", "ACU30832.1", "KPJ59441.1", 
"WP_028052179.1", "OGN93027.1", "OGO32450.1", "PSN93892.1", "ESQ22364.1", 
"WP_069806679.1", "WP_013336464.1", "WP_066315780.1", "KRT77961.1", 
"OIO07272.1", "WP_009823005.1"), list("ygglgwvdnrggsadlgvsmggaplllplgdpilhf", 
    "-----w-dlpngsay-ghslggapllyplgdpilhf", "wgglgwldlpggsaxagwslggapltlplgdpwsh-", 
    "vggmgfydyrggsadlgfsmggagllldlgdpilhy", "ygglgwvdrrggsadlgfsmgtlglfvplgdpvyhf", 
    "yggfgwvdrrggsadlgfstggvgallplgdpvlhf", "-ggfgwvdyvggsadlghsvgagplmlplcdpllhy", 
    "-gglgwvdnmggtsdlghsvsagpimlphsdplvhh", "ygglgfvdprggsadlgwsdggapmi-plgdpvlhf", 
    "ykptgyvdqfggsvelgssyggaqlviplgdpilhf", "------vnlkggsidlghsaggaqivlpfgdpilhf", 
    "yggmgwvdspgnsaalgnamggaplllkfgdpilhf", "ygglgwvdqpggsaalgnalggapllvplgdpilhf", 
    "ygglgyvdmvggtvhlgnafggasml-plgdpilhf", "ygglgrvdmvggtthlgnamggaplllplgdpighf", 
    "-gglgvvelrgarvdlgvsfggapvalplgdpihhf", "-ggmglvslrggsadlgvsfggvplllplgdpifhc", 
    "ygglgwvfqiggsvylgesfggvp-llplgdpifhf", "ygglgwvylrghssdlgwsyggvglllplgdpllhf", 
    "ygglgwvdnrggsadaglsmggaplllplgdpilhf", "fgglgwvdnrggtadagvsmggaplllplgdpilhf", 
    "ygglgwvdnrggsadagvsmggapmllplgdpllhf", "ygglgwvdnrdgsadlgvsmggapllvplgdpilhf", 
    "ygglgwvdnrggsadlgismggaplllplgdpllhf", "ygglgwtdnrggsadlghsmggaplllplgdpilhf", 
    "ygglgwvdnrggsadlglsmggapllapmadplmhf", "----gwcdnrggsadlgvsmggapvllplgdpiehf", 
    "ygglgwvdnrggtadqgvsvggapllvplgdpilhf", "yggcgwldnrggsadlgismggaplllplgdhilhf", 
    "ygglgfvdnrggsadvgismggaplllplgdpilhf", "yggmgyldnrggsadigasmggaplllplgdsilhf", 
    "ygglgwldnrggsadlgvsmggaplllplgdpilhf", "ygglgwldnrggstdlgvsmggadlllplgdnilhf", 
    "ygglgwldnrggsvdlgvsmggaplllplgdpilhf", "ygglgwldnrggsadlgfsmggaglllptgdpifhh", 
    "ygglgwvdnrggtadqgvsmggapllvklgdpiehf", "ygglgwvdnrggsadlgaslggaplllplgdpilhf", 
    "ygglgwvdnrggsadlgaslggaallpplgdpilhf", "ygglgwvdnrggsgdlgwslgglgallplgdpilhf"), 
    NA, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
    NULL, NULL, NULL, NULL), .Names = c("nb", "nam", "seq", "com", 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA))

另外,我没有在列表n中获得子集。

在此示例中,我期望与fas相同的对象,但是变量n中只有3个元素。

预先感谢

我敢肯定,这可能有更好的方法。
但是我用一个技巧解决了。

首先,我用 read.fasta no read.alignment导入文件,我仍在使用 SeqinR0。

fas <- read.fasta("file.fa")

之后,我在列表中构建了一个tibble,并使用as.alignment,该 CC_12是对准对象的构造函数。

tibble(x) %>% 
  cbind(names = names(x)) %>% 
  filter(names %in% n) %>% 
  as.alignment(nb = nrow(.), seq = pull(., x), nam = pull(., names))

与此我做了我所需要的。

改进是完全有用且可接受的。不管怎么说,还是要谢谢你。我希望它可以帮助某人。

align <- read.alignment("fastafile",format="fasta")
align.temp.nam <- align$nam[align$nam %in% n]
align.temp.seq <- align$seq[align$nam %in% n]
align.sub <- as.alignment(nb=length(align.temp.nam),nam=align.temp.nam,seq=align.temp.seq)

相关内容

  • 没有找到相关文章

最新更新