I'm having some problems in exporting the annotations of some variants from a VCF file, after using the "VariantAnnotation" package from bioconductor. Below the script I've used:
#!/usr/bin/env Rscript
library(VariantAnnotation)
library(BSgenome.Scerevisiae.UCSC.sacCer3)
library(TxDb.Scerevisiae.UCSC.sacCer3.sgdGene)
args = commandArgs(trailingOnly=TRUE)
vcf <- readVcf(args[1], "sacCer3")
sc <- BSgenome.Scerevisiae.UCSC.sacCer3
txdb <- TxDb.Scerevisiae.UCSC.sacCer3.sgdGene
coding <- data.frame(predictCoding(vcf, txdb, seqSource=sc))
The coding
dataframe looks like this:
seqnames start end width strand paramRangeID REF ALT QUAL FILTER
1 chrI 455 455 1 + <NA> C T 40 PASS
2 chrI 455 455 1 + <NA> C 40 PASS
3 chrI 455 455 1 + <NA> C G 40 PASS
4 chrI 455 455 1 + <NA> C A 40 PASS
5 chrI 456 456 1 + <NA> T A 40 PASS
6 chrI 456 456 1 + <NA> C CCTGCTC 40 PASS
varAllele CDSLOC.start CDSLOC.end CDSLOC.width PROTEINLOC QUERYID TXID CDSID
1 T 121 121 1 41 1 1 1
2 121 121 1 41 2 1 1
3 G 121 121 1 41 3 1 1
4 A 121 121 1 41 4 1 1
5 A 122 122 1 41 5 1 1
6 CCTGCTC 122 122 1 41 6 1 1
GENEID CONSEQUENCE REFCODON VARCODON REFAA VARAA
1 YAL069W nonsynonymous CTC TTC L F
2 YAL069W not translated CTC TC
3 YAL069W nonsynonymous CTC GTC L V
4 YAL069W nonsynonymous CTC ATC L I
5 YAL069W nonsynonymous CTC CAC L H
6 YAL069W nonsynonymous CTC CCCTGCTCC L PCS
But if I try to save it to file, for instance using the following command:
write.table(coding, 'test.tsv', sep='\t', row.names=F)
The output table looks like this:
"seqnames" "start" "end" "width" "strand" "paramRangeID" "REF" "ALT" "QUAL" "FILTER" "varAllele" "CDSLOC.start" "CDSLOC.end" "CDSLOC.width" "PROTEINLOC" "QUERYID" "TXID" "CDSID" "GENEID" "CONSEQUENCE" "REFCODON" "VARCODON" "REFAA" "VARAA"
"chrI" 455 455 1 "+" NA "C" <S4 object of class "DNAStringSet"> 40 "PASS" "T" 121 121 1 41 1 "1" 1 "YAL069W" "nonsynonymous" "CTC" "TTC" "L" "F"
"chrI" 455 455 1 "+" NA "C" <S4 object of class "DNAStringSet"> 40 "PASS" "" 121 121 1 41 2 "1" 1 "YAL069W" "not translated" "CTC" "TC" "" ""
Notice the <S4 object of class "DNAStringSet">
bit. Is there any way to force R to give me the same representation as head
? I couldn't find anything in Biostrings' documentation.