This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Changing RSids in plink

Hi, I am trying to change the way my RSids are written in one .bim file to match another file so I can use the --extract flag. Currently the RSids are written as "rs569167217_60684_A_C" and I need them to only be in the form of "rs569167217". Is there a way to remove the extra part of each RSid in plink? Thank you for any help with this!

snp

1 answer

You can use one of two ways in unix/linux:

  1. create a new bim file and replace your bim file with the new one
awk -F "_" '{print $1,$2,$3,$4}' your_bim_file.bim | awk -F " " '{print $1,$2,$6,$7,$8,$9}' > new_rs_bim_file.bim 
  1. create plink --update-name file with two columns like "rs569167217_60684_A_C rs569167217"
awk -F "_" '{print $1,$2,$3,$4}' test.txt | awk -F " " '{print $2,$2 "_" $3 "_" $4 "_" $5}' > update_name.txt

then use plink to update short rs names:

plink --bfile our_plink_file --update-name update_name.txt --make-bed --out new plink_file

Log in to answer this question.