You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何去除SNP rsid名称中的芯片分析冗余信息(Plink二进制格式)

Got it, let's fix those messy SNP IDs in your Plink binary dataset. Here are two solid approaches to strip away the chip-specific prefixes (like GSA-, psy-) and suffixes (like _CNV_SULT1A3) and get back clean rsNUMBER format IDs:

Plink 1.9+ has a powerful --set-all-var-ids flag that lets you use regex substitutions to rewrite SNP IDs. This method ensures you don't mess up the structure of your binary files (.bed/.bim/.fam), which is crucial for downstream analyses.

Run this command, replacing your_dataset with your actual file prefix and cleaned_dataset with your desired output prefix:

plink --bfile your_dataset --set-all-var-ids '@{s/.*(rs\d+).*/$1/}' --make-bed --out cleaned_dataset

What this does:

  • The regex .*(rs\d+).* matches any string that contains rs followed by numbers, capturing just the rsNUMBER part.
  • The substitution replaces the full messy ID with the captured rsNUMBER segment.
  • --make-bed generates a new set of clean binary files, leaving your original data untouched (always a good practice!).

Method 2: Directly Edit the .bim File (Fast, Manual Control)

Since the .bim file is plain text (each line's second column is the SNP ID), you can use a command-line text editor like sed to batch-clean the IDs in place.

First, backup your original .bim file (critical in case of typos!):

cp your_dataset.bim your_dataset.bim.backup

Then run this sed command to clean the IDs:

sed -i 's/.*\(rs[0-9]\+\).*/\1/' your_dataset.bim

What this does:

  • -i tells sed to edit the file in place.
  • The regex targets any string containing rs followed by digits, replacing the entire ID with just the rsNUMBER portion.
  • This is faster than re-generating the binary files, but only modify the .bim file—never touch the .bed or .fam files directly!

Quick Validation

After either method, check a few lines of the cleaned .bim file to confirm the IDs are fixed:

head cleaned_dataset.bim  # For Method 1
# OR
head your_dataset.bim     # For Method 2

You should see only rsNUMBER entries in the second column now.

内容的提问来源于stack exchange,提问作者Inken

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 22:17:51