Piping samtools output to picard
1
1
Entering edit mode
8.4 years ago
Yaseen Ladak ▴ 30

Hi All,

I need some help I want to pipe the output from samtools to picard read group 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 don't 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

next-gen-sequencing alignment • 5.1k views
ADD COMMENT
0
Entering edit mode

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 REPLY
0
Entering edit mode

Hi Devon,

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

Thanks,

Yaseen

ADD REPLY
0
Entering edit mode
ADD REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode
8.4 years ago

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 COMMENT
1
Entering edit mode

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 REPLY
1
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 2859 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6