Bioconductor / GenomicRanges

Representation and manipulation of genomic intervals
https://bioconductor.org/packages/GenomicRanges
43 stars 18 forks source link

Bug in makeGRangesFromDataFrame from empty data table #81

Closed gevro closed 11 months ago

gevro commented 11 months ago

Hi, Using GenomicRanges 1.46.1, I found a bug.

ignore.strand doesn't seem to work when applying it to an empty data table. See below for reproducible example.

Empty data table

blah <- data.table(chrom=character(),pos=numeric(),strand=factor())

makeGRangesFromDataFrame(blah,seqnames.field="chrom",start.field="pos",end.field="pos",ignore.strand=TRUE)

Error in stop_if_wrong_length("'seqnames'", ans_len) : 
  'seqnames' must have the length of the object to construct (1) or
  length 1

makeGRangesFromDataFrame(blah,seqnames.field="chrom",start.field="pos",end.field="pos",strand.field="strand")

GRanges object with 0 ranges and 0 metadata columns:
   seqnames    ranges strand
      <Rle> <IRanges>  <Rle>
  -------
  seqinfo: no sequences

NOT empty data table

blah <- data.table(chrom="chr1",pos=1,strand=factor("+"))

makeGRangesFromDataFrame(blah,seqnames.field="chrom",start.field="pos",end.field="pos",ignore.strand=TRUE)

GRanges object with 1 range and 0 metadata columns:
      seqnames    ranges strand
         <Rle> <IRanges>  <Rle>
  [1]     chr1         1      *
  -------
  seqinfo: 1 sequence from an unspecified genome; no seqlengths

makeGRangesFromDataFrame(blah,seqnames.field="chrom",start.field="pos",end.field="pos",strand.field="strand")

GRanges object with 1 range and 0 metadata columns:
      seqnames    ranges strand
         <Rle> <IRanges>  <Rle>
  [1]     chr1         1      +
  -------
  seqinfo: 1 sequence from an unspecified genome; no seqlengths
gevro commented 11 months ago

Thanks for fixing this! When will the new release be on bioconductor that incorporates this? (not urgent)

hpages commented 11 months ago

Thanks to @LiNk-NY for the PR (#82).

When will the new release be on bioconductor that incorporates this?

Not before Monday next week. Run BiocManager::install() on Monday and you should get the fix (granted that you're running BioC 3.18 which was released earlier this week, see https://bioconductor.org/news/bioc_3_18_release/).

Best