MicrobiotaProcess icon indicating copy to clipboard operation
MicrobiotaProcess copied to clipboard

fc.method = "compare_mean" can run but fc.method = "compare_median" can't run

Open shaodongyan opened this issue 2 years ago • 7 comments

mpse1 %>% mp_cal_abundance(.abundance=Abundance, force=TRUE, relative=FALSE) %>% mp_diff_analysis(.abundance=Abundance, force=TRUE, relative=FALSE, .group=group, filter.p="pvalue",p.adjust = "BH",fc.method = "compare_median")

can't run . mpse1 %>%

  • mp_cal_abundance(.abundance=Abundance, force=TRUE, relative=FALSE) %>%
  • mp_diff_analysis(.abundance=Abundance, force=TRUE, relative=FALSE, .group=group, filter.p="pvalue",p.adjust = "BH",fc.method = "compare_mean") can . Thanks,But I don't konw Why

shaodongyan avatar Jul 24 '22 07:07 shaodongyan

and why image is 1000%?

shaodongyan avatar Jul 24 '22 08:07 shaodongyan

mp_diff_analysis(.abundance=Abundance, force=TRUE, relative=FALSE means the Abundance (may be count in your data) not relative abundance will be test.

xiangpin avatar Jul 24 '22 09:07 xiangpin

mp_diff_analysis(.abundance=Abundance, force=TRUE, relative=FALSE means the Abundance (may be count in your data) not relative abundance will be test.

My data is metaphlan3 data .The Abundance is relative abundance,So I don;t think it is the reason why "fc.method = "compare_median" " can't make sense. Thank you, xiangpin. Could you tell me why? Thanks

shaodongyan avatar Jul 24 '22 09:07 shaodongyan

Please provide more information, I can not debug for you because you do not provide the reproducible analysis codes and data set. But, first please check the Abundance of mpse1 is relative abundance. You can just use compare_mean to identify which abundance of group is more. The compare_median will be deprecated in the next version.

mpse1 %>% mp_extract_assays(.abundance=Abundance) %>% colSums() %>% head()

xiangpin avatar Jul 24 '22 09:07 xiangpin

Please provide more information, I can not debug for you because you do not provide the reproducible analysis codes and data set. But, first please check the Abundance of mpse1 is relative abundance. You can just use compare_mean to identify which abundance of group is more. The compare_median will be deprecated in the next version.

mpse1 %>% mp_extract_assays(.abundance=Abundance) %>% colSums() %>% head()

C8-7d_remove_host_profile C8-77d_remove_host_profile C8-26d_remove_host_profile C8-175d_remove_host_profile 100.00001 100.00000 100.00001 99.93213 C8-140d_remove_host_profile C8-11d_remove_host_profile 99.91116 100.00000
Thank you! If The compare_median will be deprecated in the next version , I will use the deafult method. How I use the ggdiffbox() function in MPSE object? or how can i use other function to plot the similar plot such as ggdiffbox()? Thanks!

shaodongyan avatar Jul 24 '22 09:07 shaodongyan

or how can i use other function to plot the similar plot such as ggdiffbox()?

You can use the mp_plot_diff_boxplot of github version (remotes::install_github('YuLab-SMU/MicrobiotaProcess')) to do it

refer to the following codes

library(MicrobiotaProcess)
data(mouse.time.mpse)
mouse.time.mpse %<>%
  mp_rrarefy()
mouse.time.mpse
mouse.time.mpse %<>%
   mp_diff_analysis(.abundance=RareAbundance,
                   .group=time,
                   first.test.alpha=0.01,
                   action="add")
library(ggplot2)
p1 <- mouse.time.mpse %>%
          mp_plot_diff_boxplot(.group = time) %>%
          set_diff_boxplot_color(
           values = c("deepskyblue", "orange"),
           guide = guide_legend(title=NULL)
         )

p2 <- mouse.time.mpse %>%
         mp_plot_diff_boxplot(
           taxa.class = c(Genus, OTU),
           group.abun = TRUE,
           removeUnknown = TRUE,
         ) %>%
         set_diff_boxplot_color(
           values = c("deepskyblue", "orange"),
           guide = guide_legend(title=NULL)
         )

aplot::plot_list(p1, p2)

plot

xiangpin avatar Jul 29 '22 08:07 xiangpin

or how can i use other function to plot the similar plot such as ggdiffbox()?

You can use the mp_plot_diff_boxplot of github version (remotes::install_github('YuLab-SMU/MicrobiotaProcess')) to do it

refer to the following codes

library(MicrobiotaProcess)
data(mouse.time.mpse)
mouse.time.mpse %<>%
  mp_rrarefy()
mouse.time.mpse
mouse.time.mpse %<>%
   mp_diff_analysis(.abundance=RareAbundance,
                   .group=time,
                   first.test.alpha=0.01,
                   action="add")
library(ggplot2)
p1 <- mouse.time.mpse %>%
          mp_plot_diff_boxplot(.group = time) %>%
          set_diff_boxplot_color(
           values = c("deepskyblue", "orange"),
           guide = guide_legend(title=NULL)
         )

p2 <- mouse.time.mpse %>%
         mp_plot_diff_boxplot(
           taxa.class = c(Genus, OTU),
           group.abun = TRUE,
           removeUnknown = TRUE,
         ) %>%
         set_diff_boxplot_color(
           values = c("deepskyblue", "orange"),
           guide = guide_legend(title=NULL)
         )

aplot::plot_list(p1, p2)

plot

Thanks! It works,But How can I get the raw data of mp_plot_diff_boxplot()?

shaodongyan avatar Aug 12 '22 09:08 shaodongyan