生信人

找回密码
立即注册
搜索
热搜: 活动 交友 discuz
发新帖

0

收听

12

听众

318

主题
发表于 2023-5-11 20:26:12 | 查看: 2821| 回复: 0
本帖最后由 生信喵 于 2023-5-11 21:02 编辑

物种分类鉴定
  1. #方法一:dada2自带注释函数,官网下载
  2. #https://benjjneb.github.io/dada2/training.html
  3. # taxa <- assignTaxonomy(seqtab.nochim, "MiSeq_SOP/tax/silva_nr99_v138.1_train_set.fa.gz", multithread=12)
  4. # taxa <- addSpecies(taxa, "MiSeq_SOP/tax/silva_species_assignment_v138.1.fa.gz")
  5. #
  6. # taxa.print <- taxa
  7. # rownames(taxa.print) <- NULL
  8. # head(taxa.print)

  9. #方法二: DECIPHER
  10. download.file(url="http://www2.decipher.codes/Classification/TrainingSets/SILVA_SSU_r138_2019.RData", destfile="SILVA_SSU_r138_2019.RData")

  11. #加载CECIPHER SILVA库
  12. load("SILVA_SSU_r138_2019.RData")

  13. #加载DECIPHER
  14. library(DECIPHER)
  15. packageVersion("DECIPHER")

  16. #创建dna序列
  17. dna <- DNAStringSet(getSequences(seqtab.nochim))

  18. ids <- IdTaxa(dna, trainingSet, strand="top", processors=12, verbose=FALSE)
  19. ranks <- c("domain", "phylum", "class", "order", "family", "genus", "species") # ranks of interest
  20. # Convert the output object of class "Taxa" to a matrix analogous to the output from assignTaxonomy
  21. taxid <- t(sapply(ids, function(x) {
  22.   m <- match(ranks, x$rank)
  23.   taxa <- x$taxon[m]
  24.   taxa[startsWith(taxa, "unclassified_")] <- NA
  25.   taxa
  26. }))
  27. colnames(taxid) <- ranks
  28. rownames(taxid) <- getSequences(seqtab.nochim)
复制代码
评估结果
  1. unqs.mock <- seqtab.nochim["Mock",]
  2. unqs.mock <- sort(unqs.mock[unqs.mock>0], decreasing=TRUE)
  3. cat("DADA2 inferred", length(unqs.mock), "sample sequences present in the Mock community.\n")

  4. mock.ref <- getSequences(file.path(path, "HMP_MOCK.v35.fasta"))
  5. match.ref <- sum(sapply(names(unqs.mock), function(x) any(grepl(x, mock.ref))))
  6. cat("Of those,", sum(match.ref), "were exact matches to the expected reference sequences.\n")
复制代码
画树
  1. library(msa)

  2. seqs <- getSequences(seqtab.nochim)
  3. names(seqs) <- seqs
  4. mult <- msa(seqs, method="ClustalW", type="dna", order="input")

  5. library("phangorn")
  6. phang.align <- as.phyDat(mult, type="DNA", names=getSequence(seqtab))
  7. dm <- dist.ml(phang.align)
  8. treeNJ <- NJ(dm) # Note, tip order != sequence order
  9. fit = pml(treeNJ, data=phang.align)
  10. ## negative edges length changed to 0!
  11. fitGTR <- update(fit, k=4, inv=0.2)
  12. fitGTR <- optim.pml(fitGTR, model="GTR", optInv=TRUE, optGamma=TRUE,
  13.                     rearrangement = "stochastic", control = pml.control(trace = 0))
  14. fitGTR$tree
复制代码

收藏回复 显示全部楼层 道具 举报

您需要登录后才可以回帖 登录 | 立即注册

QQ|Archiver|手机版|小黑屋|生信人 ( 萌ICP备20244422号 )

GMT+8, 2024-11-23 21:18 , Processed in 0.086950 second(s), 30 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表