I already told you. Was there something unclear about my response?
I successfully ran LD pruning from SNPRelate package and obtained the selected SNPs IDs. I would like to create a new GDS file with only the pruned SNPs so I can use it in another software. Codes:
#read in vcf file
vcf.fn <- ""C:/Users/HP/Desktop/Magic_FavoritePanel_VCF_SNPs.vcf"
# reformat to create gds file
snpgdsVCF2GDS(vcf.fn, "panelReformat.gds", method="biallelic.only")
snpgdsSummary("panelReformat.gds")
#open the GDS file
genofile <- snpgdsOpen("panelReformat.gds")
#Perfom LD-based SNP pruning
set.seed(1000)
snpset <- snpgdsLDpruning(genofile, ld.threshold=0.2)
names(snpset)
# Final output, get all selected snp id
snpset.id <- unlist(snpset)
Now, snpset.id is not a complete dataset; how do I extract from the original GDS file only the data set related to the selected SNP IDs and save it as GDS file? With this, I can play with the data in many ways; I can convert it back to VCF and analyze it in Tassel or STRUCTURE.
Thank you in advance
2 answers
You want createDataFile from GWASTools. Ideally you wouldn't do that though - it takes forever to create a new GDS file, and the whole idea for GWASTools is to have one GDS file on disk and things like snpgdsLDpruning simply create filters that affect what gets read in, rather than changing the structure of the on-disk data file.
Thank you James for the response; My problem is only if I want to use the output of LD pruning in a different software, like STRUCTURE (to perform population structure analysis using LD pruned SNPs), how do I save that data subset?
Log in to answer this question.
You could subset your VCF
C:/Users/HP/Desktop/Magic_FavoritePanel_VCF_SNPs.vcfto the SNPs you store insnpset.idand then create the GDS again if you don't want to follow what James suggested.