Operation on GRanges Object
1
0
Entering edit mode
Haiying.Kong ▴ 110
@haiyingkong-9254
Last seen 5.0 years ago
Germany

*******************************************************************************************************************

I figured out, and tried to delete the post, but no option for deleting.

The answer is: rowRanges(all)@elementMetadata has all information on the right hand side of bar separation.

*******************************************************************************************************************

If I load a vcf file, and go to rowRanges slot:

> rowRanges(all)[2:5]

GRanges object with 4 ranges and 5 metadata columns:
              seqnames         ranges strand | paramRangeID            REF
                 <Rle>      <IRanges>  <Rle> |     <factor> <DNAStringSet>
  1:12783_G/A        1 [12783, 12783]      * |         <NA>              G
  1:13110_G/A        1 [13110, 13110]      * |         <NA>              G
  1:13116_T/G        1 [13116, 13116]      * |         <NA>              T
  1:13118_A/G        1 [13118, 13118]      * |         <NA>              A
                             ALT      QUAL      FILTER
              <DNAStringSetList> <numeric> <character>
  1:12783_G/A                  A     33.56           .
  1:13110_G/A                  A    103.15           .
  1:13116_T/G                  G   1681.37           .
  1:13118_A/G                  G   1591.21           .

 

  I would like to take the values in the slot "REF", but in fact, this is not a slot:

> getClass(class(all@rowRanges))
Class "GRanges" [package "GenomicRanges"]

Slots:

Name:         seqnames          ranges          strand elementMetadata
Class:             Rle         IRanges             Rle       DataFrame

Name:          seqinfo        metadata
Class:         Seqinfo            list

I can get the information with names(rowRanges(all)), but some names in this vector are already translated to "rs" numbers.

So I still need to get values for the columns REF and ALT. How?

 

> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: openSUSE 13.1 (Bottle) (x86_64)

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8
 [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats4    parallel  stats     graphics  grDevices utils     datasets
[8] methods   base

other attached packages:
 [1] VariantAnnotation_1.20.3   Rsamtools_1.26.2
 [3] Biostrings_2.42.1          XVector_0.14.1
 [5] SummarizedExperiment_1.4.0 Biobase_2.34.0
 [7] GenomicRanges_1.26.4       GenomeInfoDb_1.10.3
 [9] IRanges_2.8.2              S4Vectors_0.12.2
[11] BiocGenerics_0.20.0

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.10             AnnotationDbi_1.36.2     GenomicAlignments_1.10.1
 [4] zlibbioc_1.20.0          BiocParallel_1.8.2       BSgenome_1.42.0
 [7] lattice_0.20-35          tools_3.3.3              grid_3.3.3
[10] DBI_0.6-1                digest_0.6.12            Matrix_1.2-8
[13] rtracklayer_1.34.2       bitops_1.0-6             biomaRt_2.30.0
[16] RCurl_1.95-4.8           memoise_1.1.0            RSQLite_1.1-2
[19] GenomicFeatures_1.26.4   XML_3.98-1.6
bioconductor • 1.1k views
ADD COMMENT
0
Entering edit mode
@martin-morgan-1513
Last seen 5 days ago
United States

Don't use slot access, but instead use accessors. After running

example(readVcf)

there's an object vcf. I can access rowRanges(vcf), which is a 'GRanges' object. From the help page ?GRanges I find that I can access

mcols(rowRanges(vcf))

to retrieve a DataFrame, and then

mcols(rowRanges(vcf))$REF

or (also from ?GRanges) simply

rowRanges(vcf)$REF

From the main VariantAnnotation vignette or the help page ?VCF, I see that there's also a direct accessor

ref(vcf)
ADD COMMENT

Login before adding your answer.

Traffic: 1053 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6