Entering edit mode
3.5 years ago
rheab1230
▴
140
I am running a R script to update vcf file with rsid of snp file.I am getting error.
Error in `$<-.data.frame`(`*tmp*`, variant_id, value = "snp__") :
replacement has 1 row, data has 0
Calls: $<- -> $<-.data.frame
Execution halted
Can anyone please help me with this?
Hi, this is not reproducible. Both code and data are missing. Please provide it with a minimum working example.
What the script does is it takes rsid from snp file and put that in ID coloumn in vcf file.
Thanks for showing the code; however, this doesn't help due to the fact that we cannot have certainty which line produces the error. You have neither provided any test input data; so, we cannot run the code in its entirety.
Please tell us which line produces the error. Also show the output of
str()
run on the objects that are used in the command that produces the error.This is the line that is showing the error: snp_ref$variant_id<-paste("snp_",snp_ref$CHROM, "_", snp_ref$POS, sep="")
I am not able to attach the input data file. Can you please tell me how to attach the input file?
I see, what is the output of
str(snp_ref)
just before you run that line of code?Oh, your object is a weird format..
spec_tbl_df
... please change it to a data frame viadata.frame(snp_ref)
Okay, I will do that
I have one more question. When I am mapping vcf file and dbsnp file so that vcf file can contain rsid, my vcf file size is getting reduced.
That makes sense. Please view the VCF via
bcftools view my.vcf | more
, and then you'll observe why (not all of your variants will have an rs ID).The dbSNP file is a file coming from the UCSC Genome Browser that would have a list of all the known SNPs with their rsid. The GEUVADIS .vcf files I used were older and did not have an appropriate rsid in the ID column of that file. So I made a script to update .vcf file to assign them an appropriate modern rsid. However, the record count had dropped by a lot from the original .vcf file. Basically SNPs are getting lost from the .vcf file when merged with the dbSNP file.
It could be variants in GEUVADIS that have no known dbSNP rs ID, I suppose