774646878
x <- 'HMGB1,PELI1,PTPN22,PTPN22,PTPN22,PTPN22,WDFY1,MCMDC2,SPO11,SPO11,SPO11,SPO11,SPO11,SPO11'
x_tb <- table(strsplit(x, ',')[[1]])
paste0(names(x_tb), ifelse(x_tb > 1, paste0('(', x_tb, ')'), ''), collapse = ',')
#> [1] "HMGB1,MCMDC2,PELI1,PTPN22(4),SPO11(6),WDFY1"