Skip to content

expand() and non-standard rowRanges columns #85

@jayoung

Description

@jayoung

hi there,

is there a way to retain non-standard rowRanges columns when I use expand() on a CollapsedVCF object? Some demo code below.

If not, please can you consider this an enhancement request? thanks!

all the best,

Janet

library(VariantAnnotation)

vcf <- VCF(rowRanges = GRanges("chr1", IRanges(1:4*3, width=c(1, 2, 1, 1))))
alt(vcf) <- DNAStringSetList("A", c("TT"), c("G", "A"), c("TT", "C"))
ref(vcf) <- DNAStringSet(c("G", c("AA"), "T", "G"))

## add some non-standard columns to rowRanges
mcols(rowRanges(vcf))$SNP_name <- paste("SNP_", 1:length(vcf), sep="")
mcols(rowRanges(vcf))$num_alts <- elementNROWS(alt(vcf))

## take a look
rowRanges(vcf)

GRanges object with 4 ranges and 6 metadata columns:
      seqnames    ranges strand |    SNP_name  num_alts            REF                ALT      QUAL
         <Rle> <IRanges>  <Rle> | <character> <integer> <DNAStringSet> <DNAStringSetList> <numeric>
  [1]     chr1         3      * |       SNP_1         1              G                  A        NA
  [2]     chr1       6-7      * |       SNP_2         1             AA                 TT        NA
  [3]     chr1         9      * |       SNP_3         2              T                G,A        NA
  [4]     chr1        12      * |       SNP_4         2              G               TT,C        NA
           FILTER
      <character>
  [1]        <NA>
  [2]        <NA>
  [3]        <NA>
  [4]        <NA>
  -------
  seqinfo: 1 sequence from an unspecified genome; no seqlengths


## those extra columns are lost when we expand
vcfLong <- expand(vcf)
rowRanges(vcfLong)
rowRanges(vcfLong)

GRanges object with 6 ranges and 4 metadata columns:
      seqnames    ranges strand |            REF            ALT      QUAL      FILTER
         <Rle> <IRanges>  <Rle> | <DNAStringSet> <DNAStringSet> <numeric> <character>
  [1]     chr1         3      * |              G              A        NA        <NA>
  [2]     chr1       6-7      * |             AA             TT        NA        <NA>
  [3]     chr1         9      * |              T              G        NA        <NA>
  [4]     chr1         9      * |              T              A        NA        <NA>
  [5]     chr1        12      * |              G             TT        NA        <NA>
  [6]     chr1        12      * |              G              C        NA        <NA>
  -------
  seqinfo: 1 sequence from an unspecified genome; no seqlengths

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions