首页 > 解决方案 > chromoPlot 错误 - 读取的数据多于文件中的数据

问题描述

我正在尝试使用 R 中的 chromoPlot 包来可视化染色体片段。

根据指南,我应该制作一个定义感兴趣染色体的染色体文件和一个包含感兴趣片段的数据文件

然后

library(chromoMap)
chromoMap("FF Chromosome Map/DB/chromosome_file.txt","FF Chromosome Map/DB/Anne Larsen.txt")

应该很好地在染色体图上绘制片段。

但是,当我尝试运行代码时出现错误

********************************** __ __ ************
** __**|__ * __* __ * __ __ * __ *|  |  |* __ * __ **
**|__**|  |*|  *|__|*|  |  |*|__|*|  |  |*|_ |*|__|**
***********************************************|   **
*************** by Lakshay Anand ********************
OUTPUT: 
Number of Chromosome sets: 1 
Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec,  : 
  line 2 did not have 5 elements

当我手动读取数据文件时,它们有 4 列,每个 \tab 按应有的方式分隔。

有什么建议么

标签: rgenetics

解决方案


我认为您需要检查您的文件并确保没有列名或行名,并且具有指南中提到的格式。见下文:

我们可以模拟一些数据并将它们写为txt文件,注意没有列名或行名:

df = data.frame(chr=c("chr1","chr2","chr3"),
start=1,end=c(100e6,120e6,80e6),cent=c(50e6,60e6,70e6))
write.table(df,"chromosome_file.txt",quote=F,
sep="\t",row.names=FALSE,col.names=FALSE)
anno = data.frame(Ele=c("Feature1","Feature2"),
chr=c("chr2","chr3"),start=c(50000,55000),
end=c(60000,70000),score=c(77,88))

这是一个可重现的例子:

library(chromoMap)
chromoMap("chromosome_file.txt","anno.txt")

在此处输入图像描述

如果表是用行名或列名编写的,默认情况下,我可以重现您的错误:

write.table(df,"chromosome_file_v2.txt",quote=F,sep="\t")
chromoMap("chromosome_file_v2.txt","anno.txt")
********************************** __ __ ************
** __**|__ * __* __ * __ __ * __ *|  |  |* __ * __ **
**|__**|  |*|  *|__|*|  |  |*|__|*|  |  |*|_ |*|__|**
***********************************************|   **
*************** by Lakshay Anand ********************
OUTPUT: 
Number of Chromosome sets: 1 
Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec,  : 
  line 1 did not have 5 elements

推荐阅读