Question: How To Delete Some Rgs From One Bam File
0
gravatar for wu.zhiqiang.1020
5.7 years ago by
United States
wu.zhiqiang.102020 wrote:

Dear all, Before I only one sample in my analysis, but when I merge the bam file from different lane, I used the different RG. Just like the following:

@RG ID:Ptrem PL:ILLUMINA LB:Ptrem SM:Ptrem

@RG ID:PtPE14c PL:ILLUMINA LB:PtPE14c SM:PtPE14c

@RG ID:PtPE14d PL:ILLUMINA LB:PtPE14d SM:PtPE14d

@RG ID:PtPE15 PL:ILLUMINA LB:PtPE15 SM:PtPE15

@RG ID:PtPE16 PL:ILLUMINA LB:PtPE16 SM:PtPE16

@RG ID:PtPE1a PL:ILLUMINA LB:PtPE1a SM:PtPE1a

@RG ID:PtPE1a1 PL:ILLUMINA LB:PtPE1a1 SM:PtPE1a1

@RG ID:PtPE1a2 PL:ILLUMINA LB:PtPE1a2 SM:PtPE1a2

Now, I want to delete some RG from the BAM file. How could I do that? I just want to have onely one RG in the right BAM file.

• 2.5k views
ADD COMMENTlink modified 5.7 years ago by Pierre Lindenbaum120k • written 5.7 years ago by wu.zhiqiang.102020
1
gravatar for Irsan
5.7 years ago by
Irsan6.9k
Amsterdam
Irsan6.9k wrote:

picard tools addOrReplaceReadgroups

From the documentation:

Replaces all read groups in the INPUT file with a new read group and assigns all reads to this read group in the OUTPUT BAMVersion: 1.0

ADD COMMENTlink modified 5.7 years ago • written 5.7 years ago by Irsan6.9k
0
gravatar for wu.zhiqiang.1020
5.7 years ago by
United States
wu.zhiqiang.102020 wrote:

Hi Irsan, I used the command: java -Xmx10g -jar /usr/local/bin/picard-tools-1.66/AddOrReplaceReadGroups.jar \ INPUT=new.sort.reheadered3.bam \ OUTPUT=new.sort.RG.bam \ SORT_ORDER=coordinate \ RGID=Ptrem \ RGLB=Ptrem \ RGPL=illumina \ RGPU=C063JACXX.6 RGSM=Ptrem

But I got the error: [Sun Sep 22 13:16:52 CDT 2013] net.sf.picard.sam.AddOrReplaceReadGroups done. Elapsed time: 0.02 minutes. Runtime.totalMemory()=1519058944 FAQ: http://sourceforge.net/apps/mediawiki/picard/index.php?title=Main_Page Exception in thread "main" net.sf.samtools.SAMFormatException: SAM validation error: ERROR: Record 683, Read name HWI-ST261:1:28:18847:188777#ATCACG, RG ID on SAMRecord not found in header: Ptrem1

    at net.sf.samtools.SAMUtils.processValidationErrors(SAMUtils.java:448)

    at net.sf.samtools.BAMFileReader$BAMFileIterator.advance(BAMFileReader.java:506)

    at net.sf.samtools.BAMFileReader$BAMFileIterator.next(BAMFileReader.java:487)

    at net.sf.samtools.BAMFileReader$BAMFileIterator.next(BAMFileReader.java:446)

    at net.sf.samtools.SAMFileReader$AssertableIterator.next(SAMFileReader.java:641)

    at net.sf.samtools.SAMFileReader$AssertableIterator.next(SAMFileReader.java:619)

    at net.sf.picard.sam.AddOrReplaceReadGroups.doWork(AddOrReplaceReadGroups.java:91)

    at net.sf.picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:177)

    at net.sf.picard.cmdline.CommandLineProgram.instanceMainWithExit(CommandLineProgram.java:119)

    at net.sf.picard.sam.AddOrReplaceReadGroups.main(AddOrReplaceReadGroups.java:61)

What is the problem!

Thanks!

ZQ

ADD COMMENTlink written 5.7 years ago by wu.zhiqiang.102020
1

Hmm well just as the error message says, it seems there is a read with a read group ID that is not in your header. Maybe you can add VALIDATION_STRINGENCY=LENIENT (or even VALIDATION_STRINGENCY=SILENT) to your command to ignore the error and continue to replace the read group info

ADD REPLYlink modified 5.7 years ago • written 5.7 years ago by Irsan6.9k
0
gravatar for Pierre Lindenbaum
5.7 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum120k wrote:

I wrote a tool name samjs: you can filter a BAM using a javascript expression: https://github.com/lindenb/jvarkit#samjs-filtering-a-sambam-file-with-javascript

$ curl -s "ftp://ftp-trace.ncbi.nih.gov/1000genomes/ftp/phase1/data/HG00096/exome_alignment/HG00096.mapped.illumina.mosaik.GBR.exome.20110411.bam" |\
java -jar dist/samjs.jar SE='record.readGroup.id!="SRR081241" > result.bam
ADD COMMENTlink written 5.7 years ago by Pierre Lindenbaum120k
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: 1544 users visited in the last hour