r - 是否可以将 R 数据帧插入到现有的 .dat 文件中,该文件专门格式化为 COLONY 软件的输入?
问题描述
感谢您考虑这个问题。
我正在尝试使用软件 COLONY 来衡量我根据基因型收集的蜜蜂之间兄弟姐妹关系的可能性。我有 90 个人口要运行,所以我想使用程序的批处理功能,它需要为每个人口提供一个输入文件(90 个 .dat 格式的输入文件)。输入文件看起来都是一样的,除了它们必须包括唯一的群体名称、群体中的样本数量(变化)和群体特定的基因型信息(在适当的情况下)。输入文件如下所示,之后的所有内容!是注释,输入必须特定于人口的三个地方标有**:
OcciSibGroups !Dataset name
**OcciSibGroup[i]** !Output file name
**nrows(OcciSibGroup[i])** ! Number of offspring in the sample
6 ! Number of loci
1234 ! Seed for random number generator
0 ! 0/1=Not updating/updating allele frequency
1 ! 0/1=Diploid species/HaploDiploid species
1 1 ! 0/1=Polygamy/Monogamy for males & females
0 ! 0/1=Unknown/Known population allele frequency
1 ! Number of runs
3 ! Length of run
0 ! 0/1=Monitor method by Iterate#/Time in second
10000 ! Monitor interval in Iterate# / in seconds
0 ! Windows version
B124 BTERN01 BT28 BT10 BT30 B96 !Marker IDs of locus 1~6
0 0 0 0 0 0 !Marker type (0/1=Codominant/Dominant) of locus 1~6
0.01 0.01 0.01 0.01 0.01 0.01 !Allelic dropout rate of locus 1~6
0.05 0.05 0.05 0.05 0.01 0.05 !Other Error rate of locus 1~6
**Insert OcciSibGroup[i] here** !Offspring ID and genotypes of locus 1~6
0.5 0.5 !Prob. the father and mother of an offspring are included in candidates
0 0 !Numbers of candidate males and females
0 !Number of offspring with known father
0 !Number of offspring with known mother
0 !Number of known paternal sibships
0 !Number of known maternal sibships
0 !Number of offspring with known excluded fathers
0 !Number of offspring with known excluded mothers
我在 R 中创建了一个包含所有样本及其基因型的数据框,并使用 SPLIT 函数以输入文件的正确格式为每个群体的基因型信息创建单独的对象。
OcciSibGroup <- split(occi_sibship, [, 32])
str(OcciSibGroup)
每个总体看起来像这样,每个样本在一行,第一列是样本名称:
OcciSibGroup[1]
UC-Occi90 242 244 108 108 186 186 134 160 188 191 232 232
UC-Occi91 244 244 108 110 186 186 130 132 194 194 232 232
UC-Occi92 0 0 106 122 0 0 130 150 194 194 232 232
UC-Occi93 242 244 116 116 186 186 128 134 191 194 232 232
UC-Occi94 0 0 108 126 0 0 150 162 0 0 0 0
UC-Occi95 244 244 106 116 180 186 132 150 194 197 232 232
我想 1)将基因型数据框插入到 .dat 文件中的正确位置,以及 2)创建一个循环,允许我同时创建所有输入文件,其中包括更改输出文件名和样本中的后代数量(基因型数据框中的行数)。输入文件中的其他所有内容都将保持不变。
解决方案
推荐阅读
- r - modCost 中的错误(obs = world_data,model = out):在 R 中找不到对象“world_data”
- python - 计算余弦相似度:ValueError: Input must be 1- or 2-d
- jboss - PersistenceException / HibernateException:事务在不同的线程中回滚
- python - int() 参数必须是字符串、类似字节的对象或数字,而不是 'NoneType' Django 表单
- laravel - 如何在windows中输入php artisan serve linux?
- r - plot.new() 中的错误:闪亮应用中的图形边距太大
- wpf - ClickOnce - 部署中的引用与应用程序清单中定义的身份不匹配
- reactjs - 从对象数组填充表示 SVG 的功能组件
- c# - 按下按钮时跳转(unity 2D)
- javascript - Puppeteer:一旦特殊元素已经出现,就停止等待缓慢的页面