joey711 / phyloseq

phyloseq is a set of classes, wrappers, and tools (in R) to make it easier to import, store, and analyze phylogenetic sequencing data; and to reproducibly share that data and analysis with others. See the phyloseq front page:
http://joey711.github.io/phyloseq/
581 stars 187 forks source link

biplot with phyla relative abundance #726

Open AndreaQ7 opened 7 years ago

AndreaQ7 commented 7 years ago

Goodmorning guys,

I'm trying to perform a beta-diversity analysis with biplot, but not as the normal one like figure 1 but like in figure2 with the representation of phyla abundance among samples and the size depending on phyla relative abundance...do u have any help for me please? thank u all fig1 fig2

spholmes commented 7 years ago

Actually there are women who aren't guys who read your requests, even on International women's day....

Your best bet is to get the coordinates out from the ordination command and refine what was done at various stages of the microbiome workflow paper: https://f1000research.com/articles/5-1492/v2

To make the relative abundance, we used:

rel_abund <- t(apply(otu_table(ps), 1, function(x) x / sum(x)))qplot(rel_abund[, 12], geom = "histogram") + xlab("Relative abundance")

If you don't provide a more precise question or data set, it's hard to be more specific than that, but once you get an object out of the ordinate command, you should look at it and you can add annotations to ggplot using something like

ps_ccpna <- ordinate(pslog, "CCA", formula = pslog ~ age_binned + family_relationship)

when we made Figure 16, we used a ggplot from scratch:

ggplot() + geom_point(data = row_scores, aes(x = li.Axis1, y = li.Axis2), shape = 2) + geom_point(data = col_scores, aes(x = 25 co.Comp1, y = 25 co.Comp2, col = Order), size = .3, alpha = 0.6) + scale_color_brewer(palette = "Set2") + facet_grid(~ age_binned) + guides(col = guide_legend(override.aes = list(size = 3))) + labs(x = sprintf("Axis1 [%s%% variance]", round(evals_prop[1], 2)), y = sprintf("Axis2 [%s%% variance]", round(evals_prop[2], 2))) + coord_fixed(sqrt(ranks_pca$eig[2] / ranks_pca$eig[1])) + theme(panel.border = element_rect(color = "#787878", fill = alpha("white", 0)))

You can do the same but add

geom_point(aes(size = rel_abund), pch = 1)

Best of luck,

Susan

On Wed, Mar 8, 2017 at 3:26 AM, AndreaQ7 notifications@github.com wrote:

Goodmorning guys,

I'm trying to perform a beta-diversity analysis with biplot, but not as the normal one like figure 1 but like in figure2 with the representation of phyla abundance among samples and the size depending on phyla relative abundance...do u have any help for me please? thank u all [image: fig1] https://cloud.githubusercontent.com/assets/18282354/23702154/62285a2a-03fa-11e7-8d27-5b8e252e3da6.JPG [image: fig2] https://cloud.githubusercontent.com/assets/18282354/23702155/622c51b6-03fa-11e7-8f73-af0ef243b1b1.JPG

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/joey711/phyloseq/issues/726, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJcvWTkwzY1ifOkZNJrcoAbR5AFd2btks5rjpCAgaJpZM4MWq8e .

-- Susan Holmes Professor, Statistics and BioX John Henry Samter Fellow in Undergraduate Education Sequoia Hall, 390 Serra Mall Stanford, CA 94305 http://www-stat.stanford.edu/~susan/

AndreaQ7 commented 7 years ago

Thank you a lot for your help and I have to apologize with the beginning of my previous post. This was a mistake of translating my message in english, indeed in my mother language the term "guys" is used both to indicate male and female people (so it is a way to say hi to all people reading), thus i translated it directly without thinking if in english language it was the same. Still apologize for that.