Question: Making pattern of GT:AD:DP:PL column values to be replaced by o and 1.
0
gravatar for S AR
5 months ago by
S AR50
Pakistan
S AR50 wrote:

Im trying to replace GT:AD:DP:GQ:PL values from all samples in a multi vcf file with 1.

My file looks like this:

Pos 6620    6734    6737    6742    6750    7151    7212    7362
Alt A   A   A   G   GC  A   T   G
ERR038741   0   1:1,213:214:99:7391,0   0   0   0   0   1:2,205:207:99:7078,0   1:0,191:191:99:7383,0
ERR040140   0   1:1,336:337:99:11415,0  0   0   0   0   0   0
ERR046796   0   1:4,180:184:99:5672,0   0   0   1:3,182:185:99:6609,0   0   0   0
ERR046903   0   1:1,170:171:99:6142,0   0   0   1:1,158:159:99:5954,0   0   0   0
ERR067581   0   1:0,86:86:99:3037,0 0   0   0   0   0   0
ERR067593   0   1:0,90:90:99:3229,0 0   0   0   0   0   0
ERR067606   0   1:0,65:65:99:2267,0 0   0   0   0   1:0,58:58:99:1971,0 1:0,62:62:99:2353,0
ERR067607   0   1:0,73:73:99:2593,0 0   0   0   0   0   0
ERR067608   0   1:0,70:70:99:2390,0 0   0   0   0   0   0
ERR067609   0   1:0,80:80:99:2826,0 0   0   0   0   1:0,75:75:99:2574,0 1:1,82:83:99:3049,0

I want the "1:0,73:73:99:2311,0: type of text to be replaced with 1. I m able to pick the pattern but how to replace it with one. The grep command for pattern matching is:

grep "1:0,.*" susc_ml_combine.vcf

Now how to replace it? can any one help please.

ADD COMMENTlink modified 5 months ago by Kevin Blighe61k • written 5 months ago by S AR50

Did you try using awk?

ADD REPLYlink written 5 months ago by Susmita Mandal60

i tried gsub from R but it didnt work.

As well i tried:

ex -s -c '%1:1,.*/1/g|x' file.vcf
ADD REPLYlink modified 5 months ago • written 5 months ago by S AR50
0
gravatar for Kevin Blighe
5 months ago by
Kevin Blighe61k
University College London
Kevin Blighe61k wrote:

Just use sed on your command line:

cat temp 
Pos 6620    6734    6737    6742    6750    7151    7212    7362
Alt A   A   A   G   GC  A   T   G
ERR038741   0   1:1,213:214:99:7391,0   0   0   0   0   1:2,205:207:99:7078,0   1:0,191:191:99:7383,0
ERR040140   0   1:1,336:337:99:11415,0  0   0   0   0   0   0
ERR046796   0   1:4,180:184:99:5672,0   0   0   1:3,182:185:99:6609,0   0   0   0
ERR046903   0   1:1,170:171:99:6142,0   0   0   1:1,158:159:99:5954,0   0   0   0
ERR067581   0   1:0,86:86:99:3037,0 0   0   0   0   0   0
ERR067593   0   1:0,90:90:99:3229,0 0   0   0   0   0   0
ERR067606   0   1:0,65:65:99:2267,0 0   0   0   0   1:0,58:58:99:1971,0 1:0,62:62:99:2353,0
ERR067607   0   1:0,73:73:99:2593,0 0   0   0   0   0   0
ERR067608   0   1:0,70:70:99:2390,0 0   0   0   0   0   0
ERR067609   0   1:0,80:80:99:2826,0 0   0   0   0   1:0,75:75:99:2574,0 1:1,82:83:99:3049,0


sed 's/ \+/\t/g' temp | sed 's/1:0,[0-9\\:\\,]*/1/g'
Pos 6620    6734    6737    6742    6750    7151    7212    7362
Alt A   A   A   G   GC  A   T   G
ERR038741   0   1:1,213:214:99:7391,0   0   0   0   0   1:2,205:207:99:7078,0   1
ERR040140   0   1:1,336:337:99:11415,0  0   0   0   0   0   0
ERR046796   0   1:4,180:184:99:5672,0   0   0   1:3,182:185:99:6609,0   0   0   0
ERR046903   0   1:1,170:171:99:6142,0   0   0   1:1,158:159:99:5954,0   0   0   0
ERR067581   0   1   0   0   0   0   0   0
ERR067593   0   1   0   0   0   0   0   0
ERR067606   0   1   0   0   0   0   1   1
ERR067607   0   1   0   0   0   0   0   0
ERR067608   0   1   0   0   0   0   0   0
ERR067609   0   1   0   0   0   0   1   1:1,82:83:99:3049,0
ADD COMMENTlink written 5 months ago by Kevin Blighe61k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 783 users visited in the last hour