mirror of https://github.com/msberends/AMR
34 changed files with 625 additions and 126 deletions
@ -0,0 +1,119 @@
@@ -0,0 +1,119 @@
|
||||
# ==================================================================== # |
||||
# TITLE # |
||||
# Antimicrobial Resistance (AMR) Data Analysis for R # |
||||
# # |
||||
# SOURCE # |
||||
# https://github.com/msberends/AMR # |
||||
# # |
||||
# LICENCE # |
||||
# (c) 2018-2021 Berends MS, Luz CF et al. # |
||||
# Developed at the University of Groningen, the Netherlands, in # |
||||
# collaboration with non-profit organisations Certe Medical # |
||||
# Diagnostics & Advice, and University Medical Center Groningen. # |
||||
# # |
||||
# This R package is free software; you can freely use and distribute # |
||||
# it for both personal and commercial purposes under the terms of the # |
||||
# GNU General Public License version 2.0 (GNU GPL-2), as published by # |
||||
# the Free Software Foundation. # |
||||
# We created this package for both routine data analysis and academic # |
||||
# research and it was publicly released in the hope that it will be # |
||||
# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. # |
||||
# # |
||||
# Visit our website for the full manual and a complete tutorial about # |
||||
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ # |
||||
# ==================================================================== # |
||||
|
||||
#' Italicise Taxonomic Families, Genera, Species, Subspecies |
||||
#' |
||||
#' According to the binomial nomenclature, the lowest four taxonomic levels (family, genus, species, subspecies) should be printed in italic. This function finds taxonomic names within strings and makes them italic. |
||||
#' @inheritSection lifecycle Maturing Lifecycle |
||||
#' @param string a character (vector) |
||||
#' @param type type of conversion of the taxonomic names, either "markdown" or "ansi", see *Details* |
||||
#' @details |
||||
#' This function finds the taxonomic names and makes them italic based on the [microorganisms] data set. |
||||
#' |
||||
#' The taxonomic names can be italicised using markdown (the default) by adding `*` before and after the taxonomic names, or using ANSI colours by adding `\033[3m` before and `\033[23m` after the taxonomic names. If multiple ANSI colours are not available, no conversion will occur. |
||||
#' |
||||
#' This function also supports abbreviation of the genus if it is followed by a species, such as "E. coli" and "K. pneumoniae ozaenae". |
||||
#' @inheritSection AMR Read more on Our Website! |
||||
#' @export |
||||
#' @examples |
||||
#' italicise_taxonomy("An overview of Staphylococcus aureus isolates") |
||||
#' italicise_taxonomy("An overview of S. aureus isolates") |
||||
#' |
||||
#' cat(italicise_taxonomy("An overview of S. aureus isolates", type = "ansi")) |
||||
italicise_taxonomy <- function(string, type = c("markdown", "ansi")) { |
||||
if (missing(type)) { |
||||
type <- "markdown" |
||||
} |
||||
meet_criteria(string, allow_class = "character") |
||||
meet_criteria(type, allow_class = "character", has_length = 1, is_in = c("markdown", "ansi")) |
||||
|
||||
if (type == "markdown") { |
||||
before <- "*" |
||||
after <- "*" |
||||
} else if (type == "ansi") { |
||||
if (!has_colour()) { |
||||
return(string) |
||||
} |
||||
before <- "\033[3m" |
||||
after <- "\033[23m" |
||||
} |
||||
|
||||
vapply(FUN.VALUE = character(1), |
||||
string, |
||||
function(s) { |
||||
s_split <- unlist(strsplit(s, " ")) |
||||
|
||||
search_strings <- gsub("[^a-zA-Z-]", "", s_split) |
||||
|
||||
ind_species <- search_strings != "" & |
||||
search_strings %in% MO_lookup[which(MO_lookup$rank %in% c("family", |
||||
"genus", |
||||
"species", |
||||
"subspecies", |
||||
"infraspecies", |
||||
"subsp.")), |
||||
"species", |
||||
drop = TRUE] |
||||
|
||||
ind_fullname <- search_strings != "" & |
||||
search_strings %in% c(MO_lookup[which(MO_lookup$rank %in% c("family", |
||||
"genus", |
||||
"species", |
||||
"subspecies", |
||||
"infraspecies", |
||||
"subsp.")), |
||||
"fullname", |
||||
drop = TRUE], |
||||
MO_lookup[which(MO_lookup$rank %in% c("family", |
||||
"genus", |
||||
"species", |
||||
"subspecies", |
||||
"infraspecies", |
||||
"subsp.")), |
||||
"subspecies", |
||||
drop = TRUE]) |
||||
|
||||
# also support E. coli, add "E." to indices |
||||
has_previous_genera_abbr <- s_split[which(ind_species) - 1] %like_case% "^[A-Z][.]?$" |
||||
ind_species <- c(which(ind_species), which(ind_species)[has_previous_genera_abbr] - 1) |
||||
|
||||
ind <- c(ind_species, which(ind_fullname)) |
||||
|
||||
s_split[ind] <- paste0(before, s_split[ind], after) |
||||
s_paste <- paste(s_split, collapse = " ") |
||||
|
||||
# clean up a bit |
||||
s_paste <- gsub(paste0(after, " ", before), " ", s_paste, fixed = TRUE) |
||||
|
||||
s_paste |
||||
}, |
||||
USE.NAMES = FALSE) |
||||
} |
||||
|
||||
#' @rdname italicise_taxonomy |
||||
#' @export |
||||
italicize_taxonomy <- function(string, type = c("markdown", "ansi")) { |
||||
italicise(string = string, type = type) |
||||
} |
Binary file not shown.
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 82 KiB |
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
|
||||
// be compatible with the behavior of Pandoc < 2.8).
|
||||
document.addEventListener('DOMContentLoaded', function(e) { |
||||
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); |
||||
var i, h, a; |
||||
for (i = 0; i < hs.length; i++) { |
||||
h = hs[i]; |
||||
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
|
||||
a = h.attributes; |
||||
while (a.length > 0) h.removeAttribute(a[0].name); |
||||
} |
||||
}); |
@ -0,0 +1,312 @@
@@ -0,0 +1,312 @@
|
||||
<!-- Generated by pkgdown: do not edit by hand --> |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||
|
||||
<title>Italicise Taxonomic Families, Genera, Species, Subspecies โ italicise_taxonomy โข AMR (for R)</title> |
||||
|
||||
<!-- favicons --> |
||||
<link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png"> |
||||
<link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png"> |
||||
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png" /> |
||||
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png" /> |
||||
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png" /> |
||||
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png" /> |
||||
|
||||
<!-- jquery --> |
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script> |
||||
<!-- Bootstrap --> |
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.4.0/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" /> |
||||
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script> |
||||
|
||||
<!-- bootstrap-toc --> |
||||
<link rel="stylesheet" href="../bootstrap-toc.css"> |
||||
<script src="../bootstrap-toc.js"></script> |
||||
|
||||
<!-- Font Awesome icons --> |
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous" /> |
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous" /> |
||||
|
||||
<!-- clipboard.js --> |
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script> |
||||
|
||||
<!-- headroom.js --> |
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script> |
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script> |
||||
|
||||
<!-- pkgdown --> |
||||
<link href="../pkgdown.css" rel="stylesheet"> |
||||
<script src="../pkgdown.js"></script> |
||||
|
||||
|
||||
|
||||
<link href="../extra.css" rel="stylesheet"> |
||||
<script src="../extra.js"></script> |
||||
|
||||
<meta property="og:title" content="Italicise Taxonomic Families, Genera, Species, Subspecies โ italicise_taxonomy" /> |
||||
<meta property="og:description" content="According to the binomial nomenclature, the lowest four taxonomic levels (family, genus, species, subspecies) should be printed in italic. This function finds taxonomic names within strings and makes them italic." /> |
||||
<meta property="og:image" content="https://msberends.github.io/AMR/logo.png" /> |
||||
|
||||
|
||||
|
||||
|
||||
<!-- mathjax --> |
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script> |
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script> |
||||
|
||||
<!--[if lt IE 9]> |
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> |
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> |
||||
<![endif]--> |
||||
|
||||
|
||||
|
||||
</head> |
||||
|
||||
<body data-spy="scroll" data-target="#toc"> |
||||
<div class="container template-reference-topic"> |
||||
<header> |
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation"> |
||||
<div class="container"> |
||||
<div class="navbar-header"> |
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false"> |
||||
<span class="sr-only">Toggle navigation</span> |
||||
<span class="icon-bar"></span> |
||||
<span class="icon-bar"></span> |
||||
<span class="icon-bar"></span> |
||||
</button> |
||||
<span class="navbar-brand"> |
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a> |
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.6.0.9015</span> |
||||
</span> |
||||
</div> |
||||
|
||||
<div id="navbar" class="navbar-collapse collapse"> |
||||
<ul class="nav navbar-nav"> |
||||
<li> |
||||
<a href="../index.html"> |
||||
<span class="fas fa-home"></span> |
||||
|
||||
Home |
||||
</a> |
||||
</li> |
||||
<li class="dropdown"> |
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"> |
||||
<span class="fas fa-question-circle"></span> |
||||
|
||||
How to |
||||
|
||||
<span class="caret"></span> |
||||
</a> |
||||
<ul class="dropdown-menu" role="menu"> |
||||
<li> |
||||
<a href="../articles/AMR.html"> |
||||
<span class="fas fa-directions"></span> |
||||
|
||||
Conduct AMR analysis |
||||
</a> |
||||
</li> |
||||
<li> |
||||
<a href="../articles/resistance_predict.html"> |
||||
<span class="fas fa-dice"></span> |
||||
|
||||
Predict antimicrobial resistance |
||||
</a> |
||||
</li> |
||||
<li> |
||||
<a href="../articles/datasets.html"> |
||||
<span class="fas fa-database"></span> |
||||
|
||||
Data sets for download / own use |
||||
</a> |
||||
</li> |
||||
<li> |
||||
<a href="../articles/PCA.html"> |
||||
<span class="fas fa-compress"></span> |
||||
|
||||
Conduct principal component analysis for AMR |
||||
</a> |
||||
</li> |
||||
<li> |
||||
<a href="../articles/MDR.html"> |
||||
<span class="fas fa-skull-crossbones"></span> |
||||
|
||||
Determine multi-drug resistance (MDR) |
||||
</a> |
||||
</li> |
||||
<li> |
||||
<a href="../articles/WHONET.html"> |
||||
<span class="fas fa-globe-americas"></span> |
||||
|
||||
Work with WHONET data |
||||
</a> |
||||
</li> |
||||
<li> |
||||
<a href="../articles/SPSS.html"> |
||||
<span class="fas fa-file-upload"></span> |
||||
|
||||
Import data from SPSS/SAS/Stata |
||||
</a> |
||||
</li> |
||||
<li> |
||||
<a href="../articles/EUCAST.html"> |
||||
<span class="fas fa-exchange-alt"></span> |
||||
|
||||
Apply EUCAST rules |
||||
</a> |
||||
</li> |
||||
<li> |
||||
<a href="../reference/mo_property.html"> |
||||
<span class="fas fa-bug"></span> |
||||
|
||||
Get properties of a microorganism |
||||
</a> |
||||
</li> |
||||
<li> |
||||
<a href="../reference/ab_property.html"> |
||||
<span class="fas fa-capsules"></span> |
||||
|
||||
Get properties of an antibiotic |
||||
</a> |
||||
</li> |
||||
<li> |
||||
<a href="../articles/benchmarks.html"> |
||||
<span class="fas fa-shipping-fast"></ |