【问题标题】:Sushi plotBedgraph and plotBed functions produce errorsSushi plotBedgraph 和 plotBed 函数产生错误
【发布时间】:2020-03-26 10:19:24
【问题描述】:

我想使用 Sushi 包的 plotBedGraph 和 plotBed 函数以 bedgraph 和 bed 文件格式绘制我的数据。我使用 Bedtools 从我的 bam 文件中生成了这两个文件。此外,我运行了 Sushi 包提供的示例数据集,以查看我的包安装和依赖项是否存在且正常运行,并且一切正常。 我导入了我的 bedgraph 文件并使用 plotBedgraph 函数来绘制数据集,如下所示:

# import bedgraph file
```A24H1.bedgraph <- read.delim("A24H1.bedgraph", header = FALSE)```
# rename colnames according to Sushi example dataset
```colnames(A24H1.bedgraph) <- c("chrom", "start", "end", "value")```
# plot data
```chrom = "Chr"```
```chromstart = 0```
```chromend = 10835```
```plotBedgraph(A24H1.bedgraph,chrom,chromstart,chromend,colorbycol = SushiColors(5))```
# the function produced the following error:
[1] "not enough data within range to plot"

我检查了我的床位图文件的结构如下:

```str(A24H1.bedgraph)```

'data.frame':   6162 obs. of  4 variables:

$ chrom: Factor w/ 1 level "TBEV_Hypr_(TEU39292)": 1 1 1 1 1 1 1 1 1 1 ...

$ start: int  0 1 4 16 17 18 24 25 26 27 ...

$ end  : int  1 4 16 17 18 24 25 26 27 28 ...

$ value: int  5 6 10 8 5 8 11 55 57 58 ...

bedgraph 结构对应于 Sushi 包提供的示例 bedgraph 文件。 我还从我的 bamfile 中提取了映射的读取,并将它们映射到 Geneious 中,以查看读取实际上映射到我的参考,因此我知道有足够的读取进行映射。

另外我在使用 plotBed 函数时遇到了一个错误:

# import bedgraph file
```A24H1.bed <- read.delim("A24H1.bed",header = FALSE)```
# rename colnames according to Sushi example dataset
```colnames(A24H1.bed) <- c("chrom", "start", "end", "name", "score", "strand")```
```chrom = "Chr"```
```chromstart = 0```
```chromend = 10833```
```plotBed(beddata = A24H1.bed,chrom = chrom,chromstart = chromstart,chromend = chromend,colorby = A24H1.bed$strand,colorbycol = SushiColors(2),row = "auto",wiggle = 0.001)```
# the function produced the following error:
Error in seq.default(min(vec), max(vec), length.out = num) :

  'from' must be a finite number

In addition: Warning messages:

1: In min(vec) : no non-missing arguments, returning NA

2: In max(vec) : no non-missing arguments, returning NA

Additionally, I also checked the structure of my bed file as follows:

``` str(A24H1.bed)```

'data.frame':   49000 obs. of  6 variables:

 $ chrom : chr  "TBEV_Hypr_(TEU39292)" "TBEV_Hypr_(TEU39292)" "TBEV_Hypr_(TEU39292)" "TBEV_Hypr_(TEU39292)" ...

 $ start : int  0 0 0 0 0 1 4 4 4 4 ...

 $ end   : int  17 17 42 16 16 17 36 36 36 36 ...

 $ name  : chr  "HISEQ:1014:CCU0AANXX:1:1107:9256:84705" "HISEQ:1014:CCU0AANXX:1:1109:3798:5998" "HISEQ:1014:CCU0AANXX:1:1307:20106:47604" "HISEQ:1014:CCU0AANXX:1:1310:6646:43722" ...

 $ score : int  255 255 255 255 255 255 255 255 255 255 ...

 $ strand: chr  "+" "+" "+" "-" ...

我是 R 初学者,我不知道我还能如何找到问题所在。我会很高兴收到任何建议,因为我已经在谷歌上搜索了很多小时类似的问题,而且似乎没有其他人对这些 Sushi 功能有任何问题。谢谢

【问题讨论】:

  • 似乎chrom = "Chr" 将分配不存在的染色体名称Chr,因此没有数据可绘制。试试chrom = "TBEV_Hypr_(TEU39292)"...
  • 感谢您的建议!确实有效!彻底解决了plotbedgraph函数问题;然而,plotBed 函数产生了这个错误信息: Error in Summary.factor(c(2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, : 'min' not meaning for factors, So我手动将“strand”列字符值“+”和“-”转换为“1”和“-1”数值,尽管 Sushi 手册允许两者。但是,当我使用这个调整后的数据集运行 plotBed 函数时,命令继续运行没有任何回应
  • 默认情况下(至少在当前的 R 版本中,read.delim 使用选项stringsAsFactors = TRUE 读取数据。试试A24H1.bed &lt;- read.delim("A24H1.bed",header = FALSE, stringsAsFactors = FALSE)
  • 不幸的是stringsAsFactors=FALSE,产生了几个错误:A24H1.bed1 &lt;- read.delim("A24H1.bed", header = FALSE, stringsAsFactors = FALSE) plotBed(beddata = A24H1.bed1,chrom = chrom,chromstart = chromstart,chromend = chromend,colorby = A24H1.bed1$strand,colorbycol = SushiColors(2),row = "auto",wiggle = 0.001) [1] "yes" Error in seq.default(min(vec), max(vec), length.out = num ) : 'from' 必须是一个有限数另外: 警告信息: In seq.default(min(vec), max(vec), length.out = num) : NAs 由强制引入
  • plotBed 函数的更新:我让 plotBed 函数的命令运行了一夜,前几天来到我的办公室,找到了所需的图形!最终,我对输入床文件所做的所有调整都是有效且正确的,我的 RStudio 只用了 1 个多小时来处理该功能。感谢您的大力帮助和咨询!

标签: r plot


【解决方案1】:

根据请求将其重新发布为答案:

发布代码中的chrom = "Chr" 将分配不存在的染色体名称Chr,因此没有要绘制的数据。改用chrom = "TBEV_Hypr_(TEU39292)" 应该可以解决这个问题。

【讨论】:

    猜你喜欢
    • 2020-10-10
    • 2022-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-11
    • 2022-01-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多