knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 6 ) # Switch for landscape tables in pdf: output_html = ifelse(rmarkdown::metadata$output == "rmarkdown::html_vignette", TRUE, FALSE)
The object small_example
has one mock sample and three non-mock samples, with four
control species in the mock sample and three non-control species. The first column
identifies the sample, and remaining columns are
a1, a2, a3 and a4 for the four control species, and 1, 2 and 3 for the non-control species.
Corresponding entries are the number of reads of each species in each sample.
library(eDNAcutoff)
small_example
# kable() is to display the results for vignette, but the chunk above is what you # would run in command line. Thus most chunks here are repeated to format the output # better in the vignette. knitr::kable(small_example)
To remove the false positives use the function remove_false_pos()
:
small_removed <- remove_false_pos(small_example) small_removed
small_removed <- remove_false_pos(small_example) knitr::kable(small_removed)
To see which reads were set to zero use which_set_to_zero()
:
small_set_to_zero <- which_set_to_zero(small_example, small_removed) small_set_to_zero
small_set_to_zero <- which_set_to_zero(small_example, small_removed) knitr::kable(small_set_to_zero)
That used the default value of 0.2 for the parameter $\alpha$, which is the tolerance for ...add text
To test sensitivity to $\alpha$ use the function change_alpha()
for a vector
of $\alpha$ values:
alpha_values <- c(0.01, seq(0.1, 1, 0.1)) small_sens_alpha <- change_alpha(small_example, alpha_vec = alpha_values)
which returns a list containing:
alpha_values
)small_sens_alpha$num_zeroed plot(alpha_values, small_sens_alpha$num_zeroed, type = "o", col = "red", xlab = "Tolerance level", ylab = "Number of reads set to zero", ylim = c(0, max(small_sens_alpha$num_zeroed)) )
small_sens_alpha$num_mock_sp_left
small_sens_alpha$num_samp_rem_with_mock_sp
alpha_values
,
for examplealpha_values[6]
small_sens_alpha$out_list[[6]]
knitr::kable(small_sens_alpha$out_list[[6]])
and
alpha_values[7]
small_sens_alpha$out_list[[7]]
knitr::kable(small_sens_alpha$out_list[[7]])
Note how the read of 10 for sample 2 and species 2 gets kept for $\alpha=0.5$ but zeroed for $\alpha=0.6$ (corresponding to the red line increasing up at $\alpha=0.6$ in the figure).
The more realistic big_example
has XXX mock samples and XXX non-mock samples,
with ...
big_example
if(output_html){ knitr::kable(big_example) } else { library(kableExtra) kableExtra::kable(big_example, longtable = TRUE, booktabs = TRUE) %>% kable_styling(font_size = 7) %>% landscape() }
To remove the false positives:
big_removed <- remove_false_pos(big_example) big_removed
big_removed <- remove_false_pos(big_example) if(output_html){ knitr::kable(big_removed) } else { kableExtra::kable(big_removed, longtable = TRUE, booktabs = TRUE) %>% kable_styling(font_size = 7) %>% landscape() }
And again, to see which reads were set to zero use which_set_to_zero()
:
big_set_to_zero <- which_set_to_zero(big_example, big_removed) big_set_to_zero
big_set_to_zero <- which_set_to_zero(big_example, big_removed) if(output_html){ knitr::kable(big_set_to_zero) } else { kableExtra::kable(big_set_to_zero, longtable = TRUE, booktabs = TRUE) %>% kable_styling(font_size = 7) %>% landscape() }
To test sensitivity to $\alpha$, do as above (but just plot the results here)
As above, to test sensitivity to $\alpha$:
big_sens_alpha <- change_alpha(big_example, alpha_vec = alpha_values)
which returns a list containing:
alpha_values
)big_sens_alpha$num_zeroed plot(alpha_values, big_sens_alpha$num_zeroed, type = "o", col = "red", xlab = "Tolerance level", ylab = "Number of reads set to zero", ylim = c(400, max(big_sens_alpha$num_zeroed)) )
big_sens_alpha$num_mock_sp_left
big_sens_alpha$num_samp_rem_with_mock_sp
alpha_values
available as
big_sens_alpha$out_list[[6]]
etc. (not shown).TODO Seems surprising that the big data set is fairly insensitive to
$\alpha$ - look into somewhat manually and check. And set up a test()
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.