Just posting this to flag an issue - I have found a work around but wanted this to be here as a reference for others who might encounter the issue.
I was getting the error: Error in boot_group_specimens[[gr]] : subscript out of bounds when running testBetaDiversity() on a set of data that contained 154 specimens divided amongst two groups. I pin pointed this issue to lines 170-180 in s3functions.R:
boot_group_specimens <-sapply(unique_groups,
function(x) apply(sample_specimen_matrix[groups == x,np_boot_pulls[,k]],2,max) %>%
(function(y) names(y)[y==1]))
boot_centroids[[k]] <- lapply(unique_groups,
function(gr){
samples <- unlist(sapply(boot_group_specimens[[gr]],
function(specname)
which(sample_specimen_matrix[,specname] ==1)))
return(apply(dv$fitted_z[samples,,drop= F],2,median))}
)
When making object boot_group_specimens starting at line 170, if there is an equal number of specimens in each group sapply() forces makes the object into a matrix instead of a list. This then causes the error in the step where the object boot_centroids[[k]] (starting at line 174) is created as at line 176 boot_group_specimens[[k]] is used which will not work for the matrix made in the prior step. This is apparently something inherent to sapply().
This would, of course, only happen if you have an even number of specimens divided amongst two groups.
I have worked around this so it's not a huge issue for me at the moment but wanted to flag it in case anyone else runs into it in the future. Apologies if this was already raised elsewhere.
Just posting this to flag an issue - I have found a work around but wanted this to be here as a reference for others who might encounter the issue.
I was getting the error:
Error in boot_group_specimens[[gr]] : subscript out of boundswhen running testBetaDiversity() on a set of data that contained 154 specimens divided amongst two groups. I pin pointed this issue to lines 170-180 in s3functions.R:When making object
boot_group_specimensstarting at line 170, if there is an equal number of specimens in each groupsapply()forces makes the object into a matrix instead of a list. This then causes the error in the step where the objectboot_centroids[[k]](starting at line 174) is created as at line 176boot_group_specimens[[k]]is used which will not work for the matrix made in the prior step. This is apparently something inherent tosapply().This would, of course, only happen if you have an even number of specimens divided amongst two groups.
I have worked around this so it's not a huge issue for me at the moment but wanted to flag it in case anyone else runs into it in the future. Apologies if this was already raised elsewhere.