Skip to content

Commit bb16350

Browse files
authored
Merge pull request #33 from annemarie-sharp/main
Rename columns for clarity in study/taxon tables
2 parents 049b422 + 4bcd6c5 commit bb16350

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

R/describe_curation.R

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,20 @@ createTaxonTable <- function(dat, n=10){
4242
fixed = TRUE
4343
))
4444
})) %>%
45-
mutate(total_signatures = sapply(metaphlan_name, function(x)
45+
mutate(`Total Signatures` = sapply(metaphlan_name, function(x)
4646
.countTaxon(dat = dat, x = x, direction = "both"))) %>%
47-
mutate(increased_signatures = sapply(metaphlan_name, function(x)
47+
mutate(`Increased Signatures` = sapply(metaphlan_name, function(x)
4848
.countTaxon(dat = dat, x = x, direction = "increased"))) %>%
49-
mutate(decreased_signatures = sapply(metaphlan_name, function(x)
49+
mutate(`Decreased Signatures` = sapply(metaphlan_name, function(x)
5050
.countTaxon(dat = dat, x = x, direction = "decreased"))) %>%
5151
mutate(Taxon = gsub(".+\\|", "", output$metaphlan_name))
5252

5353
output %>% separate(col="Taxon", into=c("Taxonomic Level", "Taxon Name"), sep="__") %>%
5454
mutate(`Taxonomic Level` = unname(dmap[`Taxonomic Level`])) %>%
5555
rowwise() %>%
56-
mutate( `Binomial Test pval` = .createBinomTestSummary(increased_signatures, total_signatures, wordy = FALSE)) %>%
56+
mutate( `Binomial Test pval` = .createBinomTestSummary(`Increased Signatures`, `Total Signatures`, wordy = FALSE)) %>%
5757
ungroup() %>%
58-
relocate(`Taxon Name`, `Taxonomic Level`, total_signatures, increased_signatures, decreased_signatures, `Binomial Test pval`)
58+
relocate(`Taxon Name`, `Taxonomic Level`, `Total Signatures`, `Increased Signatures`, `Decreased Signatures`, `Binomial Test pval`)
5959
}
6060

6161
.countTaxon = function(dat, x, direction = c("both", "increased", "decreased")){
@@ -115,24 +115,24 @@ createStudyTable <- function(bsdb.df, includeAlso = NULL) {
115115
# Core of the change is in how study IDs are generated, see function in
116116
# simple.R. NB: the function also fixes DOI links as side effect, now.
117117

118-
bsdb_with_StudyCodes.df <- .make_unique_study_ID(bsdb.df)
118+
bsdb_with_StudyIDs.df <- .make_unique_study_ID(bsdb.df)
119119

120120
# some dplyr-fu to summarize tables, with more recent syntax
121-
study_table_fixed <- bsdb_with_StudyCodes.df %>%
122-
group_by(`Study code`) %>%
121+
study_table_fixed <- bsdb_with_StudyIDs.df %>%
122+
group_by(`Study Identifier`) %>%
123123
reframe(
124-
MaxCases = max(`Group 1 sample size`),
125-
MaxControls = max(`Group 0 sample size`),
124+
Cases = max(`Group 1 sample size`),
125+
Controls = max(`Group 0 sample size`),
126126
across(
127127
all_of(
128128
c("Study design", "Condition", "PMID", "DOI", "URL", includeAlso)
129129
),
130130
.fns = function(x)
131131
paste(unique(x), collapse = "; ")
132132
),
133-
N_signatures = n()
133+
`Number of signatures` = n()
134134
) %>%
135-
relocate(N_signatures, .after = Condition)
135+
relocate(`Number of signatures`, .after = Condition)
136136

137137
return(study_table_fixed)
138138
}
@@ -147,10 +147,10 @@ globalVariables(
147147
"Study.Design",
148148
"Taxon Name",
149149
"Binomial Test pval",
150-
"total_signatures",
150+
"Total Signatures",
151151
"Abundance in Group 1",
152-
"decreased_signatures",
153-
"increased_signatures",
152+
"Decreased Signatures",
153+
"Increased Signatures",
154154
"Taxonomic Level",
155155
"metaphlan_name",
156156
"Freq",
@@ -164,10 +164,10 @@ globalVariables(
164164
"PMID",
165165
"URL",
166166
"uniqueRank",
167-
"Study code",
167+
"Study Identifier",
168168
"Group 0 sample size",
169169
"Group 1 sample size",
170-
"N_signatures"
170+
"Number of signatures"
171171
)
172172
)
173173

R/simple.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ getMostFrequentTaxa <- function(dat, n=10, sig.type=c("both", "increased", "decr
9090
#' @param bsdb.df \code{data.frame} produced by \link[bugsigdbr]{importBugSigDB}, pre-filtered as desired
9191

9292
.make_unique_study_ID <- function(bsdb.df){
93-
bsdb_with_StudyCode <- bsdb.df %>%
93+
bsdb_with_StudyIDs <- bsdb.df %>%
9494
# fix DOIs
9595
mutate(
9696
DOI = ifelse(
@@ -107,11 +107,11 @@ getMostFrequentTaxa <- function(dat, n=10, sig.type=c("both", "increased", "decr
107107
# this is arbitrary, the point is to make sure you can split overlapping
108108
# IDs into one
109109
uniqueRank = as.numeric(as.factor(paste(PMID, DOI, URL, `Authors list`))),
110-
`Study code` = ifelse(uniqueRank > 1, paste(BasicID, uniqueRank - 1, sep = "."), BasicID)
110+
`Study Identifier` = ifelse(uniqueRank > 1, paste(BasicID, uniqueRank - 1, sep = "."), BasicID)
111111
) %>%
112112
ungroup() %>%
113113
select(- BasicID, - uniqueRank) %>%
114-
relocate(`Study code`)
114+
relocate(`Study Identifier`)
115115

116-
return(bsdb_with_StudyCode)
116+
return(bsdb_with_StudyIDs)
117117
}

0 commit comments

Comments
 (0)