# MetaPhlAn 4 for paired end reads of multiple samples

**URL:** <https://forum.biobakery.org/t/metaphlan-4-for-paired-end-reads-of-multiple-samples/4242>\
**Category:** MetaPhlAn\
**Created:** [October 14, 2022, 12:41pm UTC](https://forum.biobakery.org/t/metaphlan-4-for-paired-end-reads-of-multiple-samples/4242 "2022-10-14T12:41:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anbu\_arun](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/anbu_arun/32/1725_2.png) [@anbu\_arun](https://forum.biobakery.org/u/anbu_arun)\
**Post date:** [October 14, 2022, 12:41pm UTC](https://forum.biobakery.org/t/metaphlan-4-for-paired-end-reads-of-multiple-samples/4242/1 "2022-10-14T12:41:20Z")

</div>

Hi,  
I am new to the MetaPhlan microbial community profiling. I have dataset of shotgun metagenomic raw reads for 62 samples, i.e., 124 paired end reads. I would like to run all the samples together in MetaPhlan 4. I will run it on remote server. Please help me in this regard.

---

<div class="post-metadata">

**Author:** ![aitor.blancomiguez](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/aitor.blancomiguez/32/86_2.png) [@aitor.blancomiguez](https://forum.biobakery.org/u/aitor.blancomiguez)\
**Post date:** [October 18, 2022, 11:52am UTC](https://forum.biobakery.org/t/metaphlan-4-for-paired-end-reads-of-multiple-samples/4242/2 "2022-10-18T11:52:51Z")

</div>

Hi @anbu_arun  
Please, have a look to the MetaPhlAn 4 tutorial [MetaPhlAn 4 · biobakery/MetaPhlAn Wiki · GitHub](https://github.com/biobakery/MetaPhlAn/wiki/MetaPhlAn-4) and documentation [MetaPhlAn 4 · biobakery/MetaPhlAn Wiki · GitHub](https://github.com/biobakery/MetaPhlAn/wiki/MetaPhlAn-4)

---

<div class="post-metadata">

**Author:** ![Julian-marchesi](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/julian-marchesi/32/2307_2.png) [@Julian-marchesi](https://forum.biobakery.org/u/Julian-marchesi)\
**Post date:** [July 22, 2023, 4:03pm UTC](https://forum.biobakery.org/t/metaphlan-4-for-paired-end-reads-of-multiple-samples/4242/3 "2023-07-22T16:03:14Z")

</div>

Hi

Does anyone know how to loop this for paired end reads, I can run them using

for i in \*.fastq.gz ; do metaphlan $i --input\_type fastq --nproc 14 -s sams/${i%}.sam.bz2 --bowtie2out bowtie2/${i%}.bowtie2.bz2 -o profiles/${i%}\_profiled.tsv ; done

but this does not take into account that I have paired-end reads, this treats each fastq.gz file as single sample.

---

<div class="post-metadata">

**Author:** ![aitor.blancomiguez](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/aitor.blancomiguez/32/86_2.png) [@aitor.blancomiguez](https://forum.biobakery.org/u/aitor.blancomiguez)\
**Post date:** [July 28, 2023, 2:09pm UTC](https://forum.biobakery.org/t/metaphlan-4-for-paired-end-reads-of-multiple-samples/4242/4 "2023-07-28T14:09:09Z")

</div>

If your paired-end files are named in a “\_1.fastq.gz” “\_2.fastq.gz” like way, you could run the following:

`for i in *_1.fastq.gz ; do metaphlan $i,${i/_1.fastq.bz2/_2.fastq.bz2} --input_type fastq --nproc 14 -s sams/${i%}.sam.bz2 --bowtie2out bowtie2/${i%}.bowtie2.bz2 -o profiles/${i%}_profiled.tsv ; done`

---

<div class="post-metadata">

**Author:** ![Julian-marchesi](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/julian-marchesi/32/2307_2.png) [@Julian-marchesi](https://forum.biobakery.org/u/Julian-marchesi)\
**Post date:** [August 30, 2023, 5:26pm UTC](https://forum.biobakery.org/t/metaphlan-4-for-paired-end-reads-of-multiple-samples/4242/5 "2023-08-30T17:26:50Z")

</div>

> [@aitor.blancomiguez](#):
>
> for i in \*\_1.fastq.gz ; do metaphlan $i,${i/\_1.fastq.bz2/\_2.fastq.bz2} --input\_type fastq --nproc 14 -s sams/${i%}.sam.bz2 --bowtie2out bowtie2/${i%}.bowtie2.bz2 -o profiles/${i%}\_profiled.tsv ; done

many thanks - Julian M
