This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Edit Column sex in ped file

I want to edit my column sex in ped file and place in numbers 2 and 1 instead of F and M . How do I do this Linux?

plink linux

Despite Individual ID Paternal ID Maternal ID- how to build Family ID?

           yes

1 answer

awk '{OFS="\t";if($5=="M") {$5="1";} else if($5=="F") {$5="2";} else {$5="0";}print;}' in.ped > out.ped

The output file as follows: It seems that is wrong

SNP Chip    ID  Animal  0   Paternal
R950E03 111006  930226  910008  0   Resistant
R950E06 110917  950085  910043  0   Resistant
R950C09 110892  950085  910125  0   Resistant
R949B05 111101  870141  840409  0   Resistant

I assumed that the sex is in column $5 and there is no header:

$ echo "FAM ID FATHER MOTHER M" | awk '{OFS="\t";if($5=="M") {$5="1";} else if($5=="F") {$5="2";} else {$5="0";}print;}'
FAM ID  FATHER  MOTHER  1

Log in to answer this question.