Question: Piping samtools output to picard
0
gravatar for Yaseen Ladak
3.3 years ago by
Yaseen Ladak20
United Kingdom, London, Imperial College London
Yaseen Ladak20 wrote:

Hi All,

I need some help I want to pipe the output from samtools to picard readgrous commands but I am failing:

bowtie2 -x bowtie2_index_hg38 -1 R1.fq.gz -2 R2.fq.gz | samtools view -Shb - | samtools sort - output

What I want to achieve is the following is to also add the read groups the output.bam file from above command and also index the output bam file with reads groups. I am failing with the following command and I dont know how to also index the output bam file that has the read group.

bowtie2 -x bowtie2_index_hg38 -1 mrg_sample_1_R1_val_1.fq -2 mrg_sample_1_R2_val_2.fq | samtools view -Shb - | samtools sort - - | picard AddOrReplaceReadGroups I= output.bam O=rg_output.bam RGID=sample_1 RGLB=sample_1 RGPL=illumina_hi-seq RGPU=sample_1 RGSM=sample_1

Can someone please help me?

Thanks,

Yaseen

ADD COMMENTlink modified 3.3 years ago • written 3.3 years ago by Yaseen Ladak20

Hello yaseen.ladak!

It appears that your post has been cross-posted to another site: Don't cross-post on here and the samtools mailing list.

This is typically not recommended as it runs the risk of annoying people in both communities.

ADD REPLYlink written 3.3 years ago by Devon Ryan88k

Hi Devon,

MY apologies I am very new to using these forums. I will keep in mind.

Thanks,

Yaseen

ADD REPLYlink written 3.3 years ago by Yaseen Ladak20

cross posted here too: http://gatkforums.broadinstitute.org/discussion/6471

ADD REPLYlink written 3.3 years ago by Pierre Lindenbaum118k

Hi Devon and every one,

Thank you very much. it works now. I will also keep in mind not to post in samtools and here as you mentioned. I am very new to this, I thought if someone would reply I will get an email. Is there a setting biostar if someone replies to my post I get an email?

Thanks,

Yaseen

ADD REPLYlink written 3.3 years ago by Yaseen Ladak20
0
gravatar for Devon Ryan
3.3 years ago by
Devon Ryan88k
Freiburg, Germany
Devon Ryan88k wrote:

My reply (it's apparently in moderation, not sure why) to the samtools list was:

You can add the read group directly in bowtie2:

bowtie2 -x bowtie2_index_hg38 --rg-id sample1 --rg SM:sample1 ... | samtools view -Su - | samtools sort - output

Picard's BuildBamIndex tool might be able to take input from a pipe (I'm pretty sure this doesn't work with samtools at the moment), in which case:

... | picard SortSam INPUT=/dev/stdin OUTPUT=/dev/stdout | tee output.bam | picard BuildBamIndex INPUT=/dev/stdin OUTPUT=output.bam.bai

Or something along those regards. I really can't recommend doing this, though. Getting the index in an additional step is going to be a minuscule time savings.

ADD COMMENTlink written 3.3 years ago by Devon Ryan88k
1

one picard cmd should be enough (not tested)

java -jar picard.jar SortSam CREATE_INDEX=true INPUT=/dev/stdin OUTPUT=output.bam SORT_ORDER=coordinate

ADD REPLYlink modified 3.3 years ago • written 3.3 years ago by Pierre Lindenbaum118k
1

and I hate the (non standard) way picard handles options.

ADD REPLYlink written 3.3 years ago by Pierre Lindenbaum118k

Ah, I thought I remembered a CREATE_INDEX option, but didn't see it in the documentation when I looked.

ADD REPLYlink written 3.3 years ago by Devon Ryan88k

it's defined in the 'general options' (with -H )

ADD REPLYlink written 3.3 years ago by Pierre Lindenbaum118k
0
gravatar for Yaseen Ladak
3.3 years ago by
Yaseen Ladak20
United Kingdom, London, Imperial College London
Yaseen Ladak20 wrote:

Sorry, just managed to change my setting in my profile about the email. My apologies, I should have looked better for this option in my profile setting. 

ADD COMMENTlink written 3.3 years ago by Yaseen Ladak20
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: 699 users visited in the last hour