Filtering snps in ld with a given snp

30 views
Skip to first unread message

Peiyuan Zhu

unread,
Jul 6, 2025, 3:36:07 AMJul 6
to plink2-users
Does plink2 still support filtering snps in ld with a snp? If so, how to do it? 

I tried plink1.9. There's a line of my sample file that is -1 -1 0 NA and ld-snps stopped working. 

[zhupy@cedar1 zhupy]$ ./plink --bgen chromosome1 --sample chromosome1.sample --r2 --ld-snps rs2473375 --ld-window-kb 100 --ld-window 99999 --ld-window-r2 0.8 --out rs2473375_ld

PLINK v1.9.0-b.7.8 64-bit (15 Jun 2025)            cog-genomics.org/plink/1.9/

(C) 2005-2025 Shaun Purcell, Christopher Chang   GNU General Public License v3

Logging to rs2473375_ld.log.

Options in effect:

  --bgen chromosome1

  --ld-snps rs2473375

  --ld-window 99999

  --ld-window-kb 100

  --ld-window-r2 0.8

  --out rs2473375_ld

  --r2

  --sample chromosome1.sample


257825 MB RAM detected; reserving 128912 MB for main workspace.

Allocated 7258 MB successfully, after larger attempt(s) failed.

Error: Invalid sex code on line 5598 of .sample file.

Christopher Chang

unread,
Jul 6, 2025, 11:41:46 PMJul 6
to plink2-users
https://www.cog-genomics.org/plink/2.0/ld#r

No red text here; all the flags you're looking for have been implemented in plink2.

Peiyuan Zhu

unread,
Jul 6, 2025, 11:57:07 PMJul 6
to Christopher Chang, plink2-users

It looks like it's not working. Flags ('--ld-snp') and ('--ld-snp-list') are unrecognized. 




MacBookPro-2:data garyzhubc$ ./plink2 --bgen chromosome1 ref-first --sample chromosome1.sample --r2 --ld-snp rs2473375 --ld-window-kb 100 --ld-window 99999 --ld-window-r2 0.8 --out rs2473375_ld

PLINK v2.00a5.2 64-bit (11 Oct 2023)           www.cog-genomics.org/plink/2.0/

(C) 2005-2023 Shaun Purcell, Christopher Chang   GNU General Public License v3

Logging to rs2473375_ld.log.

Options in effect:

  --bgen chromosome1 ref-first

  --ld-snp rs2473375

  --ld-window 99999

  --ld-window-kb 100

  --ld-window-r2 0.8

  --out rs2473375_ld

  --r2

  --sample chromosome1.sample


Start time: Sun Jul  6 20:53:52 2025

Error: Unrecognized flag ('--ld-snp').

For more info, try "plink2 --help <flag name>" or "plink2 --help | more".

MacBookPro-2:data garyzhubc$ vim focus_snp.txt

MacBookPro-2:data garyzhubc$ ./plink2 --bgen chromosome1 ref-first \

>          --sample chromosome1.sample \

>          --r2 \

>          --ld-snp-list focus_snp.txt \

>          --ld-window-kb 100 \

>          --ld-window 99999 \

>          --ld-window-r2 0.8 \

>          --out rs2473375_ld

PLINK v2.00a5.2 64-bit (11 Oct 2023)           www.cog-genomics.org/plink/2.0/

(C) 2005-2023 Shaun Purcell, Christopher Chang   GNU General Public License v3

Logging to rs2473375_ld.log.

Options in effect:

  --bgen chromosome1 ref-first

  --ld-snp-list focus_snp.txt

  --ld-window 99999

  --ld-window-kb 100

  --ld-window-r2 0.8

  --out rs2473375_ld

  --r2

  --sample chromosome1.sample


Start time: Sun Jul  6 20:55:09 2025

Error: Unrecognized flag ('--ld-snp-list').

For more info, try "plink2 --help <flag name>" or "plink2 --help | more".

MacBookPro-2:data garyzhubc$ 



--
You received this message because you are subscribed to a topic in the Google Groups "plink2-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/plink2-users/E1BEJrFtrOY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to plink2-users...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/plink2-users/28357afd-3e73-44c8-8bf3-9ddebc0e0dc0n%40googlegroups.com.

Chris Chang

unread,
Jul 7, 2025, 6:00:55 AMJul 7
to Peiyuan Zhu, plink2-users
I said “all the flags have been implemented”, not “all the flags were already implemented in Oct 2023”.
Message has been deleted

Peiyuan Zhu

unread,
Jul 11, 2025, 9:01:39 AMJul 11
to plink2-users
Got it. I was using an older version of plink2. 

Now after updating to the latest version, this following line worked:

./plink2 --bgen chromosome1.bgen ref-first --sample chromosome1.sample --r2-unphased --ld-snps rs2473375 --ld-window-kb 100 --ld-window 99999 --ld-window-r2 0.8 --out rs2473375_ld 


Reply all
Reply to author
Forward
0 new messages