Giter Site home page Giter Site logo

hillr's People

Contributors

ajrominger avatar akpaulson avatar bisaloo avatar daijiang avatar katrinleinweber avatar p-neves avatar rekyt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

hillr's Issues

error in `hill_taxa_parti` if sites have the same and only one species

M is a matrix with two sites that both have the same species and only one species in common.

M <- matrix(c(0,1,0,0,1,0), byrow = T, ncol = 3)
hill_taxa_parti(M)

if we try to calculate beta diversity for M we get the following error:

Error in !all.equal(sum(comm_gamma), 1) : invalid argument type

I suspect this occurs because Some species in comm data were not observed in any site, delete them... which likely reduces the matrix to a vector which might cause an error upstream which causes sum(comm_gamma) to give NA or NULL. This is, however, speculation as I haven't found which function calls this code (haven't dug deep though yet)

edit: forgot to say - thank you so much for this package it was thoroughly missing!

hill_func() is returning D_q higher than species richness

I noticed that hill_func() is returning values of D_q (functional hill number, the effective number of equally abundant and functionally equally distinct species) higher than the values of taxonomic species richness, which should not be possible (it is not possible to have more equally abundant and functionally equally distinct species than the number of species).
I was afraid it was something wrong with my data, but I checked the example codes with "dummy" dataset from FD package and it happens too.

library(FD)
library(hillR)

dummy = FD::dummy

hill_func(comm = dummy$abun, traits = dummy$trait, q = 0)
hill_taxa(comm = dummy$abun, q = 0)

And the outputs are:

          com1      com2      com3      com4      com5      com6      com7      com8       com9
Q    0.4016663 0.1922618 0.2780442 0.1146261 0.3816159  0.404177 0.2934143 0.3343662  0.4156546
FDis 0.3481687 0.1670560 0.2375808 0.1146261 0.3211366  0.330233 0.2532751 0.2877931  0.3421687
D_q  4.0974923 3.6518111 3.2454591 3.0237158 3.0655375  5.233241 3.1470056 4.3998540  5.2114653
MD_q 1.6458245 0.7021037 0.9023810 0.3465969 1.1698580  2.115156 0.9233765 1.4711625  2.1661695
FD_q 6.7437533 2.5639502 2.9286406 1.0480104 3.5862436 11.069121 2.9058708 6.4729004 11.2889174
         com10
Q    0.3844765
FDis 0.3503927
D_q  4.1694097
MD_q 1.6030400
FD_q 6.6837303

 com1  com2  com3  com4  com5  com6  com7  com8  com9 com10 
    4     3     3     2     3     5     3     4     5     4 

Every community here has D_q higher than species richness for q = 0. Something seems wrong here, but I could not find the problem in the codes. Can you help with this?

object 'comm' not found

I'm trying to run the hillR code using the comm data within the package. I have installed and loaded the package but I get the notification that object "comm" is not found when I try to run the code.

This is what I'm seeing:

library(hillR)
hill_taxa(comm, q = 0, MARGIN = 1, base = exp(1))
Error in as.matrix(comm) : object 'comm' not found

div_by_sp

In the man files for hill_func.Rd, there is an argument {div_by_sp}{as FD calculated in this way will be highly correlated with taxonomic diversity, one simple way to correct this is to divide the results by the number of species. Default is FALSE.}
I'm not sure it it is really ok to simply correct by dividing the results by the number of species? Perhaps this issues requires a bit more context for the user. A common approach to dealing with this issue is to use null models to calculate standardized effect sizes (Swenson 2014). How would the specification of this argument in hillR intersect with this approach (or not)?

@sydnerecord I think we should move the review here.

hill_func() returns same-ish values regardles of similarity

So - I was trying to futz with this package to understand how it works, and find that D_Q returns about the same number regardless of the trait values. Below is a reprex:

library(hillR)
library(mvtnorm)

#make a bunch of species where I can determine how
#correlated their abundances are
cmat <-  matrix(rep(0.9,25), ncol = 5)
diag(cmat) <- 1

#the data
z <- mvtnorm::rmvnorm(10, rep(10, 5),
                      cmat)

#check how correlated they are
dist(t(z))

#turn it into a data frame
z <- as.data.frame(z)

#traits
tdat <- data.frame(
  t1 = c(rep(1, 4), 1.1),
  t2 = c(rep(1, 4), 1.1),
  t3 = c(rep(1, 4), 1.1)
)

rownames(tdat) <- names(z)

hill_func(z,
          tdat,
          q = 2,
          fdis = FALSE)

This returns D_q values of ~ 5 for all plots.

          [,1]      [,2]      [,3]      [,4]      [,5]
Q     1.246470  1.247999  1.260358  1.184194  1.254891
D_q   4.984464  4.982051  4.955814  5.108023  4.965449
MD_q  6.212983  6.217595  6.246097  6.048892  6.231096
FD_q 30.968389 30.976372 30.954496 30.897877 30.940189
          [,6]      [,7]      [,8]      [,9]     [,10]
Q     1.230411  1.234581  1.246552  1.226033  1.255536
D_q   5.017417  5.009502  4.984898  5.025869  4.967230
MD_q  6.173487  6.184635  6.213932  6.161883  6.236534
FD_q 30.974956 30.981939 30.975818 30.968813 30.978294

This seems odd. Note how I put together the traits. Now, if I crank up that 1.1 to 100 to make things very different, I still get D_Q of around 5. If I change it to vectors of 5 uniform numbers, D_q is still ~ 5. If I change the correlation matrix of species to be very uncorrelated (0.001), I still get a D_q of around 5 in each plot. I would expect somewhere along the line, I should get D_q values in the 1-2 range.

What is wrong here? Or am I fundamentally missing something (always possible!)

Note, I even tried zeroing out some species

z[sample(1:10, 10, replace = TRUE), sample(1:5, 10, replace = TRUE)] <- 0

And still got D_q values of ~ 5 for all plots.

Something..... seems wrong here.

`hill_func` throws error when only one trait is measured

Hi Daijiang! Just wanted to let you know that hill_func throws an error when you give it data on only one trait (i.e. when the traits argument is a data.frame with one column). This applies to hill_func_parti as well. I created a pull request that fixes this issue: #16

Calculated Rao Q in hillR and FD packages are different

Hi,
I test your code and the trial data "dummy", comparing the results of FD package and hillR, The reported Rao Q are different, because of dependencies of hill functional diversity numbers on RaoQ, I think the calculated Functional hill numbers in your code are not correct.
Regards,
Bagher

Installation instructions - dependencies

Currently the devtool option automates the dependencies, but for posterity it may be helpful to also list the dependencies and package version numbers in case there are ever issues with devtools.

R session abored

When the R code run the hill_phylo(comm, tree, q = 0) in version 0.5.1, the R studio is always in session aborted. although, I had tried from the R4.1.3 to R4.2.1, even re-install the R and the RStudio. I am looking forward to getting your help to solve this problem, thank you!!!
61bd77ae291a154837da86d8655296a

hill_func with categorical traits

HI!
Thanks for implementing this package.
I have one question, is it possible to run the hill_func function using categorical traits?

Thanks a lot!

`hill_func` fails for all numeric traits

take the following reproducible example:

library(hillR)
library(vegan)

BCI <- data(BCI, package = "vegan") 

ncol(BCI)

BCI_trait <- matrix(rnorm(ncol(BCI)*10, 5, 1), ncol = 10)
rownames(BCI_trait) <- colnames(BCI)

# fails
hillR::hill_func(BCI, BCI_trait, q = 1, fdis = FALSE)

# add random character trait
BCI_trait <- cbind(BCI_trait, sample(LETTERS, ncol(BCI), replace = T))

#works
hillR::hill_func(BCI, BCI_trait, q = 1, fdis = FALSE)

There are 2 additional errors that you might want to have a look at:

  1. I have to set fdis = FALSE as otherwise the function fails
  2. If I provide a distance matrix I have to set traits_as_is = T and checkdata = F otherwise the checks throw an error..

Problems installing

Hi, I just tried to install the package and got the error "Installation failed: Not found (404)". I'd be grateful for any suggestions as I'd really like to run the package. Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.