MoBiodiv / mobr

Tools for analyzing changes in diversity across scales
Other
23 stars 18 forks source link

Errors in plot_rarefaction examples (dev branch) #270

Closed FelixMay closed 6 months ago

FelixMay commented 1 year ago

Several errors are generated, when I execute the examples from the documentation of plot_rarefaction, for example:

library(mobr)
#> Warning: vorhergehender Import 'dplyr::filter' durch 'stats::filter' während
#> des Ladens von 'mobr' ersetzt
#> Warning: vorhergehender Import 'dplyr::lag' durch 'stats::lag' während des
#> Ladens von 'mobr' ersetzt
data(inv_comm)
data(inv_plot_attr)
inv_mob_in = make_mob_in(inv_comm, inv_plot_attr, coord_names = c('x', 'y'))

# random individual based rarefaction curves
plot_rarefaction(inv_mob_in, 'group', 'uninvaded', 'IBR',
                 pooled=FALSE, log='x')
#> Error in rarefaction(y, method, ...): unbenutztes Argument (pooled = FALSE)
# random sample based rarefaction curves 
plot_rarefaction(inv_mob_in, 'group', 'uninvaded', 'SBR', log='xy')
#> Error in plot_rarefaction(inv_mob_in, "group", "uninvaded", "SBR", log = "xy"): Samples can only not be pooled at the treatment level when individual-based rarefaction is used (i.e., method="IBR")
# spatial sample based rarefaction curves 
plot_rarefaction(inv_mob_in, 'group', 'uninvaded', 'sSBR', log='xy')
#> Error in plot_rarefaction(inv_mob_in, "group", "uninvaded", "sSBR", log = "xy"): Samples can only not be pooled at the treatment level when individual-based rarefaction is used (i.e., method="IBR")

Created on 2023-03-28 with reprex v2.0.2

dmcglinn commented 6 months ago

hey @FelixMay I think I've fixed these now in 31ed149 to the dev branch

dmcglinn commented 6 months ago

The arguments supplied to plot_rarefaction have changed. Specifically there is no longer a pooled argument. This has been superseded by the scales argument. In the past setting pooled = TRUE is now carried out by including gamma as one of the scales.

library(mobr)
data(inv_comm)
data(inv_plot_attr)
inv_mob_in <- make_mob_in(inv_comm, inv_plot_attr, coord_names = c('x', 'y'))
par(mfrow=c(1,2))
plot_rarefaction(inv_mob_in, 'group', 'uninvaded', 'IBR', log='x') 
#generates the following graphic
# note the default scales argument is set to alpha, gamma, and study. 
# we discussed best naming practices in https://github.com/MoBiodiv/mobr/issues/255

image

# spatial, sample-based rarefaction
plot_rarefaction(inv_mob_in, 'group', 'uninvaded', 'sSBR', log = 'x')
# spatially explicit, sample-based rarefaction, thanks to Felix for this addition!
plot_rarefaction(inv_mob_in, 'group', 'uninvaded', 'spexSBR', log = 'x')

image