Skip to content
Snippets Groups Projects
Commit e7e71fdb authored by Jeffrey Pullin's avatar Jeffrey Pullin
Browse files

Add visualisation of mean in simulations

parent 20ea08d2
No related branches found
No related tags found
No related merge requests found
Pipeline #6356 passed
---
title: "Gamma distribution visualisation"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r libraries}
library(splatter)
library(ggplot2)
```
```{r sim-setup}
set.seed(42)
# Number of samples to make the histograms from.
N <- 10000
```
```{r default-splat-params}
default_params <- newSplatParams()
default_params@mean.shape
default_params@mean.rate
```
```{r default-params}
default_params <- newSplatParams()
shape <- default_params@mean.shape
rate <- default_params@mean.rate
data.frame(x = rgamma(N, shape = shape, rate = rate)) %>%
ggplot(aes(x)) +
geom_histogram(bins = 50) +
labs(x = "Value", y = "Count") +
theme_bw()
shape
rate
shape / rate
```
```{r esimated-params}
pbmc <- readRDS(here::here("data", "pbmc3k.rds"))
est_params <- splatEstimate(as.matrix(logcounts(pbmc)))
shape <- est_params@mean.shape
rate <- est_params@mean.rate
data.frame(x = rgamma(N, shape = shape, rate = rate)) %>%
ggplot(aes(x)) +
geom_histogram(bins = 50) +
labs(x = "Value", y = "Count") +
theme_bw()
shape
rate
shape / rate
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment