Skip to content

Commit c06a606

Browse files
authored
Merge pull request #26 from waldronlab/16-update-student-vignettes-with-modern-analyses
16 update student vignettes with modern analyses
2 parents af4a6bb + 70828b7 commit c06a606

12 files changed

+496
-675
lines changed

DESCRIPTION

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Package: bugSigSimple
2-
Version: 0.99.5
2+
Version: 0.99.6
33
Date: 2022-03-07
44
Title: Simple exploratory analysis of curated microbe signatures
55
Authors@R: c(person("Ludwig", "Geistlinger", email = "[email protected]", role = c("aut", "cre")),
66
person("Chloe", "Mirzayi", email = "[email protected]", role = c("aut")),
77
person("Fatima", "Zohra", email = "[email protected]", role = "aut"),
88
person("Levi", "Waldron", email = "[email protected]", role = "aut"))
9-
Maintainer: Ludwig Geistlinger <ludwig.geistlinger@sph.cuny.edu>
9+
Maintainer: Chloe Mirzayi <chloe.mirzayi@sph.cuny.edu>
1010
Depends: R(>= 4.1.0)
1111
Imports:
1212
curatedMetagenomicData,
@@ -31,12 +31,15 @@ Imports:
3131
Suggests:
3232
BiocStyle,
3333
knitr,
34-
rmarkdown
34+
rmarkdown,
35+
broom,
36+
jtools
3537
Remotes:
3638
waldronlab/BugSigDBStats,
3739
waldronlab/bugsigdbr
3840
Description: bugSigSimple provides simple exploratory analysis of curated microbe signatures from bugsigdb.org.
3941
License: Artistic-2.0
4042
VignetteBuilder: knitr
41-
RoxygenNote: 7.1.2
43+
RoxygenNote: 7.3.2
44+
Encoding: UTF-8
4245
URL: https://waldronlab.io/bugSigSimple

NAMESPACE

100755100644
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,21 @@ importFrom(dplyr,filter)
1414
importFrom(dplyr,first)
1515
importFrom(dplyr,group_by)
1616
importFrom(dplyr,mutate)
17+
importFrom(dplyr,n)
1718
importFrom(dplyr,n_distinct)
19+
importFrom(dplyr,reframe)
1820
importFrom(dplyr,relocate)
1921
importFrom(dplyr,rename)
2022
importFrom(dplyr,rowwise)
21-
importFrom(dplyr,summarize)
23+
importFrom(dplyr,select)
2224
importFrom(dplyr,ungroup)
2325
importFrom(kableExtra,kable_styling)
2426
importFrom(kableExtra,kbl)
2527
importFrom(stats,binom.test)
2628
importFrom(stats,quantile)
2729
importFrom(stringr,str_extract)
2830
importFrom(stringr,str_replace)
31+
importFrom(tidyr,all_of)
2932
importFrom(tidyr,separate)
3033
importFrom(utils,head)
3134
importFrom(utils,relist)

R/describe_curation.R

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
#' @param dat data.frame produced by \link[bugsigdbr]{importBugSigDB}, subsetted as desired
44
#' @param n number of taxa to return (if sig.type=="both", this is the number of taxa to return for each direction)
55
#'
6-
#' @importFrom dplyr filter %>% mutate rowwise n_distinct group_by relocate rename first ungroup across
6+
#' @importFrom dplyr filter %>% mutate rowwise n_distinct group_by relocate rename first ungroup across n
77
#' @importFrom utils relist head
88
#' @importFrom stats quantile binom.test
99
#' @importFrom kableExtra kbl kable_styling
1010
#' @importFrom tidyr separate
1111
#' @importFrom stringr str_replace str_extract
12+
#' @importFrom bugsigdbr getSignatures
13+
#'
1214
#' @return kable table with increased and decreased taxa and a binomial test based on total number of studies in the data.frame
1315
#' @export
1416
#'
@@ -23,7 +25,7 @@ createTaxonTable <- function(dat, n=10){
2325
data.frame(getMostFrequentTaxa(dat, sig.type = "both", n = n),
2426
stringsAsFactors = FALSE) %>%
2527
mutate(metaphlan_name = Var1) %>%
26-
tidyr::separate(
28+
separate(
2729
col = Var1,
2830
sep = "\\|",
2931
into = dmap,
@@ -48,7 +50,7 @@ createTaxonTable <- function(dat, n=10){
4850
.countTaxon(dat = dat, x = x, direction = "decreased"))) %>%
4951
mutate(Taxon = gsub(".+\\|", "", output$metaphlan_name))
5052

51-
output %>% tidyr::separate(col="Taxon", into=c("Taxonomic Level", "Taxon Name"), sep="__") %>%
53+
output %>% separate(col="Taxon", into=c("Taxonomic Level", "Taxon Name"), sep="__") %>%
5254
mutate(`Taxonomic Level` = unname(dmap[`Taxonomic Level`])) %>%
5355
rowwise() %>%
5456
mutate( `Binomial Test pval` = .createBinomTestSummary(increased_signatures, total_signatures, wordy = FALSE)) %>%
@@ -60,7 +62,7 @@ createTaxonTable <- function(dat, n=10){
6062
if (direction[1] %in% c("increased", "decreased")){
6163
dat <- filter(dat, `Abundance in Group 1` == direction[1])
6264
}
63-
allnames <- bugsigdbr::getSignatures(dat, tax.id.type = "metaphlan")
65+
allnames <- getSignatures(dat, tax.id.type = "metaphlan")
6466
sum(vapply(allnames, function(onesignames) x %in% onesignames, FUN.VALUE = 1L))
6567
}
6668

@@ -86,22 +88,23 @@ createTaxonTable <- function(dat, n=10){
8688

8789
#' Create a table of all studies currently in data.frame
8890
#'
89-
#' @param dat data.frame produced by \link[bugsigdbr]{importBugSigDB}, subsetted as desired
91+
#' @param bsdb.df \code{data.frame} produced by \link[bugsigdbr]{importBugSigDB}, pre-filtered as desired
92+
#' @param includeAlso \code{character} with column names to additionally include in the output table (default = `NULL`)
9093
#'
91-
#' @importFrom dplyr group_by summarize %>%
94+
#' @importFrom dplyr group_by %>% select relocate reframe across n
95+
#' @importFrom tidyr all_of
9296
#' @importFrom kableExtra kbl kable_styling
9397
#' @return a data.frame of basic study information. Can be wrapped in
94-
#' kable_styling(kbl(.)) to format nicely.
98+
#' kable_styling(kbl(...)) to format nicely.
9599
#' @export
96100
#'
97101
#' @examples
98102
#' full.dat <- bugsigdbr::importBugSigDB()
99103
#' createStudyTable(full.dat)
100-
#' ## kable_styling(kbl(createStudyTable(full.dat))) #for html styling
101104

102105
createStudyTable <- function(bsdb.df, includeAlso = NULL) {
103106
# input check
104-
if (!is_null(includeAlso)) {
107+
if (!is.null(includeAlso)) {
105108
if (!all(includeAlso %in% colnames(bsdb.df))) {
106109
stop(paste(
107110
"The following columns are not found in the input data frame:",
@@ -153,7 +156,18 @@ globalVariables(
153156
"Freq",
154157
"species",
155158
"kingdom",
156-
"Var1"
159+
"Var1",
160+
# the following are necessary after the merged data
161+
"Authors",
162+
"Year",
163+
"BasicID",
164+
"PMID",
165+
"URL",
166+
"uniqueRank",
167+
"Study code",
168+
"Group 0 sample size",
169+
"Group 1 sample size",
170+
"N_signatures"
157171
)
158172
)
159173

R/simple.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ getMostFrequentTaxa <- function(dat, n=10, sig.type=c("both", "increased", "decr
8787
#' more PMID codes associated with the same ID and adds a .1, .2, for each
8888
#' duplication
8989
#'
90+
#' @param bsdb.df \code{data.frame} produced by \link[bugsigdbr]{importBugSigDB}, pre-filtered as desired
9091

9192
.make_unique_study_ID <- function(bsdb.df){
9293
bsdb_with_StudyCode <- bsdb.df %>%

man/createStudyTable.Rd

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/dot-make_unique_study_ID.Rd

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vignettes/c-section_meconium_shaimaa.Rmd

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ suppressPackageStartupMessages({
4242

4343
```{r}
4444
# use version="devel" and cache = FALSE to take the latest version from bugsigdb.org
45-
dat <- bugsigdbr::importBugSigDB(version = "devel", cache = FALSE)
45+
dat <- bugsigdbr::importBugSigDB(cache = FALSE)
4646
dim(dat)
4747
names(dat)
4848
```
@@ -85,6 +85,7 @@ subset.final <-
8585
filter(`Body site` == "Meconium") %>%
8686
arrange(PMID)
8787
```
88+
8889
Show key characteristics of the included signatures:
8990

9091
```{r}
@@ -107,13 +108,17 @@ sort(setdiff(subset.dat$PMID, subset.final$PMID))
107108
# Table of studies
108109

109110
These are the studies included in the review:
111+
110112
```{r}
111-
bugSigSimple::createStudyTable(subset.final)
113+
createStudyTable(subset.final) %>%
114+
kbl() %>%
115+
kable_styling()
112116
```
113117

114118
# Summary of taxa reported
115119

116120
This table summarizes the results for the top `n` most frequently identified taxa.
121+
117122
```{r}
118123
kable_styling(kbl(bugSigSimple::createTaxonTable(subset.final, n = 20)))
119124
```

0 commit comments

Comments
 (0)