umerijaz / microbiomeSeq

An R package for microbial community analysis in an environmental context
66 stars 26 forks source link

plot_taxa() - Error in beta.div(abund_table, method = method, sqrt.D = F, samp = T, #6

Closed Marieag closed 6 years ago

Marieag commented 6 years ago

Hello again.

I'm getting another issue when trying to run this command

>p <- plot_taxa(physeq,grouping_column="Country", method="hellinger", number.taxa=21, filename=NULL)
Error in beta.div(abund_table, method = method, sqrt.D = F, samp = T,  : 
  could not find function "beta.div"

I'm running the latest stable versions of R and Rstudio, and have updated all packages, but I'm getting the issue with both my own dataset and the tutorial pitlatrine dataset. Any idea how to work around it?

Thanks, Marie

Marieag commented 6 years ago

Also, sort-of-related, when I try to do co-ocurrence networks, it seems a lot of packages need to be installed for it to work (haven't gotten that far yet), would you happen to have a list of packages that is needed to run it?

AlfredUg commented 6 years ago

Many thanks for raising this @Marieag.

  1. The function beta.div is part of adespatial package which you can install directly from RStudio. Once you have that installed, plot_taxa will work well.
  2. Something else that could be useful is to first use taxa_level function which gives community data at a given taxonomic rank, for example, to obtain census data at Phylum level, use; physeq<-taxa_level(pitlatrine, "Phylum").
  3. About the packages, you can find the full list of dependancies in the description file here. For co-ocurrence networks specifically, the required packages include: WGCNA, igraph, reshape2, vegan and ggplot2.

I hope that helps.

Marieag commented 6 years ago

Sorry for the late response. Thanks for your feedback - plot_taxa is working fine after installing adespatial, but I'm getting a persistent error when doing the co-occurence networks,

co_occr <- co_occurence_network(pitlatrine, grouping_column = "Country", rhos = 0.35, method="cor", 
+qval_threshold=0.05, select.condition = "V", scale.vertex.size=4, scale.edge.width=10, 
+plotNetwork=T, plotBetweennessEeigenvalue=F)

Error in membership(temp_comm) : could not find function "membership" 

I get this error with the tutorial dataset as well as my own, and with or without using taxa_level. Any ideas?

AlfredUg commented 6 years ago

@Marieag, membership function is part of the igraph package. Therefore, you can install igraph and load it. Thereafter, this error will not appear anymore.

Marieag commented 6 years ago

@AlfredUg. Strange. I had igraph called already. I tried deleting the igraph library folder, reinstalling and recalling the package when doing the co-occurence networks, and it worked afterwards. Some possible masking going on?

I now have the network graph, but I can't seem to create the betweeness plot, when plotBetweennessEeigenvalue=T regardless of plotNetwork=F or plotNetwork=T It doesn't give me an error message, it just does not output any plots. I looked through construct_network.R - it seems to accept my object as g1 for the network plot, but not the betweenness plot.

I tried running the function plot_betweenness_eigenvalue separately, and got the error Error in igraph::betweenness(g1) : Not a graph object.

I suspect something is going wrong when calling the actual plot in the function?

I'd really love to be able to make this graph, it's perfect for our data, so I hope you won't mind helping me out again. Thanks!

AlfredUg commented 6 years ago

@Marieag, plotBetweennessEeigenvalue=T produces plots of Betweenness Versus Eigen value centrality of the network in the working directory. After running co_ocurrence_network with plotBetweennessEeigenvalue=T, navigate to the working directory to find these plots.

Marieag commented 6 years ago

Hi, sorry I never got back to you - thank you so much for your help. You're right, they're in the WD. Sorry for bothering you before checking :$

AlfredUg commented 6 years ago

Hi @Marieag, am glad that works fine.

BS2018 commented 6 years ago

Hello, How to deal with this error while using the function co_occurence_network? Error in vegan::rrarefy(abund_table, min(rowSums(abund_table))) : object 'do_rrarefy' not found

AlfredUg commented 6 years ago

@BS2018, check that package vegan is loaded. This error is a result of R not finding rrarefy function.

I hope that helps.

BS2018 commented 6 years ago

I have loaded almost everything library(microbiomeSeq) library(ape) library(igraph) library(DESeq2) library(KMDA) library(vegan) library(phyloseq) library(WGCNA) library(fso) library(randomForest) library(data.table) library(reshape2) library(gtable) library(ggplot2) library(gridExtra)

Even then I get the same error.

BS2018 commented 6 years ago

After installing vegan again I got it. Thank you so much.

AlfredUg commented 6 years ago

Good stuff @BS2018