how to save file on local disk after applying predictCoding() function?
1
0
Entering edit mode
@anastasiya-terskih-6815
Last seen 10.1 years ago
Russian Federation

Hello! Could you help me please.

I work with vcf file:

> vcf <- readVcf("test.vcf.gz", "hg19")

Then I use  predictCoding() to get information about nucleotide substitutions and output looks like this:

> coding <- predictCoding(vcf_mod, txdb, Hsapiens)
> coding[5:7]

GRanges with 3 ranges and 17 metadata columns:
  1:865692_C/G     chr1 [865692, 865692]      + |         <NA>              

I'd like to save this file on local disk (I mean coding).How can I do it?

Thank you!

 

vcf predict coding save file VariantAnnotation • 1.7k views
ADD COMMENT
3
Entering edit mode
@thomas-sandmann-6817
Last seen 14 months ago
USA

For the record, here are a few lines from the predictCoding man page that generate the GRanges object you asked about.

library(VariantAnnotation)
library(BSgenome.Hsapiens.UCSC.hg19)
library(TxDb.Hsapiens.UCSC.hg19.knownGene)

txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene
fl <- system.file("extdata", "chr22.vcf.gz", package="VariantAnnotation")
vcf <- readVcf(fl, "hg19")

## Rename seqlevels in the VCF object to match those in the TxDb.
vcf <- renameSeqlevels(vcf, "chr22")
coding <- predictCoding(vcf, txdb, Hsapiens)

You can save the GRanges object either as a binary Rdata file e.g.

save( coding, file="output.RData" )

and reload it with the load function.

Alternatively, you can export your results in a text (e.g. csv) file, e.g. after converting the GRanges object to a data.frame

df <- as.data.frame( coding, "data.frame", row.names = NULL)
write.csv(df, file="output.csv")

 

ADD COMMENT
1
Entering edit mode

With devel rtracklayer, you can:

file <- exportToTabix(coding, "output.txt")

This is stored and indexed in a manner that is efficient for restricted range queries:

coding_chr1 <- import(file, which=GRanges("chr1", IRanges(1e6, 2e6)))

 

ADD REPLY
0
Entering edit mode

Thank you very much!)

ADD REPLY

Login before adding your answer.

Traffic: 471 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