Skip to content

Instantly share code, notes, and snippets.

View Rekyt's full-sized avatar

Matthias Grenié Rekyt

View GitHub Profile
@Rekyt
Rekyt / predict_extinction_risk_iucn_status.R
Created June 1, 2023 13:37
Predict Extinction Risk from IUCN status based on EDGE2 quantification
#' Extinction probablity based on IUCN status
#'
#' This function returns an extinction probability based on a IUCN Red List
#' status. The extinction probability it returns is based on the EDGE2 metric as
#' defined by Gumbs et al. (2023) <doi:10.1371/journal.pbio.3001991>.
#' In particular, it returns the Global Endangerment 2 score (GE2).
#' See their Figure 1, Supplementary Info S1 for more information and the
#' underlying data with data sheet S4.
#'
#' The idea is that each IUCN status is associated with a median extinction risk
list(traits = structure(c(0.0672472331207246, 0.795684163691476,
0.997313872678205, 0.542126356624067, 0.266995168523863, 0.954949954524636,
0.108523507369682, 0.249139602528885, 0.588747339788824, 0.900564769050106,
0.0302994444500655, 0.407474847277626, 0.1075431893114, 0.733778670197353,
0.133502611424774, 0.103931269142777, 0.238055266439915, 0.819211864378303,
0.349372869357467, 0.661441418575123, 0.415594322374091, 0.894165905192494,
0.59261961793527, 0.74796782550402, 0.319392101606354, 0.40641696867533,
0.817589435493574, 0.207942749606445, 0.0987115791067481, 0.443528626346961,
0.24516011425294, 0.174178527202457, 0.439530419418588, 0.36717617767863,
0.570931863738224, 0.38591324724257, 0.89054117561318, 0.821960192639381,
@Rekyt
Rekyt / user-prefs.json
Created March 23, 2022 12:45
{rsprefs} RStudio Preferences Sync
{
"idiv-computer": {
"auto_append_newline": true,
"default_encoding": "UTF-8",
"doc_outline_show": "sections_and_chunks",
"document_author": "Matthias Grenié and Hugo Gruson",
"editor_theme": "Monokai",
"font_size_points": 12,
"graphics_antialiasing": "subpixel",
"highlight_r_function_calls": true,
@Rekyt
Rekyt / hal_query.R
Created February 28, 2019 14:34
Query HAL from R
# remotes::install_github("ropensci/solrium")
library(solrium)
(cli <- SolrClient$new(host = "api.archives-ouvertes.fr", path = "search",
port = NULL))
# Get all fields back
cli$search(params = list(q = "tomate", wt = "xml", fl="*"))
@Rekyt
Rekyt / papaja_word_count.Rmd
Created February 18, 2019 17:32
Minimal Reprex Papaja Word Count
---
title : "How to use papaja: An Example Manuscript Including Basic Instructions"
shorttitle : "How to use papaja"
author:
- name : "Frederik Aust"
affiliation : "1"
corresponding : yes # Define only one corresponding author
address : "Department Psychology, University of Cologne, Herbert-Lewin-Str. 2, 50931 Köln, Germany"
email : "frederik.aust@uni-koeln.de"
@Rekyt
Rekyt / plot_dependencies.R
Last active March 11, 2020 16:16
Plot dependency network copy-pasted from https://gist.github.com/crsh/c906e93c260488e7363ea606243057c2 but considered all dependencies
#' Plot network of package dependencies
#'
#' @param pkg package description, can be path or package name.
#' See \code{\link[devtools]{as.package}} for more information.
#' @param type which packages should be included in the network
#'
#' @details The resulting plot visualizes the network of package dependencies.
#' If you are trying to cut down on package dependencies look for big red
#' dots that represent a lot of upstream but few downstream dependencies.
#' @import ggplot2
@Rekyt
Rekyt / phylo_traits_clade_label.Rmd
Created February 6, 2019 14:00
Plot a phylogeny with clade labels and colored edges programmatically
---
title: "Phylogeny with traits in branches and clade labels"
author: "Matthias Grenié"
date: /today
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
@Rekyt
Rekyt / sfe_program.Rmd
Created October 17, 2018 10:00
Prettier Program for SFÉcologie 2018
---
title: "Prettier SFÉcologie 2018 Program"
author: "Matthias Grenié"
date: "17 octobre 2018"
header-includes:
- \usepackage{booktabs}
- \usepackage{longtable}
- \usepackage{array}
- \usepackage{multirow}
- \usepackage[table]{xcolor}
@Rekyt
Rekyt / arrow_pcoa.Rmd
Last active March 10, 2024 00:18
Plotting arrows on a PCoA
---
title: "Adding arrows to PCoA"
author: "Matthias Grenié"
date: "26 septembre 2018"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Function to add number ontop of geom_boxplot
library(ggplot2)
library(dplyr)
# /!\ Need to manually change the "groups" if ks_test included
add_groups_and_number = function(given_plot, ks_tests) {
y_range = ggplot_build(given_plot)$layout$panel_params[[1]]$y.range
y_upper = max(y_range)