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/
577 stars 187 forks source link

Can I add samples to be plotted in an ordination plot without affecting its layout? #790

Open orenkolodny opened 7 years ago

orenkolodny commented 7 years ago

Hello, I'd like to create an ordination plot based on the samples in my main experiment group, and then add to it the samples from a control group. I don't want the control samples to influence the ordination, i.e. the axes. This is analogous to doing a PCA with only some of the samples, but then using the loadings generated by that PCA to draw all of the samples. Is it possible? Thanks, Oren

spholmes commented 7 years ago

Oren Indeed this is possible using vegan or ade4, and the function wcmdscale in vegan with a vector w with the weights equal to zero for the points you do not want to participate but that you want to project.

(also in ade4 you can use the argument row.w with a vector with some zeros in the function dudi.pco).

You'll need to extract the otu_table from the phyloseq object as a data.frame or matrix for those functions.

Best Susan

On Tue, Jul 18, 2017 at 2:36 PM, Oren Kolodny notifications@github.com wrote:

Hello, I'd like to create an ordination plot based on the samples in my main experiment group, and then add to it the samples from a control group. I don't want the control samples to influence the ordination, i.e. the axes. This is analogous to doing a PCA with only some of the samples, but then using the loadings generated by that PCA to draw all of the samples. Is it possible? Thanks, Oren

— 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/790, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJcveaIn2GaKJ8L4h6J2fQKSBJsnI_xks5sPSVjgaJpZM4Ob9Lu .

-- 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/

orenkolodny commented 7 years ago

Thank you! Would wcmdscale output a data structure that is analogous to the one produced by Phyloseq's ordinate ? (I couldn't find a detailed description of the latter; I'm asking because I have downstream code that uses plot_ordination, using this output) === Editing: ==== Evidently not. But would it be OK to hack it by first producing an ordination object with and then replacing the content of ordinate_output$vectors with the output of ?

spholmes commented 7 years ago

Oren plot_ordination uses results created by vegan, you'll just have to look at the ordinate and plot_ordinattion code, they are both explicit in phyloseq so you can adapt them to the vegan output. Susan

On Tue, Jul 18, 2017 at 4:47 PM, Oren Kolodny notifications@github.com wrote:

Thank you! Would wcmdscale output a data structure that is analogous to the one produced by Phyloseq's ordinate ? (I couldn't find a detailed description of the latter; I'm asking because I have downstream code that uses plot_ordination, using this output)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/joey711/phyloseq/issues/790#issuecomment-316230796, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJcvSG2zRBF5j6SXdbqEvCv8kOiO4hoks5sPUQvgaJpZM4Ob9Lu .

-- 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/

orenkolodny commented 7 years ago

Thank you. Adding in case someone tries something similar: I ended up hacking as I noted above, and it seems to be OK, as long as I assign some weight greater than 0 (e.g. 0.00000001) to all samples in the input to wcmdscale. If I assign a zero to the samples from my control group, they don't show up in the plot at all; I'm not sure why exactly, but this will do for now.