getCriticalN.Rd
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)
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
The sizes of signatures found in a set of related studies. Simulated signatures will match these in number and size.
Probability at which a critical threshold will be calculated (default: 0.05)
Number of simulations (default: 1000)
The 1 - alpha quantile of Monte Carlo simulated values for the maximum number of times any taxon is identified.
E.g. for alpha = 0.05, we expect only a 5
full.dat <- bugsigdbr::importBugSigDB()
#> Using cached version from 2022-03-31 12:35:22
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:304/1/1_antimicrobial-agent:oral-intake-of-vancomycin-(directed-against-Gram-positive-bacteria)_vs_or-placebo-(microcrystalline-cellulose)_UP
#> 18
#> bsdb:307/1/1_antimicrobial-agent:moxifloxacin-treated-group-(MXF)_vs_Negative-control-group-(CLT)_UP
#> 2
#> bsdb:307/2/1_antimicrobial-agent:DAV132+moxifloxacin-treated-group-(MXF+DAV132)_vs_moxifloxacin-treated-group-(MXF)_UP
#> 34
#> bsdb:307/3/1_antimicrobial-agent:DAV132+moxifloxacin-treated-group-(MXF+DAV132)_vs_Negative-control-group-(CLT)_UP
#> 2
#> bsdb:315/1/1_antimicrobial-agent:Infants-to-mothers-received-IAP_vs_Infants-to-mothers-didn't-receive-IAP_UP
#> 5
#> bsdb:315/2/1_antimicrobial-agent:Breast-fed-Infants-to-mothers-received-IAP_vs_breast-fed-Infants-to-mothers-didn't-receive-IAP_UP
#> 2
#> bsdb:315/3/1_antimicrobial-agent:Formula-fed-Infants-to-mothers-received-IAP_vs_Formula-fed-Infants-to-mothers-didn't-receive-IAP_UP
#> 1
#> bsdb:316/1/1_premature-birth:2-day-old-Pre-term_vs_2-day-old-Full-term-infants(born-after-uncomplicated-pregnancy)_UP
#> 7
#> bsdb:316/2/1_premature-birth:10-day-old-Pre-term_vs_10-day-old-Full-term-infants(born-after-uncomplicated-pregnancy)_UP
#> 3
#> bsdb:316/3/1_premature-birth:30-day-old-Pre-term_vs_30-day-old-Full-term-infants(born-after-uncomplicated-pregnancy)_UP
#> 3
#> bsdb:316/4/1_premature-birth:90-day-old-Pre-term_vs_90-day-old-Full-term-infants(born-after-uncomplicated-pregnancy)_UP
#> 3
#> bsdb:316/9/1_antimicrobial-agent:30-day-old-pre-tem-neonates-exposed-to-antibiotics-(IAP)_vs_30-day-old-full-term-neonates-not-exposed-to-antibiotics-(IAP/postnatal)_UP
#> 1
#> bsdb:317/1/1_antimicrobial-agent:infants-delivered-to-mothers-with_vs_without-prenatal-antibiotics-usages_UP
#> 2
#> bsdb:317/2/1_antimicrobial-agent:infants-delivered-to-mothers-with_vs_without-peripartum-antibiotics-usages_UP
#> 2
#> bsdb:320/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:320/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:320/4/1_antimicrobial-agent:infants(1-year)-to-mothers-exposed-to--antibiotics-(amoxicillin,-penicillin-or-ampicillin)_vs_infants-(1-year)-to-mothers-unexposed-to--antibiotic_UP
#> 2
#> bsdb:320/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:327/1/1_antimicrobial-agent:infants-received-short-term(<3days)-antibiotic-treatment_vs_control(no-treatment)_UP
#> 1
#> bsdb:327/2/1_antimicrobial-agent:infants-received-long-term(>5days)-antibiotic-treatment_vs_control(no-treatment)_UP
#> 2
#> bsdb:329/1/1_antimicrobial-agent:Postnatal-antibiotic-group-(2-day-old-infant)_vs_control-group_UP
#> 1
#> bsdb:329/3/1_antimicrobial-agent:IAP-group-(6-month-old-infant)_vs_control-group_UP
#> 1
#> bsdb:329/4/1_antimicrobial-agent:IAP+postnatal-antibiotic-group-(2-day-old-infant)_vs_control-group_UP
#> 1
#> bsdb:329/6/1_antimicrobial-agent:IAP+postnatal-antibiotic-group-(6-month-old-infant)_vs_control-group_UP
#> 1
#> bsdb:334/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:334/2/1_antimicrobial-agent:infants-exposed-to-antibiotic->7day-(H-group)_vs_infants-exposed-to-antibiotic-<=7day-(L-group)_UP
#> 1
#> bsdb:336/1/1_antimicrobial-agent:combination-of-penicillin-and-moxalactam-group-(PM-group_3d-sample)_vs_Antibiotic-free-group-(AF-group_3d-sample)_UP
#> 4
#> bsdb:336/2/1_antimicrobial-agent:piperacillin-tazobactam-group-(PT-group_3d-sample)_vs_Antibiotic-free-group-(AF-group_3d-sample)_UP
#> 1
#> bsdb:336/3/1_antimicrobial-agent:combination-of-penicillin-and-moxalactam-group-(PM-group_7d-sample)_vs_Antibiotic-free-group-(AF-group_7d-sample)_UP
#> 1
#> bsdb:336/4/1_antimicrobial-agent:piperacillin-tazobactam-group-(PT-group_7d-sample)_vs_Antibiotic-free-group-(AF-group_7d-sample)_UP
#> 2
#> bsdb:337/1/1_antimicrobial-agent:3-month-old-infants-either-exposed_vs_not-exposed-to-antibiotics-during-the-second-trimester_UP
#> 1
#> bsdb:337/3/1_antimicrobial-agent:12-month-old-infants-either-exposed_vs_not-exposed-to-antibiotics-during-the-second-trimester_UP
#> 4
#> bsdb:338/1/1_obesity:obese_vs_normal-weight_UP
#> 5
#> bsdb:338/2/1_obesity:obese_vs_normal-weight_UP
#> 43
#> bsdb:340/1/1_obesity:obese/overweight_vs_non-overweight/non-obese-children_UP
#> 1
#> bsdb:340/2/1_obesity:obese/overweight_vs_non-overweight/non-obese-children_UP
#> 1
#> bsdb:340/3/1_obesity:obese/overweight_vs_non-overweight/non-obese-children_UP
#> 3
#> bsdb:345/1/1_obesity:obese_vs_normal_UP
#> 1
#> bsdb:347/1/1_obesity:obese_vs_control_UP
#> 10
#> bsdb:348/1/1_obesity:obese_vs_lean_UP
#> 2
#> bsdb:348/2/1_obesity:overweight_vs_lean_UP
#> 2
#> bsdb:348/3/1_obesity:obese_vs_lean_UP
#> 1
#> bsdb:348/4/1_obesity:overweight_vs_lean_UP
#> 1
#> bsdb:350/1/1_obesity:obese_vs_normal-weight_UP
#> 4
#> bsdb:350/2/1_obesity:obesity-with-metabolic-syndrome_vs_normal-weight_UP
#> 15
#> bsdb:351/1/1_obesity:overweight/obesity_vs_normal_UP
#> 1
#> bsdb:353/1/1_obesity:obese_vs_non-obese_UP
#> 1
#> bsdb:354/1/1_obesity:overweight/obese_vs_control-(BMI-at-normal-range)_UP
#> 1
#> bsdb:355/1/1_obesity:obese-(obese/overweight/morbidly-obese)_vs_control-(lean/normal-weight)_UP
#> 1
#> bsdb:362/1/1_obesity:obese_vs_normal-weight-children_UP
#> 1
#> bsdb:367/1/1_obesity:obese_vs_normal-weight_UP
#> 6
#> bsdb:367/2/1_obesity:overweight_vs_normal-weight_UP
#> 6
#> bsdb:369/1/1_obesity:obese_vs_normal-weight_UP
#> 4
#> bsdb:369/2/1_obesity:after-onset-of-obesity_vs_before-onset-of-obesity_UP
#> 4
#> bsdb:371/1/1_obesity:obese_vs_lean_UP
#> 1
#> bsdb:371/4/1_obesity:obese_vs_lean_UP
#> 1
#> bsdb:373/1/1_obesity:overweight_vs_normal-weight-children_UP
#> 1
#> bsdb:373/2/1_obesity:overweight_vs_normal-weight-adult_UP
#> 4
#> bsdb:375/1/1_obesity:obese_vs_normal-weight_UP
#> 1
getCriticalN(relevant.sigs, my.siglengths)
#> 95%
#> 10
# Compare to observed
frequencySigs(my.sigs.increased)
#> 543 1578 1591 186803 1239 1268 1485 39778 816 853
#> 8 6 5 5 4 4 4 4 4 4