Merge duplicates

= Merge Duplicates = file.txt: chr2_234271662	UGT1A10 chr2_234271662	UGT1A6 chr2_234271662	UGT1A7 chr2_234271662	UGT1A8 chr2_234271662	UGT1A9 chr22_34291439	APOL3 chr22_34803299 chr22_34830845 chr22_35009004	APOL3 chr22_35009004	MYH9 chr2_235047496

code cat file.txt | sort | awk 'BEGIN{FS = "\t";getline}{s[$1]=s[$1]","$2} END{for(val in s) {print val"\t"substr(s[val],2)} }'

out: chr2_234271662	UGT1A10,UGT1A6,UGT1A7,UGT1A8,UGT1A9 chr22_34291439	APOL3 chr22_34803299 chr22_34830845 chr22_35009004	APOL3,MYH9 chr2_235047496