rusher321 / microbiotaPair

An R Package for Simplified Microbiome Analysis Workflows on Intervention Study
6 stars 2 forks source link

Error in plot_ordination #3

Open cpavloud opened 3 months ago

cpavloud commented 3 months ago

Hello,

I am using R version 4.1.1 and microbiotaPair version 0.0.2

I am trying to run the example data(physeq_data) physeq <- physeq_data ord.res <- microbiotaPair::ordination(physeq, method = "NMDS", grouping_column = "Stage") Up to here, everything seems ok.

But when I run microbiotaPair::plot_ordination(ord.res, method = "PCoA", grouping_column = "Stage", PID = "ID")

I get the error

Error in h(simpleError(msg, call)) : error in evaluating the argument 'object' in selecting a method for function 'sample_data': argument "phylores" is missing, with no default

Do you have any idea how to solve it?

rusher321 commented 3 months ago

Hi, I just try the example the code about ordination on the example directory, it works. Maybe you can try the example PMV.Rmd and test if it work in your environment. Addition, about the error messeaga, it seems your phylores object didn't have sample data. You also can test 'sample_data(ord.res)' if work.

Best

cpavloud commented 3 months ago

The phyloseq object I am using is the one of the package, it's not mine. I ran exactly what I saw here.

rusher321 commented 3 months ago

emmm, here miss a parameter. you can add phylores like below, I guess it work. plot_ordination(ord.res, phylores = physeq, method = "PCoA", grouping_column = "Stage", PID = "ID")

Best

cpavloud commented 3 months ago

Still there seems to be something wrong. I get a figure but when I run microbiotaPair::plot_ordination(ord.res, phylores = physeq, method = "PCoA", grouping_column = "Stage", PID = "Stage") However the PCoA axes are "PCoA1 (NA%)" and "PCoA2 (NA%)" and I get the warning message Warning message: In is.na(x) : is.na() applied to non-(list or vector) of type 'language' PCOA

When I run I get the exact same figure, I get the same warning message. This time the axes are "NMDS1" and "NMDS2" and the stress value does not fit on the plot, so it is cut off. NMDS

rusher321 commented 3 months ago

keep the consistent between the parameter method of ordiantion and plot_ordination, the figure will be OK

 data(physeq_data)
 physeq <- physeq_data
 ord.res <- ordination(physeq, method="PCoA", grouping_column="Stage")
 plot_ordination(ord.res, physeq, method="PCoA", grouping_column="Stage", PID="ID")

image

As for the cutoff of stress , you can zoom the plot or save it as a pdf file image

best