Created
June 10, 2021 21:19
-
-
Save zx8754/09937029a3a9366112fce90e2f41556e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# About ------------------------------------------------------------------- | |
# 10/06/2021 | |
# | |
# Reference: https://www.biostars.org/p/9474813/ | |
# | |
# input: BIM filname | |
# Note: This script will overwrite the existing input bim file | |
# | |
# example run: | |
# Rscript makeSNPnamesUnique.R myBimFile.bim | |
# Input arguments --------------------------------------------------------- | |
args <- commandArgs(trailingOnly = TRUE) | |
fileBim <- args[1] | |
# Data -------------------------------------------------------------------- | |
bim <- read.table(fileBim, header = FALSE, stringsAsFactors = FALSE) | |
# make unique names | |
bim$V2 <- | |
make.unique( | |
ifelse(bim$V2 == ".", | |
paste(bim$V1, bim$V4, bim$V5, bim$V6, sep = "_"), | |
bim$V2), | |
sep = "_") | |
# Output ------------------------------------------------------------------ | |
write.table(bim, file = fileBim, | |
col.names = FALSE, row.names = FALSE, quote = FALSE, | |
sep = "\t") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment