Markov-chaining my PhD thesis II

An overhead view of many circular vessels in a grid pattern that hold leaf fragments.

This is science, I promise.


A Markov chain perfectly summarises my entire PhD thesis:

In general, litter chemical composition and decomposition.


I posted a while back about using a Markov chain to generate sentences using my PhD thesis as input. I also posted about the {markovifyR} package for generating lyrics by The Mountain Goats.

This is a quick update to that original post, but this time I’m using {markovifyR}.

Some code

The PhD text is available from my {dray} package. I’ll remove the blank lines and ignore the preamble and references section. As a reminder, the thesis is about the decomposition of tree litter that’s been exposed to environmental stressors like elevated carbon dioxide levels and acidified streams.

library(dray)  # remotes::install_github("matt-dray/dray")
## Still D-R-A-Y
phd_text <- dray::phd  # get data
phd_text <- phd[nchar(phd) > 0]  # remove blank lines
phd_text <- phd[27:376]  # ignore preamble and references

Now to prepare the work space. {markovifyR} is a wrapper of the markovify Python module; you need to install markovify with a call to system() and then also ensure you’ve installed {markovifyR} from GitHub and also the dependency {furrr}.

# Prepare the workspace
# system("pip install markovify")
library(markovifyR)  # remotes::install_github("abresler/markovifyR")
library(furrr)  # install.packages("furrr")

The function generate_markovify_model() builds the model and markovify_text() generate some sentences based on that model.

# Build model
markov_model <- generate_markovify_model(
  input_text = phd,
  markov_state_size = 2L,
  max_overlap_total = 25,
  max_overlap_ratio = 0.7

# Generate lines
phd_speak <- markovify_text(
  markov_model = markov_model,
  maximum_sentence_length = NULL,
  output_column_name = 'phd_speak',
  count = 50,
  tries = 50,
  only_distinct = TRUE,
  return_message = TRUE
## phd_speak: Chemical composition and decomposition of leaf Dry Mass
## phd_speak: Further information on these multivariate techniques can be introduced to trees in situ, but there are few studies have indicated that litter species identity determines the predictability of invertebrate species level may not take effect until beyond the end of each CO2 treatment were constructed.
## phd_speak: The lower nutritional quality, since litter grown under elevated CO2 on litter quality and breakdown, but not sufficiently to affect leaf litter across a range of tree litter in freshwaters.
## phd_speak: Hieber, M. & Graça, M.A.S.
## phd_speak: Thesis submitted for the decomposition of small woody debris – produced under artificial conditions.
## phd_speak: For example, future studies could involve the use of macroinvertebrates of the Total Environment, 440, 115–123.
## phd_speak: This work highlights the need for further work to understand how ongoing environmental changes affect this process.
## phd_speak: Once exposed in headwaters, urban litter and the essential ecosystem process at the foundation of detrital food web structure.
## phd_speak: While the potential to disturb ecosystem functioning in headwater streams.
## phd_speak: 2.4 Effects of elevated CO2 on litter chemical composition of leaf and twig decay in some cases.
## phd_speak: A version of this study suggest that ongoing changes in atmospheric CO2 enrichment altered chemical composition and the terrestrial environments, despite the higher quality of ambient-CO2 material.
## phd_speak: Taxon richness and diversity than rural litter through time.
## phd_speak: Pairs of contrasting pH.
## phd_speak: 2.3.5 Effects of multiple environmental stressors on the effects of elevated CO2, before exposure to a woodland floor and in streams.
## phd_speak: This thesis is the result of reduced substrate availability: litters with greater AFDM tended to support a higher prevalence of structural components, making its decomposition more dependent on leaf litter chemical composition of woody decomposition and whether the effects of stream acidification – and their breakdown on a slope gradient.
## phd_speak: 2.2.3 Aquatic litter decomposition advances through stages of decay in terrestrial and aquatic invertebrate detritivores was species-specific.
## phd_speak: Urban Ecosystems, 1, 240–249.
## phd_speak: This study further confirms that atmospheric growth conditions and stream acidification had no effect and rod number nested within stream identity as the process of SWD in woodland and stream acidification – and their interaction as explanatory variables.
## phd_speak: A literature review was undertaken to investigate this relationship is reported in this thesis considered single species – both trees and invertebrates – in isolation.
## phd_speak: It is, however, generally patchy in time and space, making it difficult to trace the fate of litter will result in unpredictable consequences for decomposition, nutrient turnover, and to predict and mitigate against potentially harmful ecosystem changes.
## phd_speak: The New Phytologist, 159, 153–165.
## phd_speak: This includes a lack of response in terms of chemical change, though these effects will be plant and invertebrate species fed A. glutinosa litter in freshwaters.
## phd_speak: Carbon and nitrogen values were used to analyse control data from the water.
## phd_speak: Once exposed in headwaters, urban litter and the support of food webs.
## phd_speak: Effects of elevated CO2 or urban atmospheres.
## phd_speak: This is likely to be a result of chemical changes to atmospheric gas composition will have little effect on nitrogen and lignin, and broke down faster than rural litter had an 8% higher carbon concentration than ambient- and elevated-CO2 litters.
## phd_speak: Dashes indicate that the relationship between changing atmospheric composition, which can alter litter nutritional quality: elevated CO2 and stream acidification affected the taxon richness of invertebrates as a random effect.
## phd_speak: Bags containing litter for chemical analysis, three twigs of Betula verrucosa.
## phd_speak: Invertebrate species composition may also be altered as a prey item is likely to be unaffected where litter has grown under elevated CO2 reduced litter palatability to macroinvertebrate detritivores as a random effect.
## phd_speak: Journal of the hypotheses.
## phd_speak: It may also have also played a role, given that litter C/N ratios for each sample.
## phd_speak: To investigate these effects, twigs of Betula pendula were produced for collection at each of four time periods: 0, 28, 56 or 112 days.
## phd_speak: Canadian Journal of the Total Environment, 440, 272–279.
## phd_speak: The experimental results indicated that litter C/N ratios generally declined from 28 to 112 days only.
## phd_speak: These results suggest some scale-dependency in both aquatic and terrestrial invertebrates in choice and no-choice tests.
## phd_speak: Results for twig litters must, however, be interpreted with caution given the short nature of these cages were submerged and secured with 0.5 m steel rods.
## phd_speak: where n is the total nitrogen content of the North American Benthological Society, 16, 602–611.
## phd_speak: Litter decomposition advances through stages of decay in streams.
## phd_speak: Canhoto, C. & Cairns, J.F.
## phd_speak: Rural litter had lower invertebrate richness and diversity of terrestrial and aquatic habitats: effects at the foundation of detrital processing – a key ecosystem function of decomposition.
## phd_speak: Carbon dioxide enrichment altered chemical quality.
## phd_speak: For carbon, nitrogen and lignin, and broke down faster than ambient-CO2 twigs on a small number of organisms of all taxa.
## phd_speak: Carbon and nitrogen concentrations and greater C/N ratios.
## phd_speak: Small woody debris in temperate deciduous woodlands.
## phd_speak: The mean C/N ratio in the chemical composition changed though time.
## phd_speak: Chemical changes to plant litter and the essential ecosystem process of litter as a resource for invertebrate and microbial litter decomposers.
## phd_speak: Conversely to lignin, carbon and nutrients in woodland ecosystems could be observed.
## phd_speak: Financial and practical limitations will likely result in increased carbon and nitrogen oxides – have reduced runoff pH, acidifying headwater streams adjacent to temperate deciduous woodlands and adjacent streams, and provides a resource and habitat modifier might be affected by stream acidity appeared to be investigated in future studies.
## phd_speak: Tree litter is an important resource in woodlands, delivering a range of services to both terrestrial and aquatic ecosystems, and can inform mitigation strategies.
## phd_speak: The study of rotting detritus is not a unifying trend amongst detritivorous macroinvertebrates.

I haven’t spent much time tweaking the arguments in generate_markovify_model(), but the results are pretty amusing anyway.


I ran this a few times and picked some favourites.

Output Hot take
In general, litter chemical composition and decomposition. This is the ultimate summary of my thesis.
This thesis is the total nitrogen content of the North American Benthological Society. I’m sure the NABS has more nitrogen in its possession.
This simplicity has allowed for broad underlying principles to be linked to litter chemical composition differently depending on whether it was exposed to a labeled 0.5 m steel rod. Holy smokes, who knew that the steel rods were the deciding factor? Were they radioactive or something?
Deciduous woodlands are dependent on the parent tree. Yes, all deciduous woodlands have one central master tree from which all the others are descended.
Currently there is a key ecosystem process in temperate deciduous woodlands and streams. Yes, but what is it? I must know!
Canadian Journal of the laboratory in a randomly-ordered 3 × 3 grid. That is one niche academic journal.
I am grateful for the choice test. I designed and ran it, so I have only myself to thank.
My parents have never wavered in their responses, suggesting that caution has to be available online in the CEF. It seems the Controlled Environment Facility (CEF) cannot control for the effect of parental input; best to provide some guidance on what to do if parental influence is strong.
Bonferroni-adjusted critical significance levels were compared by pairwise PERMANOVA. That sure sounds like statistics!
This reduced decomposition rate in the University’s Open Access repository and for inter-library loan, and for inter-library loan, and for inter-library loans. Ah good, slower-decomposing books will last longer; apparently this is important for inter-library loans?

Very science, much thesis

Once again, simply copy and paste several of these sentences into your own thesis. The benefit is that you won’t have to grow any trees in a high carbon-dioxide atmosphere; you won’t have to spend months packing leaves into tiny bags; you won’t have to attach those bags to tens of IKEA cutlery holders and dunk them in frozen streams in mid-Wales; you won’t have to grind those leaves into a suspicious-looking powder and transport them cross-country for chemical analyses; you won’t have to imprison any insects against their will.

Good luck at your viva!

Session info

## [1] "Last updated 2019-09-08"
## R version 3.5.2 (2018-12-20)
## Platform: x86_64-apple-darwin15.6.0 (64-bit)
## Running under: macOS High Sierra 10.13.6
## Locale: en_GB.UTF-8 / en_GB.UTF-8 / en_GB.UTF-8 / C / en_GB.UTF-8 / en_GB.UTF-8
## Package version:
##   assertthat_0.2.1   backports_1.1.4    base64enc_0.1.3   
##   BH_1.69.0.1        blogdown_0.11      bookdown_0.9      
##   cli_1.1.0          codetools_0.2-16   compiler_3.5.2    
##   crayon_1.3.4       digest_0.6.19      dplyr_0.8.1       
##   dray_0.0.0.9000    evaluate_0.14      fansi_0.4.0       
##   furrr_0.1.0        future_1.13.0      gifski_0.8.6      
##   globals_0.12.4     glue_1.3.1         graphics_3.5.2    
##   grDevices_3.5.2    grid_3.5.2         highr_0.8         
##   htmltools_0.3.6    httpuv_1.5.1       jsonlite_1.6      
##   knitr_1.23         later_0.8.0        lattice_0.20-38   
##   listenv_0.7.0      magrittr_1.5       markdown_1.0      
##   markovifyR_0.101   Matrix_1.2-16      methods_3.5.2     
##   mime_0.7           parallel_3.5.2     pillar_1.4.1      
##   pkgconfig_2.0.2    plogr_0.2.0        plotrix_3.7-6     
##   promises_1.0.1     purrr_0.3.2        R6_2.4.0          
##   RColorBrewer_1.1-2 Rcpp_1.0.2         reticulate_1.12   
##   rlang_0.4.0        rmarkdown_1.13     servr_0.13        
##   stats_3.5.2        stringi_1.4.3      stringr_1.4.0     
##   tibble_2.1.3       tidyselect_0.2.5   tinytex_0.13      
##   tools_3.5.2        utf8_1.1.4         utils_3.5.2       
##   vctrs_0.1.0        wordcloud_2.6      xfun_0.7          
##   yaml_2.2.0         zeallot_0.1.0