3

I am using chromPlot to visualise the genome of C. elegans.

library(chromPlot)

I have created the following data frame with the lengths of C. elegans chromosomes.

Chrom Start      End    Name
1     1     0 15072434 contigs
2     2     0 15279421 contigs
3     3     0 13783801 contigs
4     4     0 17493829 contigs
5     6     0 20924180 contigs
6     7     0 17718942 contigs
7     5     0    13794 contigs

When I use chromPlot(dataframe), I get a plot with 4 chromosomes and the following output/error:

   1 segment clusters.
   1 segment clusters.
   1 segment clusters.
   1 segment clusters.
   1 segment clusters.
   1 segment clusters.
   1 segment clusters.
Chrom 1 : 15072434 bp
Chrom 2 : 15279421 bp
Chrom 3 : 13783801 bp
Chrom 4 : 17493829 bp
Error in seq.default(minval, maxval, length = howmany) : 
  'from' must be of length 1

Does anybody know why I get this error?

I don't get this error when I use the data frame provided by the package with human segments. The structure of the data frame is:

'data.frame':   457 obs. of  4 variables:
 $ Chrom: chr  "1" "1" "1" "1" ...
 $ Start: int  124535434 121535434 3845268 13219912 17125658 29878082 120697156 120936695 121485434 142731022 ...
 $ End  : int  142535434 124535434 3995268 13319912 17175658 30028082 120747156 121086695 121535434 142781022 ...
 $ Name : chr  "heterochromatin" "centromere" "contig" "contig" ...

Compared to my data frame:

'data.frame':   7 obs. of  4 variables:
 $ Chrom: chr  "1" "2" "3" "4" ...
 $ Start: int  0 0 0 0 0 0 0
 $ End  : int  15072434 15279421 13783801 17493829 20924180 17718942 13794
 $ Name : chr  "contigs" "contigs" "contigs" "contigs" ...

I am on MacOS X.

Update

The 20th line of the package-provided hg_gap data frame is:

   Chrom Start   End     Name
20     1     0 10000 telomere

Note that the Start is 0.

I've also tried changing the start from 0 to 1. The error stays the same.

Update 2

Sorting the data frame by chromosome name does not improve the situation.

The traceback of the error is:

6: stop("'from' must be of length 1")
5: seq.default(minval, maxval, length = howmany)
4: seq(minval, maxval, length = howmany)
3: pretty_ticks(minlab, maxlab, 2, ...)
2: draw.scale(y = 0.8 * chr.length[[chrom]] + 0.2 * xylims[3], minval = margin, 
       maxval = maxGeneCount, minlab = annot1_plot_range[1], maxlab = annot1_plot_range[2], 
       lwd = 4, col = colAnnot1, cex = cex, title = scale.title)
1: chromPlot::chromPlot(gaps)

I have emailed the maintainer of the package Karen Orostica with a link to this post.

llrs
  • 4,693
  • 1
  • 18
  • 42
Biomagician
  • 2,459
  • 16
  • 30
  • 1
    I think the error occurs because the start should be 1 or more and not zero. I think the BED format should be 1 based (now it is 0 based). – benn Jun 27 '18 at 14:16
  • I've updated my question. I don't think this is the problem based on my experimenting with a 1 start. – Biomagician Jun 27 '18 at 14:22
  • Maybe Chrom needs to be sorted, in your example after Chrom 1-4, comes 6 not 5. I am just guessing here. – benn Jun 27 '18 at 14:27
  • 1
    It seems more like it tries to do something like seq(NULL, to = 50). If the data is valid, it is a bug on the package. Create an issue as required by the maintainer of the package adding the traceback to see the origin of the error. – llrs Jun 27 '18 at 14:27
  • Sorting does not make a difference. I have sent an email to the maintainer Karen Orostica. – Biomagician Jun 27 '18 at 14:33
  • Are you sure C. elegans has 7 chromosomes? According to ensembl it has only 5 and X. – benn Jun 27 '18 at 14:52
  • mitochondrial "chromosome", for my own business I consider the mitochondrial genome like a chromosome but I concede it's technically wrong.
  • – Biomagician Jun 27 '18 at 14:54
  • also chromPlot didn't like my character names, but one problem at a time. – Biomagician Jun 27 '18 at 14:56
  • I was wondering if that may cause the error. Does it work if you only use the first 4 lines of your df? I mean do you still get the error? – benn Jun 27 '18 at 14:59
  • The code works with the first two lines of the data frame but fails if I run it one the first three lines. – Biomagician Jun 27 '18 at 15:08
  • This gave me an idea. If I change the chromosome 3 length to 16000000, it works, suggesting it's not allowed to be shorter than the previous chromosome? But ordering by end base did not help. – Biomagician Jun 27 '18 at 15:09
  • 1
    oooouh, but ordering by end base and removing the mitochondrial genome worked! still not an ideal situation. I wonder if I'm using it wrong or if there is a bug. – Biomagician Jun 27 '18 at 15:14
  • @charlesdarwin Maybe that could be written as an answer, just so future reader know how to solve/avoid this problem – llrs Jun 28 '18 at 07:25
  • @Llopis unfortunately, I could not reproduce it but I've got an alternative that I'll put as an answer. – Biomagician Jun 28 '18 at 13:21