diff --git a/docs/404.html b/docs/404.html index fa4e10d..9e59b98 100644 --- a/docs/404.html +++ b/docs/404.html @@ -72,6 +72,9 @@
deconvolution.Rmd
The CAMDAC equation can be used to infer pure tumour DNA methylation rates, provided the following information is available per CpG:
+Here is an example for 5 CpGs from a single sample. Note: the normal copy number state is assumed diploid (2) in humans:
+
+
+# Set parameters
+bulk = c(0.3, 0.5, 0.2, 0.1, 0.9)
+normal = c(0.3, 0.9, 0.1, 0.7, 0.5)
+ploidy = c(2, 2, 1, 3, 4)
+purity = 0.8
+
+# Deconvolve methylation rates
+pure_meth = CAMDAC:::calculate_mt(bulk, normal, purity, ploidy)
+
+# Set clean rates based on threshold
+pure_meth_clean = dplyr::case_when(
+ pure_meth < 0 ~ 0,
+ pure_meth > 1 ~ 1,
+ TRUE ~ pure_meth
+)
After deconvolution, it may be useful to estimate the CpG coverage in the deconvolved tumour sample. Additionally, the highest density interval (HDI) of the methylation rate may be informative for quality control. These metrics can be calculated given additional information on bulk methylated and unmethylated read counts:
+
+
+# Optional: calculate effective coverage of the tumour
+# # Requires coverage per CpG in the bulk sample
+bulk_coverage = c(10, 20, 5, 15, 30)
+pure_effective_coverage = CAMDAC:::calculate_mt_cov(bulk_coverage, purity, ploidy)
+
+# Optional: calculate the HDI of the pure tumour methylation rate
+bulk_methylated_count = c(3, 10, 1, 2, 27)
+bulk_unmethylated_count = c(7, 10, 4, 13, 3)
+normal_methylated_count = c(3, 9, 1, 5, 2)
+normal_unmethylated_count = c(7, 11, 3, 8, 3)
+
+# HDI function (fast)
+CAMDAC:::hdi_norm_approx(
+ bulk_methylated_count,
+ bulk_unmethylated_count,
+ normal_methylated_count,
+ normal_unmethylated_count,
+ purity,
+ ploidy
+)
+
+# HDI function (most accurate)
+CAMDAC:::vec_HDIofMCMC_mt(
+ bulk_methylated_count,
+ bulk_unmethylated_count,
+ normal_methylated_count,
+ normal_unmethylated_count,
+ purity,
+ ploidy,
+ credMass=0.99
+)