R で最大節約アルゴリズム (サル ライブラリの pratchet()) を使用してブートストラップ分析を実行しています。ルート化されていないツリー (pratchet() 関数を使用して作成) で分析を実行すると、ブートストラップは正常に実行されます。しかし、ブートストラップのサポートを見つける前に、ブートストラップされた各ツリーをルート化したい場合、100 個のツリーのいずれかでランダムにルート化するとエラーが発生します。これは、2 分割またはクレード サポートを計算するためのコードを呼び出す前に発生することに注意してください。
近隣結合アルゴリズム (サルの nj()) を使用すると、ルート化またはダウンストリームのブートストラップではまったく問題はありませんが、アウトグループを使用して節約ベースのツリーをルート化するときに (ランダムに) 発生するようです。私が観察した奇妙なことは、ルート化する前に(ルート化中にエラーが発生した場合に備えて)ルート化されていないツリーをファイルに書き込み、後でそれらをルート化したい場合、完全に正常に動作することです。
これがコードです。私は分析に使用しています。
performBootstraping = function(charMatrix, bsIterations) {
# charMatrix is a DNA alignment matrix
# bsIteration are number of bootstrap iterations.
library(phangorn)
phySeq = phyDat(charMatrix)
treeMPRooted = getRootedParsimonyTree(charMatrix)
bValuesMP = boot.phylo(treeMPRooted, charMatrix, FUN=function(xx) {tt = getRootedParsimonyTree(xx); return(tt) },
B = bsIterations, trees=T, rooted=T)
# convert to percentage
bValues = bValuesMP$BP/bsIterations * 100;
plot(treeMPRooted, use.edge.length = F);
title('Max Parsimony tree with bootstrap percentage')
nodelabels(bValues, frame = 'rect')
# write the tree as newick
write.tree(treeMPRooted, paste0(outDir,'/rooted_MP.tree'))
return(bValuesMP)
}
getRootedParsimonyTree = function(cMatrix) {
phySeq = phyDat(cMatrix);
treeMP = pratchet(phySeq)
treeMPRooted = root(treeMP, outgroup='Germline', resolve.root=T)
return(treeMPRooted)
}
これがスタックトレースとエラーです
Error in phy$edge[sndcol, 2] <- newNb[phy$edge[sndcol, 2]] <- n + 2:phy$Nnode :
number of items to replace is not a multiple of replacement length
6 root(treeMP, outgroup = "Germline", resolve.root = T) at libaryFunctions.R#105
5 getRootedParsimonyTree(xx) at libaryFunctions.R#32
4 FUN(x[, boot.samp])
3 boot.phylo(treeMPRooted, t.vaf, FUN = function(xx) {
tt = getRootedParsimonyTree(xx)
return(tt)
}, B = bstrapCount, trees = T, rooted = T) at libaryFunctions.R#32
2 performBootstraping(vaf, outDir, i, bsIterations) at runAllSitesBootstrapForAllPatients.R#15
1 runAllSitesBootstrapForAllPatients(ccfFileDir = ccfDir, outDirPref = outDir)
In addition: Warning message:
In newNb[phy$edge[sndcol, 2]] <- n + 2:phy$Nnode :
number of items to replace is not a multiple of replacement length