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

rarecurve and empty name of Subsample attribute #352

Closed
hmontenegro opened this issue Mar 30, 2020 · 1 comment
Closed

rarecurve and empty name of Subsample attribute #352

hmontenegro opened this issue Mar 30, 2020 · 1 comment
Assignees
Labels

Comments

@hmontenegro
Copy link

I am using vegan 2.5-6 and R 3.6.3, .

In order to do some custom plots (with ggplot), I was investigating the format of the list invisibly returned by rarecurve(). My understanding is the sample name is stored as the name of the last item of the Subsample attribute - please correct me if I am wrong.

Then, trying to manipulate the list returned by rarecurve(), I discovered a weird random bug: sometimes, the Subsample attribute doesn't get the name of the original sample, and is not set at all - the plot, however, does show the sample name. The bug is somewhat random, affects some datasets but not others, and also depends on the step=150 parameter.

Reproducible example:

library( MASS )
set.seed( 2 )
m <- matrix( rnegbin( 80*4034, 15, 0.0005), 80, 4034 )
colnames( m ) <- paste0( "ASV", 1:4034 )
rownames( m ) <- paste0( "S", 1:80 )
prc <- vegan::rarecurve( m, step = 150, cex = 0.5 )
# with "step = 500" the bug is not triggered

Then:

names( attributes( prc[[1]] )$Subsample[
    length( attributes( prc[[1]] )$Subsample ) ] )

returns, as expected, "S1", but:

names( attributes( prc[[17]] )$Subsample[
    length( attributes( prc[[17]] )$Subsample ) ] )

returns NULL (with the above code, "S66" has also a NULL attribute name).

However, as I said, the plot returned do contain the label for "S17", which can be easily found on the plot bellow, as it is the uppermost sample name shown - "S66" is there as well, somewhere.

rarecurve

@gavinsimpson gavinsimpson self-assigned this Apr 6, 2020
@gavinsimpson
Copy link
Contributor

Thanks for reporting this. We don't use the names on the subsample attribute for the plot. I figured out what was going on and it looks like it wasn't intended for this to be a named vector at all. Just checking a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants