countBug counts the frequency of the most commonly identified bug in a simulated signature. getCriticalN performs a Monte Carlo simulation to estimate the number of times the most frequent taxon is expected to be observed in a list of signatures

getCriticalN(relevant.sigs, siglengths, alpha = 0.05, nsim = 1000)

Arguments

relevant.sigs

a list of signatures that form the "background" from which taxa for simulated signatures will be drawn. These are used to estimate how frequently taxa occur

siglengths

The sizes of signatures found in a set of related studies. Simulated signatures will match these in number and size.

alpha

Probability at which a critical threshold will be calculated (default: 0.05)

nsim

Number of simulations (default: 1000)

Value

The 1 - alpha quantile of Monte Carlo simulated values for the maximum number of times any taxon is identified.

Details

E.g. for alpha = 0.05, we expect only a 5

Examples

full.dat <- bugsigdbr::importBugSigDB()
#> Using cached version from 2025-05-05 19:21:34
my.dat <- full.dat[full.dat$Curator == "Mst Afroza Parvin", ]
relevant.dat <- full.dat[full.dat$`Body site` %in% my.dat$`Body site`, ]
relevant.sigs <- bugsigdbr::getSignatures(my.dat)
my.sigs.increased <- relevant.sigs[grep("UP", names(relevant.sigs))]
(my.siglengths <- sapply(my.sigs.increased, length))
#>                                                                                                                                                 bsdb:19849869/1/1_Obesity:obese_vs_non-obese_UP 
#>                                                                                                                                                                                               1 
#>                                                                                                                  bsdb:22546742/1/1_Obesity:overweight/obese_vs_control-(BMI-at-normal-range)_UP 
#>                                                                                                                                                                                               1 
#>                                                                                                                               bsdb:23459324/4/1_Obesity:overweight-subjects_vs_lean-subjects_UP 
#>                                                                                                                                                                                               1 
#>                                                                                            bsdb:23631345/1/1_Obesity:obese-(obese/overweight/morbidly-obese)_vs_control-(lean/normal-weight)_UP 
#>                                                                                                                                                                                               1 
#>                                                              bsdb:25444008/1/1_Premature-birth:2-day-old-Pre-term-infants_vs_2-day-old-Full-term-infants(born-after-uncomplicated-pregnancy)_UP 
#>                                                                                                                                                                                               7 
#>                                                                    bsdb:25444008/2/1_Premature-birth:10-day-old-Pre-term_vs_10-day-old-Full-term-infants(born-after-uncomplicated-pregnancy)_UP 
#>                                                                                                                                                                                               3 
#>                                                                                  bsdb:25444008/3/1_Premature-birth:30-and-90-day-old-Pre-term-infants_vs_30-and-90-day-old-Full-term-infants_UP 
#>                                                                                                                                                                                               1 
#>      bsdb:25444008/9/1_Antimicrobial-agent:30-day-old-pre-tem-neonates-with-mothers-exposed-to-antibiotics-(IAP)_vs_30-day-old-full-term-neonates-not-exposed-to-antibiotics-(IAP/postnatal)_UP 
#>                                                                                                                                                                                               1 
#>                                                                                                                                             bsdb:25761741/1/1_Obesity:obese_vs_normal-weight_UP 
#>                                                                                                                                                                                               6 
#>                                                                                                                                    bsdb:26551842/1/1_Obesity:obese-children_vs_lean-children_UP 
#>                                                                                                                                                                                               2 
#>                                                                                                                               bsdb:26551842/2/1_Obesity:overweight-children_vs_lean-children_UP 
#>                                                                                                                                                                                               2 
#>                                                                                                                                    bsdb:26551842/3/1_Obesity:obese-children_vs_lean-children_UP 
#>                                                                                                                                                                                               1 
#>                                                                                                                               bsdb:26551842/4/1_Obesity:overweight-children_vs_lean-children_UP 
#>                                                                                                                                                                                               1 
#>                                                                                                                                             bsdb:26745497/1/1_Obesity:obese_vs_normal-weight_UP 
#>                                                                                                                                                                                               2 
#>                                         bsdb:27411009/1/1_Antimicrobial-agent:oral-intake-of-vancomycin-(directed-against-Gram-positive-bacteria)_vs_or-placebo-(microcrystalline-cellulose)_UP 
#>                                                                                                                                                                                              18 
#>                                                                               bsdb:28789705/1/1_Antimicrobial-agent:Infants-to-mothers-received-IAP_vs_Infants-to-mothers-didn't-receive-IAP_UP 
#>                                                                                                                                                                                               5 
#>                                                         bsdb:28789705/2/1_Antimicrobial-agent:Breast-fed-Infants-to-mothers-received-IAP_vs_breast-fed-Infants-to-mothers-didn't-receive-IAP_UP 
#>                                                                                                                                                                                               2 
#>                                                       bsdb:28789705/3/1_Antimicrobial-agent:Formula-fed-Infants-to-mothers-received-IAP_vs_Formula-fed-Infants-to-mothers-didn't-receive-IAP_UP 
#>                                                                                                                                                                                               1 
#>                                            bsdb:28808302/1/1_Antimicrobial-agent:combination-of-penicillin-and-moxalactam-group-(postnatal-day-3)_vs_Antibiotic-free-group-(postnatal-day-3)_UP 
#>                                                                                                                                                                                               5 
#>                                                             bsdb:28808302/2/1_Antimicrobial-agent:piperacillin-tazobactam-group-(postnatal-day-3)_vs_Antibiotic-free-group-(postnatal-day-3)_UP 
#>                                                                                                                                                                                               2 
#>                                            bsdb:28808302/3/1_Antimicrobial-agent:combination-of-penicillin-and-moxalactam-group-(postnatal-day-7)_vs_Antibiotic-free-group-(postnatal-day-7)_UP 
#>                                                                                                                                                                                               2 
#>                                                             bsdb:28808302/4/1_Antimicrobial-agent:piperacillin-tazobactam-group-(postnatal-day-7)_vs_Antibiotic-free-group-(postnatal-day-7)_UP 
#>                                                                                                                                                                                               2 
#>                                                                                       bsdb:29186529/1/1_Antimicrobial-agent:moxifloxacin-treated-group-(MXF)_vs_Negative-control-group-(CLT)_UP 
#>                                                                                                                                                                                               2 
#>                                                                     bsdb:29186529/2/1_Antimicrobial-agent:DAV132+moxifloxacin-treated-group-(MXF+DAV132)_vs_moxifloxacin-treated-group-(MXF)_UP 
#>                                                                                                                                                                                              34 
#>                                                                         bsdb:29186529/3/1_Antimicrobial-agent:DAV132+moxifloxacin-treated-group-(MXF+DAV132)_vs_Negative-control-group-(CLT)_UP 
#>                                                                                                                                                                                               2 
#>                                     bsdb:29554907/1/1_Antimicrobial-agent:infants(14-d-old)-exposed-to-prenatal-antibiotic-therapy-(PAT-group)_vs_prenatal-antibiotic-free-group-(PAF-group)_UP 
#>                                                                                                                                                                                               3 
#>                                                        bsdb:29554907/2/1_Antimicrobial-agent:infants-exposed-to-antibiotic->7day-(H-group)_vs_infants-exposed-to-antibiotic-<=7day-(L-group)_UP 
#>                                                                                                                                                                                               1 
#>                                                                                                                      bsdb:29935270/1/1_Obesity:overweight-children_vs_normal-weight-children_UP 
#>                                                                                                                                                                                               6 
#>                                                                                                                                      bsdb:29935270/2/1_Obesity:Overweight-children_vs_Adults_UP 
#>                                                                                                                                                                                              18 
#>                                                                                                                                         bsdb:30267022/1/1_Obesity:obese-children_vs_controls_UP 
#>                                                                                                                                                                                              10 
#>                                                                                                                                             bsdb:30534614/1/1_Obesity:obese_vs_normal-weight_UP 
#>                                                                                                                                                                                               4 
#>                                                                                                                  bsdb:30534614/2/1_Obesity:after-onset-of-obesity_vs_before-onset-of-obesity_UP 
#>                                                                                                                                                                                               4 
#>                     bsdb:31006170/1/1_Antimicrobial-agent:infants(6-weeks)-to-mothers-exposed-to-intrapartum-antibiotic_vs_infants-(6-weeks)-to-mothers-unexposed-to--intrapartum-antibiotic_UP 
#>                                                                                                                                                                                               4 
#>                       bsdb:31006170/2/1_Antimicrobial-agent:infants(1-year)-to-mothers-exposed-to-intrapartum-antibiotic_vs_infants-(1-year)-to-mothers-unexposed-to--intrapartum-antibiotic_UP 
#>                                                                                                                                                                                               4 
#>                                     bsdb:31006170/4/1_Antimicrobial-agent:infants(1-year)-to-mothers-exposed-to-the-penicillin-group_vs_infants-(1-year)-to-mothers-unexposed-to--antibiotic_UP 
#>                                                                                                                                                                                               2 
#>                                bsdb:31006170/5/1_Antimicrobial-agent:infants(6-weeks)-to-mothers-exposed-to-multi-class-antibiotics_vs_infants-(6-weeks)-to-mothers-unexposed-to--antibiotic_UP 
#>                                                                                                                                                                                               1 
#>       bsdb:31226994/1/1_Antimicrobial-agent:3-month-old-infants-exposed-to-antibiotics-in-the-second-trimester_vs_3-month-old-infants-not-exposed-to-antibiotics-during-the-second-trimester_UP 
#>                                                                                                                                                                                               2 
#> bsdb:31226994/3/1_Antimicrobial-agent:12-month-old-infants-exposed-to-antibiotics-during-the-second-trimester_vs_12-month-old-infants-not-exposed-to-antibiotics-during-the-second-trimester_UP 
#>                                                                                                                                                                                               4 
#>                                                                                         bsdb:31337807/1/1_Antimicrobial-agent:Postnatal-antibiotic-group-(2-day-old-infant)_vs_control-group_UP 
#>                                                                                                                                                                                               2 
#>                                                                                                        bsdb:31337807/3/1_Antimicrobial-agent:IAP-group-(6-month-old-infant)_vs_control-group_UP 
#>                                                                                                                                                                                               2 
#>                                                                                     bsdb:31337807/4/1_Antimicrobial-agent:IAP+postnatal-antibiotic-group-(2-day-old-infant)_vs_control-group_UP 
#>                                                                                                                                                                                               1 
#>                                                                                   bsdb:31337807/6/1_Antimicrobial-agent:IAP+postnatal-antibiotic-group-(6-month-old-infant)_vs_control-group_UP 
#>                                                                                                                                                                                               1 
#>                                                                                                                                       bsdb:31934770/1/1_Obesity:overweight/obesity_vs_normal_UP 
#>                                                                                                                                                                                               1 
#>                                                                                                                           bsdb:31976177/1/1_Obesity:obese-children_vs_normal-weight-children_UP 
#>                                                                                                                                                                                               5 
#>                                                                                                                           bsdb:31976177/2/1_Obesity:obese-children_vs_normal-weight-children_UP 
#>                                                                                                                                                                                              44 
#>                                                                                                                           bsdb:32143621/1/1_Obesity:Obese-children-(O)_vs_Normal-weight-(NW)_UP 
#>                                                                                                                                                                                               3 
#>                                                                                                        bsdb:32143621/2/1_Obesity:Obesity-with-metabolic-syndrome-(OMS)_vs_Normal-weight-(NW)_UP 
#>                                                                                                                                                                                              13 
#>                                          bsdb:32380969/1/1_Antimicrobial-agent:infants-who-received-short-term-or-long-term-antibiotic-treatment---week-1_vs_control-(no-treatment)---week-1_UP 
#>                                                                                                                                                                                               1 
#>                                                     bsdb:32380969/2/1_Antimicrobial-agent:infants-received-long-term(>5days)-antibiotic-treatment---week-2_vs_control(no-treatment)---week-2_UP 
#>                                                                                                                                                                                               1 
#>                                                                                                                                    bsdb:32429742/1/1_Obesity:obese_vs_normal-weight-children_UP 
#>                                                                                                                                                                                               1 
getCriticalN(relevant.sigs, my.siglengths)
#> 95% 
#>   9 
# Compare to observed
frequencySigs(my.sigs.increased)
#>   1239   1578 186803    543    976 135858   1591  39778    853   1224 
#>      6      6      5      5      5      4      4      4      4      3