library(tibble) library(dplyr) library(wext)
knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
The data used for this example is the same data set in the "simple" example from the Raphael group's GitHub repository. The original file format was one line per sample with a list of the genes that were mutated. I have already prepared this into a tidy format in "data-raw/simple_dataset.R", as it is likely what the user will start with.
simple_dataset
In this vignette, I show how WExT works by running each step separately. The "Simple Example (the easy way)" explains how a normal user would run the analysis.
This is simply defined as
$$ \tag{1} W_R = \frac{1}{\Omega_R} \sum_{B \in \Omega_R}{B} $$
but since every row of $B \in \Omega_R$ can be considered independently, this simplifies to
$$ \tag{2} W_R = \left[ w_{ij} = \frac{r_i}{n} \right] $$
Thus, we compute the weights for the data
W_R <- calculate_row_exclusivity_weights(dat = simple_dataset, sample_col = sample_name, mutgene_col = mutated_gene)
W_R
We still need to calculate equation $(1)$, but there is no closed form formula for $W_{RC}$ as there is equation $(2)$ for $W_R$. Thus, the authors generate an empirical weight matrix $W^{N}{RC}$ by drawing $N$ matrices $\Omega^{N}{RC}$ from $\Omega_{RC}$ and calculating equation $(1)$ from those matrices. The algorithm used is explained in "Creating the Row-Column-Exclusivity Null Distribution" vignette. The process is implemented in the function calculate_row_col_exclusivity_weights()
W_RC <- calculate_row_col_exclusivity_weights(dat = simple_dataset, sample_col = sample_name, mutgene_col = mutated_gene, Q = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.