Coder Social home page Coder Social logo

rvanmazijk / cape-vs-swa Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 967.9 MB

Open access repository for (some) data-sets, reproducible analyses, conference slides and manuscript for a publication based on my BSc Hons project (in press in Journal of Biogeography).

Home Page: https://www.researchgate.net/project/Plant-species-richness-turnover-environmental-heterogeneity-in-the-Cape-and-SW-Australia

License: Creative Commons Attribution 4.0 International

R 99.77% TeX 0.09% Makefile 0.14%
academic biodiversity biogeography biology botany ecology ecology-modelling macroecology manuscript open-science r rstats science science-research species-richness

cape-vs-swa's Introduction

cape-vs-swa's People

Contributors

rvanmazijk avatar

Watchers

 avatar

cape-vs-swa's Issues

Species turnover note

(From Thu, 25 Jul)

This metric of turnover has the same problems as T_QDS / S_HDS and Jaccard distance:

HDS %>%
  mutate(euc_dist = sqrt(2*(add_turnover - mean_QDS_richness)^2)) %>%
  ggplot(aes(euc_dist, fill = region)) +
    geom_histogram(bins = 20, position = position_dodge())

Conclusion: scrap

Use jackknife aot bootstrap for CLES and U-tests

Following a chat with Tony earlier today, we think it is best that I rather use jackknife resampling, so as to really get at the issue of unequal number of pixels at different spatial scales when comparing Cape and SWA roughness.

What I was doing before:

bootstrap_sample <- function(x, n) {
  t(repeat(n, {
    sample(x, size = length(x), replace = TRUE)
  }))
}

Cape %<>% bootstrap_sample(n = 1000)
SWA %<>% bootstrap_sample(n = 1000)
CLES(SWA, Cape)

Rather, I should (i) limit resamples to the lowest common number of pixels (i.e. ca. 600 for 3QDS as the limiting size) and (ii) sample without replacement to make the jackknife distribution more "null". Also, Tony pointed out that I needn't resample my roughness-value distributions, but simply resample directly from the pairwise comparison matrix. This will save on computation time because I will only have to make that matrix once.

Thus:

jackknife_sample <- function(x) {
  sample(x, size = length(threeQDS(x)), replace = FALSE)
}
CLES_jackknife <- function(x, y, n) {
  pw <- matrix(nrow = length(rows), ncol = length(cols))
  rownames(pw) <- x
  colnames(pw) <- y
  pw_comparisons <- pw
  for (i in 1:nrow(pw) {
    for (j in 1:ncol(pw) {
      pw_comparisons[i, j] <- 
        rownames(pw)[[i]] < colnames(pw)[[j]]
    }
  }
  CLES_values <- vector(length = nrow(pw) * ncol(pw))
  for (n in 1:1000) {
    rows <- jackknife_sample(1:nrow(pw))
    cols <- jackknife_sample(1:ncol(pw))
    jackknifed_pw <- pw_comparisons[rows, cols]
    jackknifed_pw %<>% as.vector()
    CLES_values[[n]] <- sum(jackknifed_pw), na.rm = TRUE) / length(jackknifed_pw)
  }
  CLES_values
}

CLES_jackknife(SWA, Cape, n = 1000)

Which "SoilsGrid250m" data?

Which "SoilsGrid250m" folder am I using for Cape vs SWA publication---the 4mb ones or the 300kb ones?

See RUAN_UCT/GIS/SoilGrids250m/*/depths-averaged/?/ for the smaller files currently in this project repo under data/derived-data/soils/.

Aspects to the study to maybe discuss

  • Autocorrelative investigations are worthwhile
  • Temporal range of your data sources << that of the question you're asking

AND:

  • Cramer & Verboom 2016's methods § is NB!
  • Linder paper in review by Tony is also NB!

Fix shapefile imports

Throws weird error/warning:

Warning message:
In readOGR(here::here("data/derived-data/borders/GCFR_QDS/")) :
  First layer lon read; multiple layers present in
/Users/ruanvanmazijk/projects/Cape-vs-SWA/data/derived-data/borders/GCFR_QDS, check layers with ogrListLayers()

Maybe is fine?

Setup mirror of repo on FigShare

A "final product mirror" as opposed to the development repo that this is.

Maybe DataDryad?

Think also about UCT FigShare system (ZivaHub)

Manuscript note

  • Tony is still working on the intro, but has put it aside for a bit as he is busy this week.
  • When he gets back to it, he will chat to me about my methods section (and cutting it down)
  • Then we will write the results.

Fix bookdown rendering

Getting this error on call bookdown::render_book("index.Rmd")

Error in x[i] <- sprintf("<a href=\"%s#%s\"", filenames[which.max(lines[lines <=  : 
  replacement has length zero

Neither editing the contents of index.Rmd to bare minimum, removing _output.yml, nor excluding all body .Rmds helps.

Cont. writing SIs

  1. Collinearity among environmental predictor variables
  2. Selecting representative BRT-models from sets of replicates
  3. Testing for concordance in ranked lists

Print abstract & keywords into YAML header from file

In manuscript/index.Rmd, I currently have the (multiline!) abstract and keywords inside the abstract: argument of the YAML header:

abstract: |
  | **Aim** Foo
  | ** Location** Bar
  | **Taxon** Wizz
  |
  | _Keywords_
  | Foo, bar, wizz

This is pretty ugly.

I want to try and keep this stuff in, say, _abstract.Rmd, and dump it on render into the YAML header:

abstract: '`r readr::read_file("_abstract.Rmd")`'

Something like that would be great. I've tried it, but it creates an odd error wherein it is as if the whole YAML header is absent (thus giving no title, author, etc.), and throwing the error:

This document format requires a nonempty <title> element.
  Please specify either 'title' or 'pagetitle' in the metadata.
  Falling back to '_main.utf8'

Fix logo display in README.md on GitHub Pages site

![](logos/...) works well on GHP, as I see in my MSc's site, but then I lose size customisation (the { width=... } does not parse on GHP).

<img src="logos/..." width=...> and ![](logos/...) work for the README on the repo display, but <img ...> breaks for GHP.

Perhaps manually reduce size of huge logos and then simply use ![](...)?

Add geographically weighted regressions

In #11 mentioned the importance of autocorrelative structure in space.

Want to apply GWR for HDS richness ~ avg QDS richness & turnover models, and also (maybe) for richness/turnover ~ environment/heterogeneity models (eventually!).

Add mixed (random) effects models

This would be especially useful for the HDS richness ~ avg QDS richness & turnover models (and maybe even the richness-environment models---unless we use BRTs).

This is is because traditional multiple linear regressions (that I have used for the richness-turnover stuff so far) assumes independence between observations. Mixed effects models structure error by the categories, not having this assumption---seemingly ideal for my comparing two regions.

Improve richness ~ enviro + roughness **more**

(#15, #43)

What I have done so far:

Richness @QDS ~ Enviro @QDS + Roughness BetwQDS

What I think would be better:

Richness  @QDS ~ Enviro  @QDS + Roughness  WithinQDS([email protected])
Richness  @HDS ~ Enviro  @HDS + Roughness  WithinHDS([email protected])
Richness @3QDS ~ Enviro @3QDS + Roughness Within3QDS([email protected])

And

Turnover  @HDS ~ Enviro  @HDS + Roughness  WithinHDS([email protected])
Turnover @3QDS ~ Enviro @3QDS + Roughness Within3QDS([email protected])

"With & without the Kogelberg" analyses no longer needed

Running these models:

foo1 <- lm(HDS_richness ~ PC1, HDS)
foo2 <- lm(HDS_richness ~ PC1, HDS[HDS$HDS_richness < 2500, ])
plot(HDS_richness ~ PC1, HDS, col = factor(HDS$region))
abline(foo1)
abline(foo2, lty = "dashed")

foo1 <- lm(QDS_richness ~ PC1, QDS[QDS$QDS_richness < 2000, ])
foo2 <- lm(QDS_richness ~ PC1, QDS)
plot(QDS_richness ~ PC1, QDS, col = factor(QDS$region))
abline(foo1)
abline(foo2, lty = "dashed")

Yields slopes from foo1 and foo2 that are almost identical.

Conclusion: the "outliers" of the Kogelberg (or the bits of the QDS raster that kind of touch the Kogelberg, because a lot of the "real" Kogelberg is excluded from the final dataset due to the edge buffer) are not a big deal!!!

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.