Question: Retrieve list of kept SNP's after LD pruning
gravatar for leeandroid
13 days ago by
leeandroid50 wrote:

Hi everyone!

I followed the SNPRelate package tutorial in order to filter a VCF by LD and finally pursued PCA. My problem is that by converting the VCF into GDS SNP's and Chromosomes ID's are also converted into a different nomenclature., a unique identifier for each sample., a unique identifier for each SNP.

How can I get the original SNP ID's that are kept after LD pruning?

Thanks in advance.


    cap.vcf <- "all_148.vcf"
    snpgdsVCF2GDS(cap.vcf, "cap.gds", method = "biallelic.only")

    genofile <- snpgdsOpen("cap.gds")

    pop_code <- scan("pop.txt", sep = "\t", what = list("pop.txt"))

    cap.LD <- snpgdsLDpruning(genofile, remove.monosnp = TRUE, ld.threshold = .1, maf = .1, missing.rate = 0.1, method = "composite", slide.max.bp = 500000, verbose = TRUE)

    snp_id_list <- unlist(cap.LD)
snprelate snp gds R vcf • 181 views
ADD COMMENTlink modified 10 days ago by zx87544.1k • written 13 days ago by leeandroid50

Thank you for adding the code.

A few things to note:

  • if the chromosomes in your VCF are labelled with a 'chr' prefix, then you should use ignore.chr.prefix = "chr" with the snpgdsVCF2GDS() function
  • SNPRelate retains both the row index of each variant and also the ID (presumably whatever was set in the VCF ID field). The documentation states: "the variable stores the original the row index of variants, and the variable stores the rs id". So, if you want to map back from the LD pruning object to the variant ID, then go by the row index.
  • for samples, I can only assume that they are taken from left to right as they appear in the VCF. You should run rigorous checks to confirm this by looking at variants in the GDS object and how they match up to your VCF
ADD REPLYlink written 10 days ago by Kevin Blighe17k

Thank you for replying, Kevin.

I was aware of the importance of chromosome nomenclature so I previously changed it to numeric values. Regarding variant ID's you're right. I was able to retrieve its original name by corresponding the row index in the snp_id_list to the row with the same index of the stored in the GDS file. (In this case sample name was not an issue, I copied it by mistake when I wrote the question. But, its stored the same way as the snps). Any of GDS fields can be checked by read.gdsn(index.gdsn(genofile, "field_name"))

Thank you!

ADD REPLYlink written 5 days ago by leeandroid50
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 970 users visited in the last hour