Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two question about import qiime2 files #97

Open
Rainjie-afk opened this issue Aug 3, 2023 · 2 comments
Open

Two question about import qiime2 files #97

Rainjie-afk opened this issue Aug 3, 2023 · 2 comments

Comments

@Rainjie-afk
Copy link

Rainjie-afk commented Aug 3, 2023

Hello! Very nice work!
I'm looking for help with running qiime2 files as import files (contain tree file) :

test_files <- import_qiime2("T2DM_16S_Amplificateion_import_results_table-dada2.qza",
                            taxaqza = "T2DM_16S_Amplificateion_import_results_import_results-rep-seqs_gtdb-214-bacteria-v3v4-classifier.qza",
                            mapfilename = "Group_metadata2.tsv",
                            treeqza = "T2DM_16S_Amplificateion_import_results_import_results-rep-seqs-aligned-masked-fasttree-tree")
mpse <- test_files %>% as.mpse()
mpse
# A MPSE-tibble (MPSE object) abstraction: 331,360 × 12
# OTU=8284 | Samples=40 | Assays=Abundance | Taxonomy=Kingdom, Phylum, Class, Order, Family, Genus, Speies
   OTU                              Sample Abundance Num   Group Kingdom        Phylum           Class Order Family Genus Speies
   <chr>                            <chr>      <dbl> <chr> <chr> <chr>          <chr>            <chr> <chr> <chr>  <chr> <chr> 
 1 3d465cca97074831971c7a7ccd5da390 F_103        229 DM_1  DM    k__d__Bacteria p__p__Desulfoba… c__c… o__o… f__f_… g__g… s__s_…
 2 a16720e62eebc35341b4fe472c181960 F_103        222 DM_1  DM    k__d__Bacteria p__p__Desulfoba… c__c… o__o… f__f_… g__g… s__s_…
 3 38257b864b5c8a324287642894f70ba8 F_103        150 DM_1  DM    k__d__Bacteria p__un_k__d__Bac… c__u… o__u… f__un… g__u… s__un…
 4 d1e1de8b48805bc64d71f66d1de798a1 F_103        163 DM_1  DM    k__d__Bacteria p__p__Desulfoba… c__c… o__o… f__f_… g__g… s__s_…
 5 ddc1d84b71dcf973e2f2c4150b51d297 F_103        137 DM_1  DM    k__d__Bacteria p__un_k__d__Bac… c__u… o__u… f__un… g__u… s__un…
 6 d248201d0fd2e84c22df158bb7b12e14 F_103         86 DM_1  DM    k__d__Bacteria p__p__Bacillota  c__c… o__o… f__f_… g__g… s__un…
 7 40f5617dbc353f11123252dae526a1ec F_103        140 DM_1  DM    k__d__Bacteria p__p__Bacillota  c__c… o__o… f__f_… g__g… s__un…
 8 cb8bdefd71370ab957076bdd3e3c9a05 F_103        118 DM_1  DM    k__d__Bacteria p__un_k__d__Bac… c__u… o__u… f__un… g__u… s__un…
 9 c53726cfa32814f54fca8f3034b87ace F_103        125 DM_1  DM    k__d__Bacteria p__un_k__d__Bac… c__u… o__u… f__un… g__u… s__un…
10 282c6376e49a5757828b0ba26bbfa875 F_103        120 DM_1  DM    k__d__Bacteria p__un_k__d__Bac… c__u… o__u… f__un… g__u… s__un…
# ℹ 331,350 more rows
# ℹ Use `print(n = ...)` to see more rows
  1. 2.8 Performing differential analysis among multiple groups
    How can i delete nodes which can't identify in the level which i selected?
    mpse2_4groups %>% mp_rrarefy() %>% mp_diff_analysis(.abundance=RareAbundance, .group=Group) %>% mp_extract_tree(tip.level=Fanmily) -> taxa.tree
屏幕截图 2023-08-05 011806

PS.
I have try code like this taxa.tree %>% dplyr::filter(!grepl("^g__un_o|^g__un_f",label)), but it doesn't work

  1. The second question related to the first one:

The code runs smoothly until chapter 2.7 "Significant differential clades for the diagnosis of some related diseases"

mpse3 %>% mp_balance_clade( .abundance = Abundance, force = TRUE, relative = FALSE, pseudonum = 1, balance_fun='geometric.mean' ) -> mpse.balance.node
R Console tells me that I should use ape to load tree file which made me can't run any further.

So, is there any way to solve this problem?
Perhaps I should run mp_extract_tree(), but i really run out of idea, help me please.

@Rainjie-afk
Copy link
Author

Another tiny question occured when i run mpse16s %<>% dplyr::left_join(sample.da, by=c("Sample"="sample_id")) in chapter 3.1 The parsing of the 16s data and construction of MPSE class
dplyr::left_join seems unable to match Sample in mpse16s

> mpse16s %<>% dplyr::left_join(sample.da, by=c("Sample"="sample_id"))


> rlang::last_trace()
<error/rlib_error_dots_nonempty>
Error in `left_join()`:
! `...` must be empty.
✖ Problematic argument:
• ..1 = !!!dots
ℹ Did you forget to name an argument?
---
Backtrace:
    ▆
 1. ├─mpse16s %<>% dplyr::left_join(sample.da, by = c(Sample = "sample_id"))
 2. ├─dplyr::left_join(., sample.da, by = c(Sample = "sample_id"))
 3. ├─MicrobiotaProcess:::left_join.MPSE(., sample.da, by = c(Sample = "sample_id"))
 4. │ └─sampleda %>% ...
 5. ├─dplyr::left_join(...)
 6. └─dplyr:::left_join.data.frame(., y, by = by, copy = copy, suffix = suffix, !!!dots)
Run rlang::last_trace(drop = FALSE) to see 5 hidden frames.
> mpse16s %<>% dplyr::left_join(sample.da, by=c("Sample"="sample_id"), !!!dots)
Error in `left_join()`:
! `...` must be empty.
✖ Problematic argument:
• ..1 = !!!dots
ℹ Did you forget to name an argument?

Is there any way to bypass left_join when I want to load PICRUST2 result and group_metadata to generate MPSE object?

@Rainjie-afk
Copy link
Author

Inspire by this post https://github.com/YuLab-SMU/MicrobiotaProcess/issues/43

The following method can solve the sorting error in multiple groups:

taxa.tree %>% 
  dplyr::filter(nodeClass=="Phylum" & !is.na(Sign_Group), keep.td=FALSE) -> genus.tb
genus.tb %>% 
  tidyr::unnest(RareAbundanceBySample) %>% 
  dplyr::filter(!grepl("^f__un_", label)) -> df_taxa.tree_Phylum
df_taxa.tree_Phylum$Group <- factor(df_taxa.tree_Phylum$Group, 
                                    levels = c("NC","DM","DL","DH"))
cols_2 <- rev(cols)
df_taxa.tree_Phylum %>% ggplot(aes(y=label, x =RelRareAbundanceBySample, fill=Group)) + 
  geom_boxplot(orientation='y', outlier.colour = NA) + 
  scale_fill_manual(values = cols_2) +
  ylab(NULL) + theme(legend.key = element_blank()) -> a1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant