# Lefse analysis in R

**URL:** <https://forum.biobakery.org/t/lefse-analysis-in-r/595>\
**Category:** LEfSe\
**Created:** [June 18, 2020, 12:45pm UTC](https://forum.biobakery.org/t/lefse-analysis-in-r/595 "2020-06-18T12:45:25Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![yiluheihei](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/yiluheihei/32/416_2.png) [@yiluheihei](https://forum.biobakery.org/u/yiluheihei)\
**Post date:** [June 18, 2020, 12:45pm UTC](https://forum.biobakery.org/t/lefse-analysis-in-r/595/1 "2020-06-18T12:45:25Z")

</div>

Hi, there

I’m developing a R package for microbiome marker discovery named [microbiomeMarker](https://github.com/yiluheihei/microbiomeMarker), and the algorithm from lefse has been integrated to this package.

You can try it out today, if you want run lefse analysis in R. **microbiomeMarker** is still a newborn, so there may be bugs.

Thanks. Any suggestions and contribution will be highly appreciated.

---

<div class="post-metadata">

**Author:** ![sma](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@sma](https://forum.biobakery.org/u/sma)\
**Post date:** [June 26, 2020, 4:19pm UTC](https://forum.biobakery.org/t/lefse-analysis-in-r/595/2 "2020-06-26T16:19:41Z")

</div>

Hi -  
Thanks for the interests and for the package! If you have any LEfSe related questions, please feel free to let us know. If you are interested in additional microbial biomarker testing methods, the group also has the [MaAsLin2](https://huttenhower.sph.harvard.edu/maaslin/) method with functionalities such as random effects for longitudinal designs, etc.  
Best,  
Siyuan

---

<div class="post-metadata">

**Author:** ![tank415](https://avatars.discourse-cdn.com/v4/letter/t/c5a1d2/32.png) [@tank415](https://forum.biobakery.org/u/tank415)\
**Post date:** [September 28, 2020, 3:44am UTC](https://forum.biobakery.org/t/lefse-analysis-in-r/595/3 "2020-09-28T03:44:26Z")

</div>

Thanks for sharing~~~  
may i ask some questions?

1. format of otu table should be .txt files? .CSV files? or others?
2. i get OTU table from “CLC” software
3. i upload .csv file and run analyze --\> show the code" Error: `ps` must be phyloseq object "  
i do not know how to solve it!! Thanks

---

<div class="post-metadata">

**Author:** ![Kelsey\_Thompson](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/kelsey_thompson/32/65_2.png) [@Kelsey\_Thompson](https://forum.biobakery.org/u/Kelsey_Thompson)\
**Post date:** [October 2, 2020, 3:57pm UTC](https://forum.biobakery.org/t/lefse-analysis-in-r/595/4 "2020-10-02T15:57:10Z")

</div>

Hi there,

Thanks for your interest! If you would like to use one of the BioBakery tools we would recommend the use of MaAsLin2([https://github.com/biobakery/maaslin2](https://github.com/biobakery/maaslin2)). If you have questions about the microbiomeMarker R package we would suggest directing your questions to the developer at [https://github.com/yiluheihei/microbiomeMarker](https://github.com/yiluheihei/microbiomeMarker).

Best!  
Kelsey

---

<div class="post-metadata">

**Author:** ![yiluheihei](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/yiluheihei/32/416_2.png) [@yiluheihei](https://forum.biobakery.org/u/yiluheihei)\
**Post date:** [October 9, 2020, 12:49am UTC](https://forum.biobakery.org/t/lefse-analysis-in-r/595/5 "2020-10-09T00:49:08Z")

</div>

The main input of **microbioMarker** must be in `phyloseq` object, which means you must convert your otu table to phyloseq. As Kelsey\_Thompson said, if you have questions about the microbiomeMarker R package, you can direct you questions at [https://github.com/yiluheihei/microbiomeMarker](https://github.com/yiluheihei/microbiomeMarker).

Thanks for you interest.

---

<div class="post-metadata">

**Author:** ![X\_Morgan](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/x_morgan/32/681_2.png) [@X\_Morgan](https://forum.biobakery.org/u/X_Morgan)\
**Post date:** [March 21, 2021, 10:46pm UTC](https://forum.biobakery.org/t/lefse-analysis-in-r/595/6 "2021-03-21T22:46:41Z")

</div>

Ying Taur has written a very nice phyloseq object to Lefse R add-on.

> **[ying14/yingtools2](https://github.com/ying14/yingtools2)**
>
> Ying's tools for analysis, with particular focus on microbiome data

> **[lefse: LEfSe in ying14/yingtools2: Ying's R Tools](https://rdrr.io/github/ying14/yingtools2/man/lefse.html)**
>
> Run LEfSe (LDA Effect Size) analysis using a phyloseq object.

An R implementation of lefse is also available from the Waldron lab:

> **[waldronlab/lefser](https://github.com/waldronlab/lefser)**
>
> R implementation of the LEfSe method. Contribute to waldronlab/lefser development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![fconstancias](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/fconstancias/32/190_2.png) [@fconstancias](https://forum.biobakery.org/u/fconstancias)\
**Post date:** [March 22, 2021, 4:47pm UTC](https://forum.biobakery.org/t/lefse-analysis-in-r/595/7 "2021-03-22T16:47:35Z")

</div>

Unfortunately, there are quite some limitations and if I am not wrong **lefser** and **microbioMarker** only supports two-group contrasts.

> Note. `lefser` supports only two-group contrasts.

---

<div class="post-metadata">

**Author:** ![yiluheihei](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/yiluheihei/32/416_2.png) [@yiluheihei](https://forum.biobakery.org/u/yiluheihei)\
**Post date:** [March 30, 2021, 3:46pm UTC](https://forum.biobakery.org/t/lefse-analysis-in-r/595/8 "2021-03-30T15:46:43Z")

</div>

[yingtools2](https://github.com/ying14/yingtools2) perform lefse analysis by calling the python script. [lefser](https://github.com/waldronlab/lefser) has very limited functionality. [microbiomeMarker](https://github.com/yiluheihei/microbiomeMarker) almost achieved all features of the original python lefse, of course, includs multiple-group constrasts. Moreover, some other common differential analysis methods are also integrated into **microbiomeMarker** , e.g. deseq2, metagenomeSeq.

---

<div class="post-metadata">

**Author:** ![Palliko](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/palliko/32/1818_2.png) [@Palliko](https://forum.biobakery.org/u/Palliko)\
**Post date:** [December 5, 2022, 9:12pm UTC](https://forum.biobakery.org/t/lefse-analysis-in-r/595/9 "2022-12-05T21:12:19Z")

</div>

Hi @yiluheihei ,

I want to do the compositional analysis for my data  
My study approach is 2 x 2 factorial design i.e 2 genetic lines and 2 efficiencies ( for example, E line high and low, Z line high and low efficiency). I want to see the interaction of 2 genetic lines with the month as a random effect. Is there any way I can do the compositional analysis?  
could you suggest to me which package and approach would be appropriate for my study

thanks

---

<div class="post-metadata">

**Author:** ![Sourav\_Dutta](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/sourav_dutta/32/1939_2.png) [@Sourav\_Dutta](https://forum.biobakery.org/u/Sourav_Dutta)\
**Post date:** [February 9, 2023, 9:51am UTC](https://forum.biobakery.org/t/lefse-analysis-in-r/595/10 "2023-02-09T09:51:29Z")

</div>

Hi @yiluheihei,  
I am getting one error in microbiomemarker package.

I have used this commands -  
mm\_lefse ← run\_lefse(  
ps,  
taxa\_rank = “Genus”,  
norm = “rarefy”,  
group = “bodysite”,  
subgroup = “genotype”  
)

plot\_cladogram(mm\_lefse, color = c(“brown”,“blue”,“red”,“green”))

Error coming:  
Error in if (n \<= length(x)) { : missing value where TRUE/FALSE needed

I have also brought this issue in the microbiomeMarker github page.

Please help!

thanks,
