I have an imputed dosage for chr 22 file. its content is:
#[1]CHROM [2]POS [3]REF [4]ALT [5]HG00096_HG00096 [6]HG00097_HG00097 [7]HG00099_HG00099 [8]HG00100_HG00100
22 16051249 T C 0.0 1.0 1.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0
I want to remove []
and remove anything coming after _
from this file as well as instead of separate 22
16051249
T
and C
i want to write:
22_16051249_T_C_b37
So the final file should look like:
Id HG00096 HG00097 HG00099 HG00100
22_16051249_T_C_b37 0 1 1 0 1 0 0 1 0
Can anyone please help me out with this.
sed -e 's/[[^][]*]//g'
And for adding the 22_1605149_T_C I did this:awk '{ID=$1""$2" "$3""$4" " +b37; print ID}' genotype.chr22_1.txt > genotype.chr22_2.txt
But it just gives me a separate file with these values and not want I want. I tried to join the columns using R but it doesn't generate a separate column. the command used is:genotype_chr22_1$ID <- paste(genotype_chr22_1$CHROM, genotype_chr22_1$POS,genotype_chr22_1$REF, genotype_chr22_1$ALT, sep = "_")
$\endgroup$Id
. On the second line, you have 8 columns, and like the previous, I can understand it will become22_16051249_T_C_b37
. But what about the third line? And how is that in your final file, the first line has 5 columns while the second line has more? $\endgroup$