# How does sub.sample function works

**URL:** <https://forum.mothur.org/t/how-does-sub-sample-function-works/22323>\
**Category:** Commands in mothur\
**Created:** [May 1, 2025, 9:39pm UTC](https://forum.mothur.org/t/how-does-sub-sample-function-works/22323 "2025-05-01T21:39:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![EllistonV](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.mothur.org/ellistonv/32/333_2.png) [@EllistonV](https://forum.mothur.org/u/EllistonV)\
**Post date:** [May 1, 2025, 9:39pm UTC](https://forum.mothur.org/t/how-does-sub-sample-function-works/22323/1 "2025-05-01T21:39:55Z")

</div>

Hello,

I just want to know how the sub.sample() function works. How does the function determines how many sequences to remove from each OTU/ASV? does it remove more sequences from larger ASVs; is there a ratio kept between ASVs, is the relative abundance of each ASV affected? Are low abundance ASVs eliminated (I see that some singletons, doubletons are eliminated)? Thanks for your help!

Regards,  
Elliston

---

<div class="post-metadata">

**Author:** ![pschloss](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.mothur.org/pschloss/32/4_2.png) [@pschloss](https://forum.mothur.org/u/pschloss)\
**Post date:** [May 5, 2025, 1:25pm UTC](https://forum.mothur.org/t/how-does-sub-sample-function-works/22323/2 "2025-05-05T13:25:06Z")

</div>

Hi - it randomly grabs the specified number of sequences from each sample. It does it empirically more abundant OTUs will be sampled more often than rarer ones. If a sample has a lot more sequences than the desired threshold it will remove more rare OTUs from the sample. If a sample has fewer than the desired threshold of sequences that sample will be removed. if you don’t give it a threshold then it will use the size of the smallest sample. This function will only do one sampling of each sample. Using dist.shared and summary.shared gives the option of doing many subsamplings and then reporting the average of the alpha or beta diversity metric over those subsamplings.

Pat

---

<div class="post-metadata">

**Author:** ![EllistonV](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.mothur.org/ellistonv/32/333_2.png) [@EllistonV](https://forum.mothur.org/u/EllistonV)\
**Post date:** [May 6, 2025, 3:15pm UTC](https://forum.mothur.org/t/how-does-sub-sample-function-works/22323/3 "2025-05-06T15:15:30Z")

</div>

Oh, okay! This makes a lot of sense. Thank you very much!

---

<div class="post-metadata">

**Author:** ![EllistonV](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.mothur.org/ellistonv/32/333_2.png) [@EllistonV](https://forum.mothur.org/u/EllistonV)\
**Post date:** [May 6, 2025, 9:06pm UTC](https://forum.mothur.org/t/how-does-sub-sample-function-works/22323/4 "2025-05-06T21:06:23Z")

</div>

Also, the sub.sample function would not be the same as rarefying the data, correct? Or is it the same?

---

<div class="post-metadata">

**Author:** ![pschloss](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.mothur.org/pschloss/32/4_2.png) [@pschloss](https://forum.mothur.org/u/pschloss)\
**Post date:** [May 8, 2025, 8:00pm UTC](https://forum.mothur.org/t/how-does-sub-sample-function-works/22323/5 "2025-05-08T20:00:56Z")

</div>

sub.sample outputs a shared file, the rarefaction commands output other file formats. subsampling is effectively rarefaction with a single randomization

Pat

---

<div class="post-metadata">

**Author:** ![EllistonV](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.mothur.org/ellistonv/32/333_2.png) [@EllistonV](https://forum.mothur.org/u/EllistonV)\
**Post date:** [May 10, 2025, 5:49am UTC](https://forum.mothur.org/t/how-does-sub-sample-function-works/22323/6 "2025-05-10T05:49:56Z")

</div>

Alright, thank you very much!

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.mothur.org/system/32/2_2.png) [@system](https://forum.mothur.org/u/system)\
**Post date:** [May 20, 2025, 5:50am UTC](https://forum.mothur.org/t/how-does-sub-sample-function-works/22323/7 "2025-05-20T05:50:24Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
