fitzLab-AL / gdm

R package for Generalized Dissimilarity Modeling
GNU General Public License v3.0
33 stars 12 forks source link

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

Closed Basquill closed 7 months ago

Basquill commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

@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 commented 7 months ago

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

Basquill commented 7 months ago

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 commented 7 months ago

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.