-
Notifications
You must be signed in to change notification settings - Fork 12
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
plotRDA, plot loadings #92
Comments
I would like to provide some examples on how to plot these feature loadings after talking with @antagomir about this. There would be 2 ways of plotting : This requires the latest github version of mia.
This is the exact same process for every reduction method, the only thing that changes is how the loadings matrix is retrieved and stored which is why wrappers discussed in microbiome/mia#596 could be helpful. As also discussed it might be possible to recognize the type of reduction method so that the user do not have to specify method when calling function.
|
Thanks @ElySeraidarian Could we formulate a miaViz-style function for one of these, so that the plotting can be done on a single line of code, given that the user provides a TreeSE object that has a) feature loading matrix (in some position that we can change later, i.e. in rowData or in metadata or in attr) and b) (optionally) a rowTree. In the first round at least we can assume that the user has themselves done the necessary agglomerations etc. There are so many considerations on those things that we cannot automated all possible scenarios on the data sizes anyway. |
Looks very nice and interesting. However, I am wondering if that is the most usual way to plot loadings ( I don't know). At least for eigenvalues the most usual way might be scree plot (bar plot). We could have function to plot both loadings and eigenvalues perhaps since both are needed to describe the ordination results fully.
|
Only some ordination methods provide eigenvalues (e.g. PCA, MDS) and I think only in PCA (out of the commonly used ordinations) the eigenvalues have an actual clear + commonly used interpretation. Thus a general function for this might not be feasible. It would be interesting to experiment with different ways to visualize loading matrices. The barplot/screeplot is indeed very common. If we have generic function to visualize loadings, then this could give different options, like bar/screeplot, heatmap, etc. However, heatmap (options 2) seems to me like a good alternative. In there, one should show also the sign of the loading (e.g. with different colors for negative and positive values); also do not use two different indicators (like size and color) to denote the same thing. If you could use native ggplot2 instead of ggcorrplot that could be useful (reducing package dependencies is in general good). I would swap the figure for better readability of species names. The tree + heatmap is very nice since usually the loadings do not show the tree but this can be useful. The idea has been borrowed from Susan Holmes' phyloseq work. |
Thanks for your returns, indeed it will be possible to create a call for a one line function that will do the plotting. I have not been able to plot the exact same plot using ggplot2 but here is an example I have build based on your returns
It is a bit different as the loadings value differs from y-axis and there is no colour change for positive/negative values. So here is also the improved version using ggcorrplot in case we want to use it
|
I would not combine the two axes like in the first plot. PC1 and PC2 we wouldn't compare directly in most cases. The original ggcorr plot looked better in fact. A related idea, how about plotting just one axis at a time (as heatmap), sorting the values in increasing order, and then using colors to illustrate the increasing values (instead of bars)? Probably the standard barplot / screeplot would be useful to include as option as well. Note: often the user is interested on just a few top features (e.g. 5-10). This might help to find additional complementary options, too. To get fwd, can we create one function that has the more standard barplot, and one heatmap version as options? |
I will open a PR tomorrow with the function that would include every plotting method we talked about and should be operational at least for PCA (waiting for other methods to have same way to retrieve loadings). Here is the example I made based on your returns.
|
This could
|
This one should be finally good
|
Great! Can you prepare an actual miaViz function that takes care of this? |
@ElySeraidarian can you close this issue as it becomes ready? |
In OMA, there is an example on how to plot loadings of features in dbRDA. We could consider to generalize this to plotting function if that is a common way to analyze which features drive the difference
The text was updated successfully, but these errors were encountered: