{"items":["5f7007605f9fcc0017abe9e4","5f7007605f9fcc0017abe9e5","5f7007605f9fcc0017abe9e6"],"styles":{"galleryType":"Columns","groupSize":1,"showArrows":true,"cubeImages":true,"cubeType":"max","cubeRatio":1.7777777777777777,"isVertical":true,"gallerySize":30,"collageAmount":0,"collageDensity":0,"groupTypes":"1","oneRow":false,"imageMargin":30,"galleryMargin":0,"scatter":0,"chooseBestGroup":true,"smartCrop":false,"hasThumbnails":false,"enableScroll":true,"isGrid":true,"isSlider":false,"isColumns":false,"isSlideshow":false,"cropOnlyFill":false,"fixedColumns":0,"enableInfiniteScroll":true,"isRTL":false,"minItemSize":50,"rotatingGroupTypes":"","rotatingCubeRatio":"","gallerySliderImageRatio":1.7777777777777777,"numberOfImagesPerRow":3,"numberOfImagesPerCol":1,"groupsPerStrip":0,"borderRadius":0,"boxShadow":0,"gridStyle":0,"mobilePanorama":false,"placeGroupsLtr":false,"viewMode":"preview","thumbnailSpacings":4,"galleryThumbnailsAlignment":"bottom","isMasonry":false,"isAutoSlideshow":false,"slideshowLoop":false,"autoSlideshowInterval":4,"bottomInfoHeight":0,"titlePlacement":["SHOW_ON_THE_RIGHT","SHOW_BELOW"],"galleryTextAlign":"center","scrollSnap":false,"itemClick":"nothing","fullscreen":true,"videoPlay":"hover","scrollAnimation":"NO_EFFECT","slideAnimation":"SCROLL","scrollDirection":0,"overlayAnimation":"FADE_IN","arrowsPosition":0,"arrowsSize":23,"watermarkOpacity":40,"watermarkSize":40,"useWatermark":true,"watermarkDock":{"top":"auto","left":"auto","right":0,"bottom":0,"transform":"translate3d(0,0,0)"},"loadMoreAmount":"all","defaultShowInfoExpand":1,"allowLinkExpand":true,"expandInfoPosition":0,"allowFullscreenExpand":true,"fullscreenLoop":false,"galleryAlignExpand":"left","addToCartBorderWidth":1,"addToCartButtonText":"","slideshowInfoSize":200,"playButtonForAutoSlideShow":false,"allowSlideshowCounter":false,"hoveringBehaviour":"NEVER_SHOW","thumbnailSize":120,"magicLayoutSeed":1,"imageHoverAnimation":"NO_EFFECT","imagePlacementAnimation":"NO_EFFECT","calculateTextBoxWidthMode":"PERCENT","textBoxHeight":60,"textBoxWidth":200,"textBoxWidthPercent":75,"textImageSpace":10,"textBoxBorderRadius":0,"textBoxBorderWidth":0,"loadMoreButtonText":"","loadMoreButtonBorderWidth":1,"loadMoreButtonBorderRadius":0,"imageInfoType":"ATTACHED_BACKGROUND","itemBorderWidth":0,"itemBorderRadius":0,"itemEnableShadow":false,"itemShadowBlur":20,"itemShadowDirection":135,"itemShadowSize":10,"imageLoadingMode":"BLUR","expandAnimation":"NO_EFFECT","imageQuality":90,"usmToggle":false,"usm_a":0,"usm_r":0,"usm_t":0,"videoSound":false,"videoSpeed":"1","videoLoop":true,"gallerySizeType":"px","gallerySizePx":1000,"allowTitle":true,"allowContextMenu":true,"textsHorizontalPadding":-30,"itemBorderColor":{"themeName":"color_12","value":"rgba(230,230,230,0)"},"showVideoPlayButton":true,"galleryLayout":2,"calculateTextBoxHeightMode":"MANUAL","targetItemSize":1000,"selectedLayout":"2|bottom|1|max|true|0|true","layoutsVersion":2,"selectedLayoutV2":2,"isSlideshowFont":true,"externalInfoHeight":60,"externalInfoWidth":0.75},"container":{"width":300,"galleryWidth":330,"galleryHeight":0,"scrollBase":0,"height":null}}

# An intuitive understanding of Bayesian statistics

In *previous post*, we mentioned that each locus across genome owns different noise rate due to variety of technical / biological factors. Bayesian method may better detect genuine variants by adding these factors into consideration. Before diving into more sophisticated somatic variant detection method, let’s spend a bit of time on the background of Bayesian inference.

**The frame of Bayesian model**
**
The main idea of Bayesian statistics is to combine current data with prior experience / data for better estimation**. Three major elements in Bayesian model are: Prior probability, Likelihood function and Posterior probability. Assuming we would like to estimate the probability of event y occurring with some prior knowledge θ that is related to y.

Where:

**P(θ)** is prior probability, representing the probability of event θ.

**P(y|θ)** is Likelihood function, representing the conditional probability of event y occurring given previous data θ is true.

**P(θ|y)** is posterior probability, representing the conditional probability of previous data y given current data θ is true.

**P(y)** is probability of event y occurring

**Why combines previous data?**
Now we like to develop a screening method for cancer that raises in 0.05% of population. In a typical retrospective study, we usually set case-control group (100 patients vs 100 healthy) to develop / evaluate the method. Assuming our method achieves 99% sensitivity and 99% specificity. How good will this method perform in real world screening task?

**P(θ)** is prior probability, representing the 0.05% occurrence of cancer in population.

**P(y|θ)** is the probability of being positively screened in patient population, aka sensitivity of 99%

**P(y) **is the probability of being positively screened in entire population. This includes positively screened patients (0.05%*99%) and positively screened healthy ((1-0.05%)*(1-99%)).

**P(θ│y)** is posterior probability, representing probability of being a cancer patient in positively screened population, aka positive predictive value (PPV).

Through calculation above, it turns out that only 4.95% positively screened are real cancer patients. This example demonstrates how inappropriate to evaluate the performance of the model when the real world scenario is ignored (in this case, the cancer occurrence in real world population).

**An example to demonstrate Bayesian model**
** The essence of Bayesian inference is to combine current data (Likelihood) and previous data (Prior probability) to calculate the Posterior probability.** This way we can make better estimation by integrating additional samples or relevant information. We will demonstrate this using an example of estimating the probability of mouse getting cancer. We set a scenario where only limited mouse samples are available in current experiment, we would like to take advantage of data gathered from previous related experiments and use Bayesian method for better estimation.

*Setting prior probability*
To model the probability of mouse getting cancer, we use Binomial distribution as Likelihood function where θ is the probability of mouse getting cancer. Beta distribution is used to as Prior probability. We choose Beta distribution because it is a continuous distribution constraint within [0, 1] and can be conveniently seen as probability of probability. Therefore, we have θ~Beta(α,β). When the exact probability of mouse getting cancer is unknown, Beta distribution gives use a rough estimation based on prior knowledge.

Based on previous data, we know the amount of mouse getting cancer and free of cancer (α,β) and can calculate the parameter and shape of Beta distribution (θ~Beta(2.6,9.7),μ=0.211 and σ^2=0.112).

*Updating prior probability*
In currently experiment, we obtained 15 mouse among which five are cancerous. We can now use this additional data to update the parameter of conjugate prior probability and drive posterior distribution.

As demonstrated above, Posterior distribution follows beta(α+k, β+n-k), where k and n-k represents cancerous mouse and healthy mouse in current experiment respectively. The final updated posterior distribution become beta(7.6,19.7) which intuitively is the compromise between Prior and Likelihood as showed in figure above. The final shape of posterior depends on the ‘confidence’ (sample size and variance) we have on prior knowledge and current data.