r - 在 R 中创建 Nexus 文件
问题描述
我有一个用于创建关联文件的矩阵:
mt = matrix(c(rep(1:5,times = 2), NA, 2,5,2,4,1,2,5,3,1), nrow=10)
rownames(mt) <- paste(rep("taxon", 10), 1:10)
colnames(mt) = c("color", "type")
mt
color type
taxon 1 1 NA
taxon 2 2 2
taxon 3 3 5
taxon 4 4 2
taxon 5 5 4
taxon 6 1 1
taxon 7 2 2
taxon 8 3 5
taxon 9 4 3
taxon 10 5 1
创建一个 ```mt```` 的关系文件(格式标准 - 分类矩阵)我正在使用:
charstate = write.nexus.data(mt, file = "charstate.nex", format ="stand", datablock = T)
这将导致:
#NEXUS
[Data written by write.nexus.data.R, Sun Mar 07 13:19:14 2021]
BEGIN DATA;
DIMENSIONS NTAX=10 NCHAR=2;
FORMAT DATATYPE=STANDARD MISSING=? GAP=- INTERLEAVE=NO symbols="0123456789";
MATRIX
taxon 1 1NA
taxon 2 22
taxon 3 35
taxon 4 42
taxon 5 54
taxon 6 11
taxon 7 22
taxon 8 35
taxon 9 43
taxon 10 51
;
END;
但是,我想在我的 NEXUS 文件中也有 CHARSTATELABELS。例子:
#NEXUS
[Data written by write.nexus.data.R, Sun Mar 07 13:19:14 2021]
BEGIN DATA;
DIMENSIONS NTAX=10 NCHAR=2;
FORMAT DATATYPE=STANDARD MISSING=? GAP=- INTERLEAVE=NO symbols="0123456789"
CHARSTATELABELS
1 'color (1 blue, 2 yellow, 3 red, 4 black, 5 white)'
2'type(1 big, 2 short, 3 medium, 4 big-short, 5 medium-short)'
;
MATRIX
此外,您可以看到符号未显示正确的编码状态。右边是符号 =“012345”,而不是最初描述的 0 到 9。如何包含CHARSTATELABELS和正确的 ** 符号**?
解决方案
推荐阅读
- python - 仅在行上方而不是下方显示文本注释
- c# - UWP C# SQLConnection
- sql - 在 SQL Server 中对分层表进行排序?
- python - 数值求解投石机运动微分方程的刚性(奇异)系统
- javascript - 如何正确地将 ref 从功能组件转发到 material-ui 组件
- c# - 程序不包含适合入口点的静态 main 方法
- nginx - 使用 Nginx 提供基于变量的不同页面
- vue.js - Vee 验证没有 v-model 的验证行
- scala - 声明 Dataframe 的 StructType:包含 org.apache.spark.ml.linalg.Vector 的列
- python-3.x - 对内置类型使用自定义验证