<commit_before>---
title: "Paper Figures"
abstract: >
    The following script reproduces all results shown in our manuscript
    "Accessible, curated metagenomic data through ExperimentHub". Please note 
    that much of this analysis occurred during the development stages of 
    curatedMetagenomicData and was written by multiple authors. As such, while 
    this analysis is methodologically sound, there may now exist more efficient 
    ways to produce the same results syntactically. For example, the `curatedMetagenomicData()`
    convenience function provides a simpler way to access the datasets, also providing 
    access to multiple versions of the same dataset if they exist. See `?curatedMetagenomicData`
    for more information.
output:
    BiocStyle::html_document
vignette: >
    %\VignetteIndexEntry{Paper Figures}
    %\VignetteEngine{knitr::rmarkdown}
    %\VignetteEncoding{UTF-8}
---


# Setup

Before running the script, please note that

* The classification analyses (Figure 1 Example 1 and Supplemental Figure 1) create very large matrices that can exceed default limits for R pointer size and the C stack limit on some systems. If you see `Error: protect(): protection stack overflow` or `Error: segfault from C stack overflow`, one of these is the issue. From GNU/Linux, these limits can be increased from the command-line as follows:

```
ulimit -s 65535   #addresses C stack overflow
R --vanilla --max-ppsize=500000    #addresses protect() error
```

If you are running on a machine with limited memory, a 32-bit installation of R, otherwise have trouble with stack overflows, or you do not want to run these classification examples, change `eval=TRUE` to `eval=FALSE` in the chunk options for the chunks named `fig1eg` and `suppfig1` to skip these analyses.

* For the sake of reproducibility, the classification analyses (Figure 1 Example 1 and Supplemental Figure 1) are conducted here by considering fixed values of "ntree" and "mtry". Although these values may be tuned using more advanced strategies (such as grid search), we observed similar accuracy results but associated with a much higher computational load.

* Several hours are needed to reproduce Supplemental Figure 3.

* When running Supplemental Figure 5 a warning occurs that "The data you have provided does not have any singletons." This is because the estimated relative abundance output of MetaPhlAn2 (and other metagenomic profiling software), even when converted to approximate counts by multiplying by read depth, does not include singletons. It is not a result of trimming, and does not affect the validity of the calculated Shannon diversity measure in as much as any relative abundance data, such as microbiome data from metagenomics, can be used to estimate alpha diversity. However, we recommend that the chao1 diversity measure not be used (Haegeman et al, The ISME Journal (2013) 7, 1092–1101; doi:10.1038/ismej.2013.10).

Then enter the following from within R to build the html:

```r
library(rmarkdown)
rmarkdown::render("PaperFigures.Rmd", "html_document")
```

# Run

```r
suppressPackageStartupMessages({
    library(curatedMetagenomicData)
    library(phyloseq)
    library(randomForest)
    library(caret)
    library(pROC)
    library(gclus)
    library(doMC) #not supported in Windows<commit_msg>fixed text in "setup" section<commit_after>---
title: "Paper Figures"
abstract: >
    The following script reproduces all results shown in our manuscript
    "Accessible, curated metagenomic data through ExperimentHub". Please note 
    that much of this analysis occurred during the development stages of 
    curatedMetagenomicData and was written by multiple authors. As such, while 
    this analysis is methodologically sound, there may now exist more efficient 
    ways to produce the same results syntactically. For example, the `curatedMetagenomicData()`
    convenience function provides a simpler way to access the datasets, also providing 
    access to multiple versions of the same dataset if they exist. See `?curatedMetagenomicData`
    for more information.
output:
    BiocStyle::html_document
vignette: >
    %\VignetteIndexEntry{Paper Figures}
    %\VignetteEngine{knitr::rmarkdown}
    %\VignetteEncoding{UTF-8}
---


# Setup

Before running the script, please note that

* The classification analyses (Figure 1 Example 1 and Supplemental Figure 1) create very large matrices that can exceed default limits for R pointer size and the C stack limit on some systems. If you see `Error: protect(): protection stack overflow` or `Error: segfault from C stack overflow`, one of these is the issue. From GNU/Linux, these limits can be increased from the command-line as follows:

   ```
   ulimit -s 65535   #addresses C stack overflow
   R --vanilla --max-ppsize=500000    #addresses protect() error
   ```
   
   If you are running on a machine with limited memory, a 32-bit installation of R, otherwise have trouble with stack overflows, or you do not want to run these classification examples, change `eval=TRUE` to `eval=FALSE` in the chunk options for the chunks named `fig1eg` and `suppfig1` to skip these analyses.

* For the sake of reproducibility, the classification analyses (Figure 1 Example 1 and Supplemental Figure 1) are conducted here by considering fixed values of "ntree" and "mtry". Better accuracies may be obtained by tuning these parameters through more advanced strategies (such as grid search), altough we observed similar results associated with a much higher computational load.

* Several hours are needed to reproduce Supplemental Figure 3.

* When running Supplemental Figure 5 a warning occurs that "The data you have provided does not have any singletons." This is because the estimated relative abundance output of MetaPhlAn2 (and other metagenomic profiling software), even when converted to approximate counts by multiplying by read depth, does not include singletons. It is not a result of trimming, and does not affect the validity of the calculated Shannon diversity measure in as much as any relative abundance data, such as microbiome data from metagenomics, can be used to estimate alpha diversity. However, we recommend that the chao1 diversity measure not be used (<NAME> al, The ISME Journal (2013) 7, 1092–1101; doi:10.1038/ismej.2013.10).

Then enter the following from within R to build the html:

```r
library(rmarkdown)
rmarkdown::render("PaperFigures.Rmd", "html_document")
```

# Run

```r
suppressPackageStartupMessages({
    library(curatedMetagenomicData)
    library(phyloseq)
    library(randomForest)
    library(caret)
    library(pROC)
    library(gclus)
    library(doMC) #not supported in Windows
{'fraction_non_alphanumeric': 0.05736480430236032, 'fraction_numerical': 0.015237526142814461, 'mean_word_length': 4.542218543046357, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6872481', 'n_tokens_mistral': 1804, 'n_tokens_neox': 1631, 'n_words': 882}