Question: unwanted linebreaks using write.table with a dataframe created via the myvariant.info r package
0
gravatar for Icke Blanco
9 months ago by
Icke Blanco0 wrote:

I have a problem using the myvariant.info r package (https://bioconductor.org/packages/release/bioc/html/myvariant.html) or more by using the write.table command, I always get unwanted linebreaks in my output.tsv using write.table with a dataframe created via the myvariant.info r package.

This is my code:

>     filepath.input <- file.path("PATH","TO", "YOUR","VCF","FILE.vcf")
>     vcf <- readVcf(filepath.input, "hg19")
>     myvcf <- formatHgvs(vcf, c("snp", "insertion", "deletion"))
>     myvariants1 <- getVariants (c(myvcf), 
>                                 fields=c("civic.evidence_items.evidence_type",
>                                          "civic.evidence_items.evidence_direction", 
>                                          "civic.evidence_items.evidence_level", 
>                                          "civic.evidence_items.drugs.name",
>                                          "civic.evidence_items.disease.name"))
>     filepath.output <-  file.path("PATH","TO", "YOUR", "OUTPUT","DIR")
>     output.tsv = file.path(filepath.output, "myannotatedvariants.tsv")
>     write.table(data.frame(myvariants1), output.tsv, sep = "\t", col.names = NA, qmethod = "double")

This is my output:

> myvariants1
DataFrame with 1 row and 4 columns
                query                X_id        civic._license
          <character>         <character>           <character>
1 chr1:g.115258745C>G chr1:g.115258745C>G https://goo.gl/gPCAyH
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   civic.evidence_items
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 <list>
1 list(drugs = list(list(name = "Cetuximab"), list(name = "Vemurafenib"), list(name = "Vemurafenib"), list(name = "NVP BEZ235"), list(name = "AZD 6244"), list(name = "NVP BEZ235"), list(name = "AZD 6244"), list(name = "AZD 6244"), list(name = "NVP BEZ235")), evidence_direction = c("Supports", "Supports", "Supports", "Supports", "Supports", "Supports", "Supports", "Supports", "Supports"), evidence_level = c("C", "C", "C", "C", "C", "C", "C", "D", "D"), evidence_type = c("Predictive", "Predictive", "Predictive", \n"Predictive", "Predictive", "Predictive", "Predictive", "Predictive", "Predictive"), disease.name = c("Colorectal Cancer", "Melanoma", "Melanoma", "Colorectal Cancer", "Colorectal Cancer", "Colorectal Cancer", "Colorectal Cancer", "Colorectal Cancer", "Colorectal Cancer"))

I tried to delete the " , \n" in " \n"Predictive"" via

gsub(", \n", ",", myvariants1)

but this giving me a: Error in as.vector(x, mode = "character") : no method for coercing this S4 class to a vector

All my trials with as.matrix etc did not work out:( Can someone help me out?

ADD COMMENTlink modified 9 months ago by shepherl ♦♦ 1.6k • written 9 months ago by Icke Blanco0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 415 users visited in the last hour