adimitromanolakis / sim1000G

Simulation of rare and common variants based on 1000 genomes data
17 stars 1 forks source link

writeVCF #13

Open williambrandler opened 2 years ago

williambrandler commented 2 years ago

I am trying to write out simulated variants using 1000G and would like to write to VCF to feed into other tools. Is this option available / possible to implement?

gilibean commented 1 year ago

Hi. I have the same problem. I have written my own code to write a VCF resulting from the simulations:

indnr=SIM$individuals_generated varnr = 100 #write your own varnr formatvcf = vcf$vcf title="#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT" for(i in 1:indnr) title=paste(title,"\tind",i,sep='') title=paste(title,"\n",sep='')

varvcf = data.frame(matrix(nrow=varnr,ncol=indnr))

for(i in 1:varnr){ for(j in 1:indnr) { varvcf[i, j] = paste(SIM$gt1[j,i], "|",SIM$gt2[j,i],sep='') } }

newvcf = c(formatvcf,varvcf) cat("##fileformat=VCFv4.2 \n",file="test2.vcf") cat(title,sep='\t',file="test2.vcf",append=TRUE)

write.table(newvcf,file="test2.vcf",row.names=FALSE,col.names=FALSE,quote=FALSE,sep="\t",append=TRUE)