r - 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 按应有的方式分隔。
有什么建议么
解决方案
我认为您需要检查您的文件并确保没有列名或行名,并且具有指南中提到的格式。见下文:
我们可以模拟一些数据并将它们写为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
推荐阅读
- python - 在 Python 中使用两个 4D 数组制作的散点图斜率
- javascript - 无法读取未定义的属性 OwnerDocument
- javascript - react js - Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
- java - null org.bukkit.command.CommandException 错误(Spigot)
- ffmpeg - 音频转换失败问题 Discord.py
- output - (wx)Maxima:返回表达式使用 `sec` `csc` 和 `cot` 而不是倒数?
- typescript - 定义 TypeScript 回调类型并提供默认回调值
- python - 如何将包含多行的单元格的数据框行转换为单独的列
- excel - 您可以在 Excel 中创建自定义错误类型吗?
- python - 我得到“TypeError:列表索引必须是整数或切片,而不是 str”。我如何解决它?