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

Coloring plot_network #243

Open
gastronaut82 opened this issue Oct 5, 2023 · 3 comments
Open

Coloring plot_network #243

gastronaut82 opened this issue Oct 5, 2023 · 3 comments

Comments

@gastronaut82
Copy link

Hi there, I constructed a network at the family level for my microbial data set, but I want to color the dots by Phylum. I'm having a lot of trouble doing this.

Here's my code:

**xt<-microbiome::transform(ex1, 'clr')
mb<-spiec.easi(xt, method='mb', lambda.min.ratio=1e-2, nlambda=20, pulsar.params=list(rep.num=50))

ig2.mb <-adj2igraph(getRefit(mb), vertex.attr = list(name=as.vector(tax_table(xt)[,"Family'])))

plot_network(ig2.mb, xt, type='taxa')**

My code successfully creates the network at the family level, but I can't color by phylum. I have tried:

plot_network(ig2.mb, xt, type='taxa', color="Phylum")
which gives me

Error: Must request at least one colour from a hue palette.

Then I've tried,

plot_network(ig2.mb, xt, type='taxa', color=tax_table(xt)[,"Phylum"])

which gives me

Error in parse_expr():
! x must contain exactly 1 expression, not 26.

Help!

Thanks

@zdk123
Copy link
Owner

zdk123 commented Oct 5, 2023

xt<-microbiome::transform(ex1, 'clr')

First of all, don't do this ⬆️ . spiec.easi applies a clr transformation with a pseudocount addition so the data you are supplying is incorrect.

plot_network is a phyloseq function, so I'm not entire sure what's going on. If I had to guess, the Phylum column contains all missing values or something. Without the looking at your data, I can't be sure.

@gastronaut82
Copy link
Author

I see thank you - I thought you had to CLR transform first.
Okay, I will try to work with igraph directly to color accordingly

@gastronaut82
Copy link
Author

Relatedly - do you recommend rarefaction prior to applying Spiec-Easi?

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

2 participants