Hi everyone, I am trying to use the R package KaryotypeR to produce rainfall plots in R for germline mutations. For this aim I use the code I found here: VCF input for KaryotypeR But I get an error:
Error in .Call2("solve_user_SEW0", start, end, width, PACKAGE = "IRanges") :
solving row 1: range cannot be determined from the supplied arguments (too many NAs)
In addition: Warning message:
In toGRanges(tmp.vcf.data) : NAs introduced by coercion
What can be done to fix this ?
Thanks for your help.
1 answer
Hi @ma23,
You have a few problems with your code, starting by the fact that you are reading the data twice and grepping for "#CHROM" and the header line starts with "CHROM" without hash, so it won't detect it.
Basically, if you have a headerless vcf and only want to create a GRanges to plot the variants in a rainfall plot you can use this much shorter and simpler code (note that we are repeating column 2 to have "start" and "end" as required by toGRanges)
> vcf.data <- read.table("file.vcf", header=TRUE)
> vars <- toGRanges(vcf.data[,c(1,2,2,4,5)])
> vars
GRanges object with 3 ranges and 2 metadata columns:
seqnames ranges strand | REF ALT
<Rle> <IRanges> <Rle> | <factor> <factor>
[1] chr10 75185 * | A AT
[2] chr10 209747 * | TTCTTTA T
[3] chr10 225362 * | G GTGTT
-------
seqinfo: 1 sequence from an unspecified genome; no seqlengths
Another option would be to read the VCF file without removing the header using the functions in the VariantAnnotation package. If you need more information on that second option I can give you a few hints.
Hope this helps
Bernat
Log in to answer this question.
Hi @ma23
Can you show us a few lines of the VCF? and the exact code you are using?
Here is the exact code:
And here are three first lines:
Please highlight code with the formatting bar:
Great, this works much better. Thank you for your help!