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

Reproducing Plot 4a in Mokany et al (2022) #38

Closed
Basquill opened this issue Mar 27, 2024 · 5 comments
Closed

Reproducing Plot 4a in Mokany et al (2022) #38

Basquill opened this issue Mar 27, 2024 · 5 comments

Comments

@Basquill
Copy link

Hello @fitzLab-AL and gdm users (also @rvalavi if you're inclined),

Is the code for reproducing plot 4a available? Section 1.7 of the supplementary materials (and online material - link below) includes code for reproducing plot 4b, but not 4a. A similar plot (to 4a) is one of many produced via plot(gdm). I can reproduce that individual plot from plot(gdm) (in part) using plot(gdm$ecological, gdm$observed). But I lack the line showing GDM-predicted dissimilarity.

Having this code will also help clarify whether a data object from predict(gdm, gdmTab) is required to produce plot 4a; and thus further reveal the relationship between plots produced via plot(gdm) and plot(x, gdm.pred).

My expectation is that other users have had this question. Thanks very much

[https://github.com/fitzLab-AL/gdm?tab=readme-ov-file#visualizing-multi-dimensional-biological-patterns]

@fitzLab-AL
Copy link
Owner

fitzLab-AL commented Mar 27, 2024

This is the code the the gdm.plot function that creates the plot. You can customize as needed.

##plots the compositional dissimilarity spline plot
plot(x$ecological, x$observed, xlab="Predicted Ecological Distance", ylab="Observed Compositional Dissimilarity", type="n", ylim=c(0,1))
points(x$ecological, x$observed, pch=20, cex=0.25, col=plot.color)
overlayX <- seq( from=min(x$ecological), to=max(x$ecological), length=PSAMPLE )
overlayY <- 1 - exp( - overlayX )
lines( overlayX, overlayY, lwd=plot.linewidth )

@Basquill
Copy link
Author

@fitzLab-AL could you please clarify what the PSAMPLE vector is or comes from? I have the code working up to that point (ie., length=PSAMPLE). thanks

@fitzLab-AL
Copy link
Owner

Have a look at the code for the gdm.plot function. It is in there. It is just an integer.

@Basquill
Copy link
Author

I checked plot.gdm and didn't see an argument for length. Or elsewhere in the gdm 1.6 package info. However, length() is in section 1.5 of Appendix S1 (Mokany et al 2022) and equivalent code on your website. The plot works okay with or without it. In the end, I matched it to the max(gdm$ecological) value for a useful visual. Thanks. I appreciate the assistance.

@fitzLab-AL
Copy link
Owner

You asked about PSAMPLE, which is defined in gdm.plot.

https://github.com/fitzLab-AL/gdm/blob/master/R/gdm.plot.R

ctrl-F PSAMPLE and you will find it.

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