gmteunisse / fantaxtic

Fantaxtic - Nested Bar Plots for Phyloseq Data
26 stars 3 forks source link

nested_top_taxa #20

Closed rabbl93 closed 1 year ago

rabbl93 commented 1 year ago

Hello, sorry to bother you. Maybe you can help me. I have a problem with the nested_top_taxa command. I always get this error message: Error in apply(toptop[, ranks], 1, paste, collapse = "") : dim(X) must have a positive length. Everything works with the example file, but not with mine. I compared the phyloseq files and everything is as it should be. Top_taxa works, but as soon as I want to do nested_top_taxa, the error occurs. Kind regards

gmteunisse commented 1 year ago

Thanks for bringing this to my attention, I’ll try my best to resolve it. Could you upload a reproducible example?


From: rabbl93 @.> Sent: Friday, June 23, 2023 2:06:05 PM To: gmteunisse/fantaxtic @.> Cc: Subscribed @.***> Subject: [gmteunisse/fantaxtic] nested_top_taxa (Issue #20)

Hello, sorry to bother you. Maybe you can help me. I have a problem with the nested_top_taxa command. I always get this error message: Error in apply(toptop[, ranks], 1, paste, collapse = "") : dim(X) must have a positive length. Everything works with the example file, but not with mine. I compared the phyloseq files and everything is as it should be. Top_taxa works, but as soon as I want to do nested_top_taxa, the error occurs. Kind regards

— Reply to this email directly, view it on GitHubhttps://github.com/gmteunisse/fantaxtic/issues/20, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHBWS3SET7XDWDOOHPFME4DXMWBC3ANCNFSM6AAAAAAZRPIKZM. You are receiving this because you are subscribed to this thread.Message ID: @.***>

rabbl93 commented 1 year ago

I'll send you the individual files and how I created the phyloseq file. I have unfortunately only one large file in which all the information is and then had to produce the rest from this.

taxmat.csv otumat.csv

OTU = otu_table(otumat, taxa_are_rows = TRUE)
TAX = tax_table(taxmat)

library("phyloseq")
physeq = phyloseq(OTU, TAX)

sampledata = sample_data(data.frame(
  Location = sample(LETTERS[1:4], size=nsamples(physeq), replace=TRUE),
  Depth = sample(50:1000, size=nsamples(physeq), replace=TRUE),
  row.names=sample_names(physeq),
  X.SampleID=sample_names(physeq),
  stringsAsFactors=FALSE
))

library("ape")
random_tree = rtree(ntaxa(physeq), rooted=TRUE, tip.label=taxa_names(physeq))
physeq1 = merge_phyloseq(physeq, sampledata, random_tree)
physeq2 = phyloseq(OTU, TAX, sampledata, random_tree)
identical(physeq1, physeq2)

And then:

top_asv <- top_taxa(physeq2, n_taxa = 15)
plot_nested_bar(ps_obj = top_asv$ps_obj,
                top_level = "phylum",
                nested_level = "genus")

works, but this doesn't work:

top_nested <- nested_top_taxa(physeq2,
                              top_tax_level = "phylum",
                              nested_tax_level = "genus",
                              n_top_taxa = 5, 
                              n_nested_taxa = 5)

Greetings and thanks for the quick reply :)

gmteunisse commented 1 year ago

Thanks for the example, that's perfect. I'll hopefully be able to look at this over the weekend.

rabbl93 commented 1 year ago

Thank you very much. That would be great!

gmteunisse commented 1 year ago

This has been fixed, please reinstall the package. Let me know if you run into any other problems. If not: enjoy using the package!

rabbl93 commented 1 year ago

Thank you very much for your quick help! Everything is working fine now.