diff --git a/.Rbuildignore b/.Rbuildignore index a9dbe0c..4b7f268 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -7,3 +7,5 @@ ^docs$ ^pkgdown$ ^\.github$ +^doc$ +^Meta$ diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index a7276e8..5fdbb1a 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -34,6 +34,11 @@ jobs: with: extra-packages: any::pkgdown, local::. needs: website + + - name: Manually install newer version of preprocessCore + run: | + Rscript -e "pak::pkg_install('BiocManager')" + Rscript -e "BiocManager::install('preprocessCore', configure.args = c(preprocessCore = '--disable-threading'), force= TRUE, update=TRUE, type = 'source')" - name: Build site run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) diff --git a/.gitignore b/.gitignore index 389bfeb..84eb6e5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ .DS_Store .Rproj docs +/doc/ +/Meta/ diff --git a/_pkgdown.yml b/_pkgdown.yml index bb08254..1ef8acf 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -2,3 +2,30 @@ url: http://omnideconv.org/methylDeconv/ template: bootstrap: 5 +articles: + - title: "Getting Started" + contents: + - getting_started + - visualization + - title: "Contributing" + contents: + - contribute + +navbar: + structure: + left: + - home + - reference + - articles + - news + components: + articles: + text: "Articles" + menu: + - text: "Getting Started" + href: articles/getting_started.html + - text: "Visualization" + href: articles/visualization.html + - text: "Contribute" + href: articles/contribute.html + diff --git a/vignettes/.build.timestamp b/vignettes/.build.timestamp new file mode 100644 index 0000000..e69de29 diff --git a/vignettes/contribute.R b/vignettes/contribute.R new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/vignettes/contribute.R @@ -0,0 +1 @@ + diff --git a/vignettes/contribute.Rmd b/vignettes/contribute.Rmd new file mode 100644 index 0000000..bd8b9df --- /dev/null +++ b/vignettes/contribute.Rmd @@ -0,0 +1,70 @@ +--- +title: "Contribute: Adding a New Method to methyldeconv" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Contribute: Adding a New Method to methyldeconv} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +# Contributing a New Method to methyldeconv + +Thank you for your interest in contributing to **methyldeconv**! This guide will help you add a new cell-type deconvolution method to the package. + +## 1. Fork and Clone the Repository + +- Fork the [methyldeconv GitHub repository](https://github.com/omnideconv/methyldeconv). +- Clone your fork locally and create a new branch for your feature. + +## 2. Add Your Method Implementation + +- Add a new R script for your method in the `R/` directory (e.g., `mynewmethod.R`). +- Follow the structure of existing methods (see files like `epidish.R`, `houseman.R`, etc.). +- Your function should: + - Accept a beta matrix or methylSet as input. + - Return results in a format consistent with other methods (see `run_epidish`, `run_houseman`, etc.). + - Include roxygen2 documentation. + +## 3. Register Your Method + +- If your method should be accessible via the unified interface (`deconvolute` or `deconvolute_combined`), update the relevant logic in `main.R`. +- Add your method to the list of supported methods and document any new parameters. + +## 4. Expose All Method Parameters via methyldeconv + +To ensure users can fully utilize your new method, make sure that all relevant parameters of your function are accessible through the main methyldeconv interfaces (`deconvolute` and/or `deconvolute_combined`). + +- Update the argument handling in `main.R` so that users can pass any method-specific parameters when calling these functions. +- Clearly document these parameters in your function's roxygen2 documentation and in the main interface documentation if needed. +- This approach ensures flexibility and makes your method as useful as possible for a wide range of use cases. + +## 5. Document Your Method + +- Add a roxygen2 documentation block to your function. +- Run `devtools::document()` to update the manual files in `man/`. +- Optionally, add an example to the README or a new vignette. + +## 6. Add Tests + +- Add tests for your method in `tests/testthat/` (see `test_methods.R` for examples). +- Ensure your method is covered by the test suite. + +## 7. Check and Build + +- Run `devtools::check()` to ensure your changes pass all checks. +- Build the documentation site locally with `pkgdown::build_site()` to preview your changes. + +## 8. Submit a Pull Request + +- Push your branch to your fork and open a pull request against the main repository. +- Describe your changes and reference any related issues. + +## 9. Code Review + +- Address any feedback or requested changes from the maintainers. + +--- + +For more details, see the [pkgdown documentation](https://pkgdown.r-lib.org/) and the [R packages book](https://r-pkgs.org/). + +If you have questions, feel free to open an issue or ask for help in your pull request! \ No newline at end of file diff --git a/vignettes/contribute.html b/vignettes/contribute.html new file mode 100644 index 0000000..d6fb244 --- /dev/null +++ b/vignettes/contribute.html @@ -0,0 +1,324 @@ + + + + + + + + + + + + + + +Contribute: Adding a New Method to methyldeconv + + + + + + + + + + + + + + + + + + + + + + +

Contribute: Adding a New Method to methyldeconv

+ + + +
+

Contributing a New Method to methyldeconv

+

Thank you for your interest in contributing to methyldeconv! This guide will help you add a new cell-type deconvolution method to the package.

+
+

1. Fork and Clone the Repository

+ +
+
+

2. Add Your Method Implementation

+ +
+
+

3. Register Your Method

+ +
+
+

4. Expose All Method Parameters via methyldeconv

+

To ensure users can fully utilize your new method, make sure that all relevant parameters of your function are accessible through the main methyldeconv interfaces (deconvolute and/or deconvolute_combined).

+ +
+
+

5. Document Your Method

+ +
+
+

6. Add Tests

+ +
+
+

7. Check and Build

+ +
+
+

8. Submit a Pull Request

+ +
+
+

9. Code Review

+ +
+

For more details, see the pkgdown documentation and the R packages book.

+

If you have questions, feel free to open an issue or ask for help in your pull request!

+
+
+ + + + + + + + + + + diff --git a/vignettes/getting_started.R b/vignettes/getting_started.R new file mode 100644 index 0000000..4cf7c7c --- /dev/null +++ b/vignettes/getting_started.R @@ -0,0 +1,34 @@ +## ----eval=FALSE--------------------------------------------------------------- +# # install the `pak` package manager +# install.packages("pak") +# +# pak::pkg_install("omnideconv/methyldeconv") + +## ----------------------------------------------------------------------------- +library(methyldeconv) +library(minfi) +library(minfiData) + +# use example data from Minfi +methyl_set <- minfiData::MsetEx +ratio_set <- minfi::ratioConvert(methyl_set) +beta_matrix <- minfi::getBeta(ratio_set) + +# run EpiDISH for deconvolution of example data +result <- methyldeconv::deconvolute(methyl_set = methyl_set, method = 'epidish') + +result_raw <- methyldeconv::run_epidish(beta_matrix = beta_matrix, mode='RPC') + +# you can also run multiple methods at the same time and get their results + aggregated results: +result_multiple <- methyldeconv::deconvolute_combined(methyl_set = methyl_set, + methods = c('epidish','houseman'), + array = '450k') + +## ----------------------------------------------------------------------------- +methyldeconv::results_barplot(result) + +methyldeconv::results_boxplot(result) + +## ----------------------------------------------------------------------------- +methyldeconv::results_aggregated_boxplot(result_multiple) + diff --git a/vignettes/getting_started.Rmd b/vignettes/getting_started.Rmd new file mode 100644 index 0000000..00e749d --- /dev/null +++ b/vignettes/getting_started.Rmd @@ -0,0 +1,53 @@ +--- +title: "Getting Started with methyldeconv" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Getting Started with methyldeconv} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +# Getting Started with methyldeconv + +Welcome to **methyldeconv**! This vignette will help you get up and running with cell-type deconvolution for DNA methylation data using the package's unified interface and included methods. + +## Installation + +You can install methyldeconv from GitHub using the [pak](https://github.com/r-lib/pak) package manager: + +```{r, eval=FALSE} +# install the `pak` package manager +install.packages("pak") + +pak::pkg_install("omnideconv/methyldeconv") +``` + +## Example Usage + +methyldeconv can be applied directly to a methylSet from the minfi package, or you can apply each method separately on a beta matrix with Illumina CpG IDs. + +Below, we demonstrate how to use the EpiDISH method with example data from minfi: + +```{r} +library(methyldeconv) +library(minfi) +library(minfiData) + +# use example data from Minfi +methyl_set <- minfiData::MsetEx +ratio_set <- minfi::ratioConvert(methyl_set) +beta_matrix <- minfi::getBeta(ratio_set) + +# run EpiDISH for deconvolution of example data +result <- methyldeconv::deconvolute(methyl_set = methyl_set, method = 'epidish') +``` + +## Viewing the Results + +The result of the deconvolution is a table with the estimated cell-type fractions for each sample. You can view it directly as a nicely formatted table: + +```{r} +knitr::kable(head(result), caption = "Estimated cell-type fractions for the first few samples") +``` + +For more details, see the package documentation and other vignettes! \ No newline at end of file diff --git a/vignettes/getting_started.html b/vignettes/getting_started.html new file mode 100644 index 0000000..7de0bb3 --- /dev/null +++ b/vignettes/getting_started.html @@ -0,0 +1,520 @@ + + + + + + + + + + + + + + +Getting Started with methyldeconv + + + + + + + + + + + + + + + + + + + + + + + + + +

Getting Started with methyldeconv

+ + + +
+

Getting Started with methyldeconv

+

Welcome to methyldeconv! This vignette will help you get up and running with cell-type deconvolution for DNA methylation data using the package’s unified interface and included methods.

+
+

Installation

+

You can install methyldeconv from GitHub using the pak package manager:

+ +
+
+

Example Usage

+

methyldeconv can be applied directly to a methylSet from the minfi package, or you can apply each method separately on a beta matrix with Illumina CpG IDs.

+

Both cases are demonstrated below using example data from minfi:

+ +
## Loading required package: FlowSorted.Blood.450k
+
## Loading required package: minfi
+
## Loading required package: BiocGenerics
+
## 
+## Attaching package: 'BiocGenerics'
+
## The following objects are masked from 'package:stats':
+## 
+##     IQR, mad, sd, var, xtabs
+
## The following objects are masked from 'package:base':
+## 
+##     anyDuplicated, aperm, append, as.data.frame, basename, cbind,
+##     colnames, dirname, do.call, duplicated, eval, evalq, Filter, Find,
+##     get, grep, grepl, intersect, is.unsorted, lapply, Map, mapply,
+##     match, mget, order, paste, pmax, pmax.int, pmin, pmin.int,
+##     Position, rank, rbind, Reduce, rownames, sapply, saveRDS, setdiff,
+##     table, tapply, union, unique, unsplit, which.max, which.min
+
## Loading required package: GenomicRanges
+
## Loading required package: stats4
+
## Loading required package: S4Vectors
+
## 
+## Attaching package: 'S4Vectors'
+
## The following object is masked from 'package:utils':
+## 
+##     findMatches
+
## The following objects are masked from 'package:base':
+## 
+##     expand.grid, I, unname
+
## Loading required package: IRanges
+
## Loading required package: GenomeInfoDb
+
## Loading required package: SummarizedExperiment
+
## Loading required package: MatrixGenerics
+
## Loading required package: matrixStats
+
## 
+## Attaching package: 'MatrixGenerics'
+
## The following objects are masked from 'package:matrixStats':
+## 
+##     colAlls, colAnyNAs, colAnys, colAvgsPerRowSet, colCollapse,
+##     colCounts, colCummaxs, colCummins, colCumprods, colCumsums,
+##     colDiffs, colIQRDiffs, colIQRs, colLogSumExps, colMadDiffs,
+##     colMads, colMaxs, colMeans2, colMedians, colMins, colOrderStats,
+##     colProds, colQuantiles, colRanges, colRanks, colSdDiffs, colSds,
+##     colSums2, colTabulates, colVarDiffs, colVars, colWeightedMads,
+##     colWeightedMeans, colWeightedMedians, colWeightedSds,
+##     colWeightedVars, rowAlls, rowAnyNAs, rowAnys, rowAvgsPerColSet,
+##     rowCollapse, rowCounts, rowCummaxs, rowCummins, rowCumprods,
+##     rowCumsums, rowDiffs, rowIQRDiffs, rowIQRs, rowLogSumExps,
+##     rowMadDiffs, rowMads, rowMaxs, rowMeans2, rowMedians, rowMins,
+##     rowOrderStats, rowProds, rowQuantiles, rowRanges, rowRanks,
+##     rowSdDiffs, rowSds, rowSums2, rowTabulates, rowVarDiffs, rowVars,
+##     rowWeightedMads, rowWeightedMeans, rowWeightedMedians,
+##     rowWeightedSds, rowWeightedVars
+
## Loading required package: Biobase
+
## Welcome to Bioconductor
+## 
+##     Vignettes contain introductory material; view with
+##     'browseVignettes()'. To cite Bioconductor, see
+##     'citation("Biobase")', and for packages 'citation("pkgname")'.
+
## 
+## Attaching package: 'Biobase'
+
## The following object is masked from 'package:MatrixGenerics':
+## 
+##     rowMedians
+
## The following objects are masked from 'package:matrixStats':
+## 
+##     anyMissing, rowMedians
+
## Loading required package: Biostrings
+
## Loading required package: XVector
+
## 
+## Attaching package: 'Biostrings'
+
## The following object is masked from 'package:base':
+## 
+##     strsplit
+
## Loading required package: bumphunter
+
## Loading required package: foreach
+
## Loading required package: iterators
+
## Loading required package: parallel
+
## Loading required package: locfit
+
## locfit 1.5-9.12   2025-03-05
+
## Setting options('download.file.method.GEOquery'='auto')
+
## Setting options('GEOquery.inmemory.gpl'=FALSE)
+
## → checking methyldeconv environment and dependencies
+ +
## Loading required package: IlluminaHumanMethylation450kmanifest
+
## Loading required package: IlluminaHumanMethylation450kanno.ilmn12.hg19
+ +
## Warning in check_input_beta(beta_matrix): 12 NA values detected in your beta
+## matrix. Replacing them with 0.5.
+
## RPC was chosen as default for "mode"
+
## blood was chosen as default for "reference"
+
## Starting EpiDISH deconvolution with mode RPC ...
+ +
## Warning in check_input_beta(beta_matrix): 12 NA values detected in your beta
+## matrix. Replacing them with 0.5.
+
## blood was chosen as default for "reference"
+## Starting EpiDISH deconvolution with mode RPC ...
+ +
## Warning in check_input_beta(beta_matrix): 12 NA values detected in your beta
+## matrix. Replacing them with 0.5.
+
## RPC was chosen as default for "mode"
+
## blood was chosen as default for "reference"
+
## Starting EpiDISH deconvolution with mode RPC ...
+
## 450k was chosen as default for "array"
+
## Blood was chosen as default for "compositeCellType"
+
## IlluminaHumanMethylationEPIC was chosen as default for "referencePlatform"
+
## IDOL was chosen as default for "probeSelect"
+
## [estimateCellCounts2] The function will assume that no preprocessing has been performed. Using 'preprocessQuantile' in prenormalized data is experimental and it should only be run under the user responsibility
+
## Loading required package: FlowSorted.Blood.EPIC
+
## Loading required package: ExperimentHub
+
## Loading required package: AnnotationHub
+
## Loading required package: BiocFileCache
+
## Loading required package: dbplyr
+
## 
+## Attaching package: 'AnnotationHub'
+
## The following object is masked from 'package:Biobase':
+## 
+##     cache
+
## see ?FlowSorted.Blood.EPIC and browseVignettes('FlowSorted.Blood.EPIC') for documentation
+
## loading from cache
+
## Loading required package: IlluminaHumanMethylationEPICmanifest
+
## [convertArray] Casting as IlluminaHumanMethylationEPIC
+
## [estimateCellCounts2] Combining user data with reference (flow sorted) data.
+
## Warning in asMethod(object): NAs introduced by coercion
+
## [estimateCellCounts2] Processing user and reference data together.
+
## [preprocessQuantile] Mapping to genome.
+
## Loading required package: IlluminaHumanMethylationEPICanno.ilm10b4.hg19
+
## 
+## Attaching package: 'IlluminaHumanMethylationEPICanno.ilm10b4.hg19'
+
## The following objects are masked from 'package:IlluminaHumanMethylation450kanno.ilmn12.hg19':
+## 
+##     Islands.UCSC, Locations, Manifest, Other, SNPs.132CommonSingle,
+##     SNPs.135CommonSingle, SNPs.137CommonSingle, SNPs.138CommonSingle,
+##     SNPs.141CommonSingle, SNPs.142CommonSingle, SNPs.144CommonSingle,
+##     SNPs.146CommonSingle, SNPs.147CommonSingle, SNPs.Illumina
+
## [preprocessQuantile] Fixing outliers.
+
## [preprocessQuantile] Quantile normalizing.
+
## [estimateCellCounts2] Using IDOL L-DMR probes for composition estimation.
+
## [estimateCellCounts2] Estimating proportion composition (prop), if you provide cellcounts those will be provided as counts in the composition estimation.
+

With methyldeconv you can either get the original result object of each respective method (methyldeconv::run_XXX) or a table with cell-type fractions that has a unified format between methods (methyldeconv::deconvolute). The unified results can be visualized using the methyldeconv functions results_barplot() or results_boxplot().

+ +

+ +

+

Results from a run with more than one method (methyldeconv::deconvolute_combined) can be easily visualized as well with results_aggregated_boxplot:

+ +

+

For more details, see the package documentation and other vignettes!

+
+
+ + + + + + + + + + + diff --git a/vignettes/visualization.R b/vignettes/visualization.R new file mode 100644 index 0000000..0613e07 --- /dev/null +++ b/vignettes/visualization.R @@ -0,0 +1,11 @@ +## ----------------------------------------------------------------------------- +methyldeconv::results_barplot(result) + + +## ----------------------------------------------------------------------------- +methyldeconv::results_boxplot(result) + + +## ----------------------------------------------------------------------------- +methyldeconv::results_aggregated_boxplot(result_multiple) + diff --git a/vignettes/visualization.Rmd b/vignettes/visualization.Rmd new file mode 100644 index 0000000..d7848d8 --- /dev/null +++ b/vignettes/visualization.Rmd @@ -0,0 +1,61 @@ +--- +title: "Visualization Options in methyldeconv" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Visualization Options in methyldeconv} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +# Visualization Options in methyldeconv + +methyldeconv provides several functions to visualize the results of cell-type deconvolution analyses. This vignette demonstrates how to use these visualization tools with example data. + +## Example Data + +We'll use example data from the `minfi` and `minfiData` packages: + +```{r} +library(methyldeconv) +library(minfi) +library(minfiData) + +# Example data +methyl_set <- minfiData::MsetEx +ratio_set <- minfi::ratioConvert(methyl_set) +beta_matrix <- minfi::getBeta(ratio_set) + +# Run deconvolution +result <- methyldeconv::deconvolute(methyl_set = methyl_set, method = 'epidish') +result_multiple <- methyldeconv::deconvolute_combined(methyl_set = methyl_set, + methods = c('epidish','houseman'), + array = '450k') +``` + +## Barplot of Deconvolution Results + +The `results_barplot()` function creates a barplot for each sample, showing the estimated cell-type fractions: + +```{r, fig.height=4, fig.width=8} +methyldeconv::results_barplot(result) +``` + +## Boxplot of Deconvolution Results + +The `results_boxplot()` function creates a boxplot for each cell type, summarizing the distribution of estimated fractions across samples: + +```{r, fig.height=4, fig.width=8} +methyldeconv::results_boxplot(result) +``` + +## Aggregated Boxplot for Multiple Methods + +If you run multiple methods using `deconvolute_combined()`, you can visualize the aggregated results with `results_aggregated_boxplot()`: + +```{r, fig.height=4, fig.width=8} +methyldeconv::results_aggregated_boxplot(result_multiple) +``` + +--- + +These visualization functions help you interpret and compare the results of different deconvolution methods. For more customization options, see the function documentation or explore the source code in the `R/visualization.R` file. \ No newline at end of file