# Command for prepring species abundance table

**URL:** <https://forum.biobakery.org/t/command-for-prepring-species-abundance-table/549>\
**Category:** MetaPhlAn\
**Created:** [June 6, 2020, 2:24pm UTC](https://forum.biobakery.org/t/command-for-prepring-species-abundance-table/549 "2020-06-06T14:24:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![DEEPCHANDA7](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@DEEPCHANDA7](https://forum.biobakery.org/u/DEEPCHANDA7)\
**Post date:** [June 6, 2020, 2:24pm UTC](https://forum.biobakery.org/t/command-for-prepring-species-abundance-table/549/1 "2020-06-06T14:24:36Z")

</div>

Hi friends!!! @fbeghini  
I’m new in linux command and just curious to know whether this command (while preparing species abundance file)

> grep -E “(s\_\_)|(^ID)” merged\_abundance\_table.txt | grep -v “t\_\_” | sed ‘s/^.\*s\_\_//g’ \> merged\_abundance\_table\_species.txt

be replaced by the following command:

> grep “(^ID)|(s\_\_)” merged\_abundance\_table.txt | grep -v “t\_\_” | sed “s/.\*s\_\_//g” \> merged\_abundance\_table\_species.txt

Thanks,  
DC7

---

<div class="post-metadata">

**Author:** ![fbeghini](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/fbeghini/32/81_2.png) [@fbeghini](https://forum.biobakery.org/u/fbeghini)\
**Post date:** [June 8, 2020, 7:52am UTC](https://forum.biobakery.org/t/command-for-prepring-species-abundance-table/549/2 "2020-06-08T07:52:03Z")

</div>

`grep -E` allows the usage of extended regex with `grep`, including the usage of the pipe character. If you do not specify the `-E` option, `grep` will retrieve any lines.

---

<div class="post-metadata">

**Author:** ![DEEPCHANDA7](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@DEEPCHANDA7](https://forum.biobakery.org/u/DEEPCHANDA7)\
**Post date:** [June 8, 2020, 9:50am UTC](https://forum.biobakery.org/t/command-for-prepring-species-abundance-table/549/3 "2020-06-08T09:50:08Z")

</div>

Oh… I missed the ‘E’… Even if I add ‘E’ still there I’ve shuffled some characters. Like, removal of` '^'` after ‘`sed`’ and alterations of `'(^ID)'` and `'(s__)'`… Do you think the following two will result into same output?

My Command:

> grep -E “(^ID)|(s\_\_)” merged\_abundance\_table.txt | grep -v “t\_\_” | sed “s/.\*s\_\_//g” \> merged\_abundance\_table\_species.txt

Tutorial command:

> grep -E “(s\_\_)|(^ID)” merged\_abundance\_table.txt | grep -v “t\_\_” | sed ‘s/^.\*s\_\_//g’ \> merged\_abundance\_table\_species.txt

Thanks,  
DC7

---

<div class="post-metadata">

**Author:** ![fbeghini](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/fbeghini/32/81_2.png) [@fbeghini](https://forum.biobakery.org/u/fbeghini)\
**Post date:** [June 8, 2020, 11:37am UTC](https://forum.biobakery.org/t/command-for-prepring-species-abundance-table/549/4 "2020-06-08T11:37:50Z")

</div>

Shuffing (s\_\_) and (^ID) do not change the output, in both case grep will report the header and the species list in the same order.  
Removing the caret, in this case, will allow matching all the text present in all the columns and not just on the one which contains the start of the line.

---

<div class="post-metadata">

**Author:** ![DEEPCHANDA7](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@DEEPCHANDA7](https://forum.biobakery.org/u/DEEPCHANDA7)\
**Post date:** [June 8, 2020, 11:40am UTC](https://forum.biobakery.org/t/command-for-prepring-species-abundance-table/549/5 "2020-06-08T11:40:56Z")

</div>

Thanks a lot @fbeghini. one more thing…  
Somewhere I’ve seen that “–ncores” option doesn’t work when we use a zipped file (e.g. fastq.gz, .bz2, etc.). But I’ve used the “–ncores” option as “–ncores 16” and also got profile output. May there be any mistake in my profile output due to that “–ncores” option? Is the following considered a wrong command?

```
 metaphlan catenated.fastq.gz --input_type fastq --nproc 16 > catenated_profile.txt

```

`NOTE: I'm using MetaPhlAn 3.0`

---

<div class="post-metadata">

**Author:** ![fbeghini](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/fbeghini/32/81_2.png) [@fbeghini](https://forum.biobakery.org/u/fbeghini)\
**Post date:** [June 9, 2020, 11:09am UTC](https://forum.biobakery.org/t/command-for-prepring-species-abundance-table/549/6 "2020-06-09T11:09:21Z")

</div>

What do you mean with “–ncores” option doesn’t work ?

---

<div class="post-metadata">

**Author:** ![DEEPCHANDA7](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@DEEPCHANDA7](https://forum.biobakery.org/u/DEEPCHANDA7)\
**Post date:** [June 9, 2020, 1:32pm UTC](https://forum.biobakery.org/t/command-for-prepring-species-abundance-table/549/7 "2020-06-09T13:32:02Z")

</div>

I have found the following lines from [this link](https://bitbucket.org/nsegata/metaphlan/wiki/MetaPhlAn_Pipelines_Tutorial):  
`"Notice we are piping the fastq reads directly from the compressed archive to MetaPhlAn. When piping MetaPhlAn's internal parallelization option (--nproc option) can not be used. This is available when the input is a an uncompressed file."`

It means --nproc option will not work when we use a zipped file. But for my analysis I’ve used` --nproc` option as in following command and got profile output. So, do you think there may be any mistake in my output as i have used `--nproc` option with `zipped` input file?

```auto
metaphlan catenated.fastq.gz --input_type fastq --nproc 16 > catenated_profile.txt

```

`NOTE: I'm using MetaPhlAn 3.0`

Thanks and regards,  
DC7

---

<div class="post-metadata">

**Author:** ![fbeghini](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/fbeghini/32/81_2.png) [@fbeghini](https://forum.biobakery.org/u/fbeghini)\
**Post date:** [June 9, 2020, 1:49pm UTC](https://forum.biobakery.org/t/command-for-prepring-species-abundance-table/549/8 "2020-06-09T13:49:25Z")

</div>

The page you linked is the manual for MetaPhlAn 1, not MetaPhlAn 3.0. Starting from version 2, the parallelization works with both compressed and uncompressed input files.
