Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

rarefaction for first quartile?

Open
#76 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
r
Domain
data

Research direction

Start by reproducing the reported workflow with mp_cal_rarecurve(), as.MPSE(), and mp_plot_rarecurve() using the supplied Abundance and Observe arguments. Trace where the plotting entry point selects the assay column, then confirm that first-quartile rarefaction and the downstream rarefaction curve work without the reported missing-column error.

Written by the indexing model from the issue text.

Description

I want to rarefy my samples to the first quartile.
i don't understand how mp_cal_rarecurve() works with this?

mouse.time.mpse %<>% 
    mp_cal_rarecurve(
        .abundance = RareAbundance,
        chunks = 400
    )

I tried to do the rarefaction before converting my phyloseq to mpse but I could not go futher the downstream analysis from there as I get an error

summary(sample_sums(ps.prev))
ps.prev.rare <- rarefy_even_depth(ps.prev, sample.size = 3501, rngseed = 50)
  Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
    641    3501   20304   52969   68311  321517 
`set.seed(50)` was used to initialize repeatable random subsampling.
Please record this for your records so others can reproduce.
Try `set.seed(50); .Random.seed` for the full vector
...
32 samples removedbecause they contained fewer reads than `sample.size`.
Up to first five removed samples are: 

M-T1-Rep4M-T5-Rep2M-T5-Rep3M-T5-Rep4M-T5-Rep6
...
2025OTUs were removed because they are no longer 
present in any sample after random subsampling
mpse.rare <- ps.prev.rare %>% as.MPSE()
mpse.rare %>% print(width=180)
# A MPSE-tibble (MPSE object) abstraction: 286,732 × 20
# OTU=2956 | Samples=97 | Assays=Abundance | Taxonomy=Kingdom, Phylum, Class, Order,
#   Family, Genus, Species
   OTU   Sample      Abundance sample.name sample.no Sample.x Phase Region Regime
   <chr> <chr>           <dbl> <chr>           <int> <fct>    <fct> <fct>  <fct> 
 1 ASV1  feed-M-Rep1         6 M1                170 feed     feed  feed   M     
 2 ASV3  feed-M-Rep1       424 M1                170 feed     feed  feed   M     
 3 ASV5  feed-M-Rep1         0 M1                170 feed     feed  feed   M     
 4 ASV6  feed-M-Rep1         0 M1                170 feed     feed  feed   M     
 5 ASV7  feed-M-Rep1         0 M1                170 feed     feed  feed   M     
 6 ASV8  feed-M-Rep1         0 M1                170 feed     feed  feed   M     
 7 ASV9  feed-M-Rep1         0 M1                170 feed     feed  feed   M     
 8 ASV10 feed-M-Rep1         0 M1                170 feed     feed  feed   M     
 9 ASV11 feed-M-Rep1         0 M1                170 feed     feed  feed   M     
10 ASV12 feed-M-Rep1         0 M1                170 feed     feed  feed   M     
   Sample_Regime sample_regime sample sample_or_control Kingdom    
   <fct>         <chr>         <chr>  <chr>             <chr>      
 1 feed.M        feed.M        feed   sample            k__Bacteria
 2 feed.M        feed.M        feed   sample            k__Bacteria
 3 feed.M        feed.M        feed   sample            k__Bacteria
 4 feed.M        feed.M        feed   sample            k__Bacteria
 5 feed.M        feed.M        feed   sample            k__Bacteria
 6 feed.M        feed.M        feed   sample            k__Bacteria
 7 feed.M        feed.M        feed   sample            k__Bacteria
 8 feed.M        feed.M        feed   sample            k__Bacteria
 9 feed.M        feed.M        feed   sample            k__Bacteria
10 feed.M        feed.M        feed   sample            k__Bacteria
   Phylum               Class                  Order               Family Genus Species
   <chr>                <chr>                  <chr>               <chr>  <chr> <chr>  
 1 p__Firmicutes        c__Clostridia          o__Oscillospirales  f__Ru… g__u… s__un_…
 2 p__Firmicutes        c__Bacilli             o__Lactobacillales  f__La… g__L… s__un_…
 3 p__Proteobacteria    c__Alphaproteobacteria o__Rhodobacterales  f__Rh… g__P… s__un_…
 4 p__Proteobacteria    c__Gammaproteobacteria o__Aeromonadales    f__Ae… g__A… s__un_…
 5 p__Bacteroidota      c__Bacteroidia         o__Cytophagales     f__Sp… g__A… s__un_…
 6 p__Proteobacteria    c__Gammaproteobacteria o__Burkholderiales  f__Co… g__P… s__un_…
 7 p__Verrucomicrobiota c__Verrucomicrobiae    o__Verrucomicrobia… f__Ru… g__L… s__un_…
 8 p__Proteobacteria    c__Alphaproteobacteria o__Rhodobacterales  f__Rh… g__R… s__un_…
 9 p__Proteobacteria    c__Gammaproteobacteria o__Enterobacterales f__En… g__E… s__un_…
10 p__Proteobacteria    c__Gammaproteobacteria o__Burkholderiales  f__Su… g__A… s__un_…
# … with 286,722 more rows
# ℹ Use `print(n = ...)` to see more rows

mpse.rare %>% 
      mp_plot_rarecurve(
         .rare = Abundance, 
         .alpha = Observe,
      )
Error in `dplyr::select()`:
! Can't subset columns that don't exist.
✖ Column `Abundance` doesn't exist.
Backtrace:
 1. mpse.rare %>% ...
 8. dplyr:::select.data.frame(., !!rlang::sym("Sample"), !!.rare)
 Error in dplyr::select(., !!rlang::sym("Sample"), !!.rare) :
Dominant language
R
Stars
195
Forks
36
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from YuLab-SMU/MicrobiotaProcess

All issues in YuLab-SMU/MicrobiotaProcess

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.