adonis 分析后写入文件时出错
error while writing file after adonis analysis
我正在尝试使用以下代码编写排列分析的输出,但它显示错误,您能否建议我如何解决此错误?
R code
###adonis_calculation
BC <- phyloseq::distance(phyloseq_prop, "bray")
pmv =adonis(BC ~Season*Region, as(sample_data(physeqN3), "data.frame"),permutations = 5000)
pmv
write.table(pmv, "permutation.16s.Root.txt")
Error:
Df SumsOfSqs MeanSqs F.Model R2 Pr(>F)
Season 1 1.2435 1.24348 17.229 0.07405 2e-04 ***
Region 2 5.3491 2.67457 37.058 0.31855 2e-04 ***
Season:Region 2 1.3222 0.66110 9.160 0.07874 2e-04 ***
Residuals 123 8.8773 0.07217 0.52866
Total 128 16.7921 1.00000
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) :
cannot coerce class ‘"adonis"’ to a data.frame
Calls: write.table ... data.frame -> as.data.frame -> as.data.frame.default
Execution halted
非常感谢
输出不是 data.frame 格式,一个选项是用 capture.output
捕获输出
capture.output(pmv, file = "permutation.16s.Root.txt")
使用一个可重现的小例子
library(vegan)
data(dune)
data(dune.env)
pmv <- adonis(dune ~ Management*A1, data = dune.env)
capture.output(pmv, file = "/Users/akrun/tmp/permutation.16s.Root.txt")
-输出
我正在尝试使用以下代码编写排列分析的输出,但它显示错误,您能否建议我如何解决此错误?
R code
###adonis_calculation
BC <- phyloseq::distance(phyloseq_prop, "bray")
pmv =adonis(BC ~Season*Region, as(sample_data(physeqN3), "data.frame"),permutations = 5000)
pmv
write.table(pmv, "permutation.16s.Root.txt")
Error:
Df SumsOfSqs MeanSqs F.Model R2 Pr(>F)
Season 1 1.2435 1.24348 17.229 0.07405 2e-04 ***
Region 2 5.3491 2.67457 37.058 0.31855 2e-04 ***
Season:Region 2 1.3222 0.66110 9.160 0.07874 2e-04 ***
Residuals 123 8.8773 0.07217 0.52866
Total 128 16.7921 1.00000
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) :
cannot coerce class ‘"adonis"’ to a data.frame
Calls: write.table ... data.frame -> as.data.frame -> as.data.frame.default
Execution halted
非常感谢
输出不是 data.frame 格式,一个选项是用 capture.output
capture.output(pmv, file = "permutation.16s.Root.txt")
使用一个可重现的小例子
library(vegan)
data(dune)
data(dune.env)
pmv <- adonis(dune ~ Management*A1, data = dune.env)
capture.output(pmv, file = "/Users/akrun/tmp/permutation.16s.Root.txt")
-输出