[Bioc-devel] GRanges to VRanges coercion
sandmann.thomas at gene.com
Thu Feb 19 21:46:05 CET 2015
Hi Valerie, hi Michael,
I find myself frequently moving back and forth between data.frames, GRanges
and VRanges objects.
The makeGRangesFromDataFrame function from the GenomicRanges makes the
coercion between the former straightforward, but I couldn't find anything
similar for the second step, coercsion from GRanges to VRanges.
There is a coercion method defined in the GenomicRanges package:
getMethod(coerce, c("GRanges", "VRanges"))
function (from, to = "VRanges", strict = TRUE)
obj <- new("VRanges")
as(obj, "GRanges") <- from
target "GRanges" "VRanges"
defined "GRanges" "VRanges"
but I haven't been able to get it to work (or find where it is documented).
The source code shown above doesn't indicate how the coercion method would
check for the presence of required / optional VRanges columns, e.g. 'ref',
'alt', 'altDepth', etc.
Would it be useful to add an explicit makeVRangesFromGRanges function to
the VariantAnnotation package ( and / or the corresponding coercion method)
Then it would be easy to go from a data.frame to a VRanges object, e.g. as
in this pseudocode:
makeGRangesFromDataFrame( data.frame )
You can find a first attempt at implementing the
here <https://gist.github.com/tomsing1/bf917b1b48afb952e1c5>, which you are
welcome to use / modify if you find it useful.
If this functionality should already be available, I'd be happy to learn
about that, too !
R version 3.1.2 (2014-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
attached base packages:
 stats4 parallel stats graphics grDevices utils datasets
other attached packages:
 VariantAnnotation_1.12.9 Rsamtools_1.18.2 Biostrings_2.34.1
 GenomeInfoDb_1.2.4 IRanges_2.0.1 S4Vectors_0.4.0
 roxygen2_4.1.0 devtools_1.7.0
loaded via a namespace (and not attached):
 AnnotationDbi_1.28.1 base64enc_0.1-2 BatchJobs_1.5
 BiocParallel_1.0.3 biomaRt_2.22.0 bitops_1.0-6
 checkmate_1.5.1 codetools_0.2-10 DBI_0.3.1
 foreach_1.4.2 GenomicAlignments_1.2.1 GenomicFeatures_1.18.3
 RCurl_1.95-4.5 RSQLite_1.0.0 rtracklayer_1.26.2
 tools_3.1.2 XML_3.98-1.1 zlibbioc_1.12.0
[[alternative HTML version deleted]]
More information about the Bioc-devel