# Too many samples discarded

**URL:** <https://forum.biobakery.org/t/too-many-samples-discarded/5051>\
**Category:** StrainPhlAn\
**Created:** [March 29, 2023, 8:15pm UTC](https://forum.biobakery.org/t/too-many-samples-discarded/5051 "2023-03-29T20:15:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ange](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/ange/32/2067_2.png) [@ange](https://forum.biobakery.org/u/ange)\
**Post date:** [March 29, 2023, 8:15pm UTC](https://forum.biobakery.org/t/too-many-samples-discarded/5051/1 "2023-03-29T20:15:53Z")

</div>

Sorry, I realize this has been asked a few times for strainphlan, but I have the same problem and I could not understand which part it’s having error in. I use the most lenient settings for sample and marker threshold but it still keeps throwing this error message. I base my clade\_markers of choice from metaphlan results so I am expecting these markers to be present in at least a quarter of my samples.

When I do --print-clades-only it doesn’t return me any clade either.

Command:

```auto
strainphlan -s ${WORKDIR}/consensus_markers/*.pkl \
-m ${WORKDIR}/db_markers/${sgb}.fna \
-o ${WORKDIR}/output \
-n 8 \
-d ${WORKDIR}/metaphlan-db \
--tmp ${WORKDIR}/temporary \
--debug --marker_in_n_samples 1 \ 
--sample_with_n_markers 1 \
-c ${sgb} \
--abs_n_markers_thres \
--abs_n_samples_thres \
--breadth_thres 80 \
--mutation_rates

```

Log:

```auto
Wed Mar 29 21:44:51 2023: Start StrainPhlAn 4.0.6 execution
Wed Mar 29 21:44:51 2023: Creating temporary directory...
Wed Mar 29 21:44:51 2023: Done.
Wed Mar 29 21:44:51 2023: Filtering markers and samples...
Wed Mar 29 21:44:51 2023: Getting markers from main samples...
Wed Mar 29 21:44:51 2023: Done.
Wed Mar 29 21:44:51 2023: Getting markers from main references...
Wed Mar 29 21:44:51 2023: Done.
Wed Mar 29 21:44:51 2023: Removing bad markers / samples...

```

Error message:

```auto
Wed Mar 29 21:44:51 2023: [Error] Phylogeny can not be inferred. Too many samples were discarded.Wed Mar 29 21:44:51 2023: Stop StrainPhlAn execution.

```

Tmp output:

```auto
 |-tmp1ijb_u1t
 | |-t__SGBxxxx.fna
 | |-blastn

```

Is there a way to know at least if this is a problem of the quality of my sequences (so more upstream) or if it’s something fixable in the parameters (so downstream) ? The range of size of the .pkl of my generated consensus\_markers are 5.5 MB - 28.1 MB.

Thank you!

---

<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:** [March 30, 2023, 12:31pm UTC](https://forum.biobakery.org/t/too-many-samples-discarded/5051/2 "2023-03-30T12:31:05Z")

</div>

Hi @ange  
Were the clade markers manually generated by you or with the extract\_markers.py script?

---

<div class="post-metadata">

**Author:** ![ange](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/ange/32/2067_2.png) [@ange](https://forum.biobakery.org/u/ange)\
**Post date:** [March 30, 2023, 12:35pm UTC](https://forum.biobakery.org/t/too-many-samples-discarded/5051/3 "2023-03-30T12:35:48Z")

</div>

Hi,

The clade markers were generated with extract\_markers.py

---

<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:** [March 30, 2023, 2:51pm UTC](https://forum.biobakery.org/t/too-many-samples-discarded/5051/4 "2023-03-30T14:51:16Z")

</div>

Did you run metaphlan with the database version Jan21 or Oct22 ? In version 4.0.6 Oct22 is the default database, so if you ran MetaPhlAn with the previous version it will lead to this kind of results

---

<div class="post-metadata">

**Author:** ![ange](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/ange/32/2067_2.png) [@ange](https://forum.biobakery.org/u/ange)\
**Post date:** [March 30, 2023, 3:07pm UTC](https://forum.biobakery.org/t/too-many-samples-discarded/5051/5 "2023-03-30T15:07:55Z")

</div>

Okay, thank you. It seems the metaphlan results we have were generated from vJan21. The analysis I’m trying out is based on these metaphlan results so I would rather adjust to accommodate the vJan21 data. Is there a way to download chocophlan vJan21 instead or an earlier version of strainphlan that supports vJan21?

---

<div class="post-metadata">

**Author:** ![ange](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/ange/32/2067_2.png) [@ange](https://forum.biobakery.org/u/ange)\
**Post date:** [March 30, 2023, 3:18pm UTC](https://forum.biobakery.org/t/too-many-samples-discarded/5051/6 "2023-03-30T15:18:17Z")

</div>

Whoops, I saw that it’s written in the documentation. I’ll download vJan21 and see. Thank you again!!

---

<div class="post-metadata">

**Author:** ![ange](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/ange/32/2067_2.png) [@ange](https://forum.biobakery.org/u/ange)\
**Post date:** [April 3, 2023, 10:20am UTC](https://forum.biobakery.org/t/too-many-samples-discarded/5051/7 "2023-04-03T10:20:08Z")

</div>

Sorry, it’s throwing a different error now- about an unsupported pickle protocol ?

Command:

```auto
strainphlan -s ${WORKDIR}/consensus_markers/*.pkl \
-r /dir/Shotgun/refseq-Acaccae_ncbi-genomes-2023-03-28/GCF_020181435.1_ASM2018143v1_genomic.fna \
-o ${WORKDIR}/output -n 8 \
-d /dir/scratch/metaphlan-db/mpa_vJan21_CHOCOPhlAnSGB_202103.pkl \
--tmp /dir/scratch/temporary/tmp \
--debug 
--marker_in_n_samples 10 \
--sample_with_n_markers 1 -c "t__SGB4529" \
--abs_n_markers_thres \
--abs_n_samples_thres \
--breadth_thres 80 \
--mutation_rates \
--print_clades_only

```

Log:

```auto
Mon Apr 3 12:08:29 2023: Start StrainPhlAn 4.0.6 execution
Mon Apr 3 12:08:29 2023: Loading MetaPhlAn mpa_vJan21_CHOCOPhlAnSGB_202103 database...
Mon Apr 3 12:08:50 2023: Done.
Mon Apr 3 12:08:53 2023: Detecting clades...

```

Error:

```auto
Traceback (most recent call last):
  File "/dir/anaconda3/envs/mph4/bin/strainphlan", line 8, in <module>
    sys.exit(main())
  File "/dir/anaconda3/envs/mph4/lib/python3.7/site-packages/metaphlan/strainphlan.py", line 624, in main
    strainphlan_runner.run_strainphlan()
  File "/dir/anaconda3/envs/mph4/lib/python3.7/site-packages/metaphlan/strainphlan.py", line 452, in run_strainphlan
    self.print_clades()
  File "/dir/anaconda3/envs/mph4/lib/python3.7/site-packages/metaphlan/strainphlan.py", line 370, in print_clades
    species2samples = self.detect_clades(markers2species)
  File "/dir/anaconda3/envs/mph4/lib/python3.7/site-packages/metaphlan/strainphlan.py", line 353, in detect_clades
    sample = ConsensusMarkers(pkl_file=sample_path)
  File "/dir/anaconda3/envs/mph4/lib/python3.7/site-packages/metaphlan/utils/consensus_markers.py", line 100, in __init__
    self.from_pkl(pkl_file)
  File "/dir/anaconda3/envs/mph4/lib/python3.7/site-packages/metaphlan/utils/consensus_markers.py", line 93, in from_pkl
    pkl_file)[1] == ".bz2" else pickle.load(open(pkl_file, "rb"))
ValueError: unsupported pickle protocol: 5

```

---

<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:** [April 5, 2023, 2:15pm UTC](https://forum.biobakery.org/t/too-many-samples-discarded/5051/8 "2023-04-05T14:15:04Z")

</div>

Hi @ange  
It looks like the sample2markers was run with python 3.8+ which generated the pkl files with protocol 5, while you were running the strainphlan with python version lower than 3.8 (in this case 3.7). I will update the python version to \>3.8 in the environment you are running strainphlan
