Saving the output of LD pruning from SNPRelate package as a new GDS file
2
0
Entering edit mode
14 months ago
Patrick • 0

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

LD-pruning SNPRelate • 854 views
ADD COMMENT
0
Entering edit mode

You could subset your VCF C:/Users/HP/Desktop/Magic_FavoritePanel_VCF_SNPs.vcf to the SNPs you store in snpset.id and then create the GDS again if you don't want to follow what James suggested.

ADD REPLY
0
Entering edit mode
14 months ago

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.

ADD COMMENT
0
Entering edit mode
14 months ago
Patrick • 0

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?

ADD COMMENT
0
Entering edit mode

I already told you. Was there something unclear about my response?

ADD REPLY

Login before adding your answer.

Traffic: 1321 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6