From 933694294fcc66f1c36d0c6cff0ebb644daeb09f Mon Sep 17 00:00:00 2001 From: alex-d13 Date: Tue, 29 Jul 2025 22:30:40 +0200 Subject: [PATCH 1/5] additional documentation about aggregation of methods --- .gitignore | 1 + R/main.R | 53 ++++++++++++- _pkgdown.yml | 3 + deconvMe.Rproj | 18 ++++- man/deconvolute_combined.Rd | 54 +++++++++++++- vignettes/combined_methods.Rmd | 131 +++++++++++++++++++++++++++++++++ vignettes/signatures.Rmd | 1 + 7 files changed, 255 insertions(+), 6 deletions(-) create mode 100644 vignettes/combined_methods.Rmd diff --git a/.gitignore b/.gitignore index 84eb6e5..1574846 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ docs /doc/ /Meta/ +*.Rproj diff --git a/R/main.R b/R/main.R index a748832..08f3727 100755 --- a/R/main.R +++ b/R/main.R @@ -75,7 +75,56 @@ deconvolute <- function(methyl_set, method=deconvolution_methods, scale_results return(result) } -#' Run selected set of methods and average results +#' Run multiple deconvolution methods and create aggregated results +#' +#' This function runs multiple cell-type deconvolution methods on the same methylation data and creates both individual method results and an aggregated (averaged) estimate. The aggregation approach can help reduce method-specific biases and provide more robust cell-type proportion estimates. +#' +#' \strong{How it works:} +#' \itemize{ +#' \item Runs each specified method independently on the methylation data +#' \item Standardizes cell-type names across methods using \code{rename_cell_types()} +#' \item For MethylResolver specifically, combines Tnaive and Tmem into "T cell CD4+" to match other methods +#' \item Calculates the mean estimate for each cell type across all methods (aggregated results) +#' \item Returns both individual method results and aggregated results in a long-format data frame +#' } +#' +#' \strong{Cell-type standardization:} +#' The function uses \code{rename_cell_types()} to standardize cell-type names across different methods. This mapping includes: +#' \itemize{ +#' \item CD8T/CD8/CD8T-cells_EPIC → "T cell CD8+" +#' \item CD4T/CD4T-cells_EPIC → "T cell CD4+" +#' \item B/Bcell/B-cells_EPIC → "B cell" +#' \item NK/NK-cells_EPIC → "NK cell" +#' \item Mono/Mon/Monocytes_EPIC → "Monocyte" +#' \item Neu/Neutro/Neutrophils/Neutrophils_EPIC → "Neutrophil" +#' \item Any unrecognized cell types → "other" +#' } +#' +#' \strong{Meaning of 'other' cell types:} +#' The "other" category includes: +#' \itemize{ +#' \item Cell types that are not in the standardized mapping above +#' \item Method-specific cell types that don't have direct equivalents in other methods +#' \item Rare or specialized cell populations that are only detected by certain methods +#' } +#' +#' \strong{Limitations of the aggregation approach:} +#' \itemize{ +#' \item \strong{Method heterogeneity:} Different methods use different algorithms, reference datasets, and cell-type definitions, which may not be directly comparable +#' \item \strong{Missing data handling:} If a method fails to estimate a particular cell type, it may be excluded from the aggregation, potentially biasing results +#' \item \strong{Equal weighting:} The current implementation gives equal weight to all methods, regardless of their individual performance or reliability +#' \item \strong{Cell-type coverage:} Methods may detect different sets of cell types, leading to incomplete coverage in aggregated results +#' \item \strong{No confidence intervals:} The aggregation provides point estimates without uncertainty quantification +#' } +#' +#' \strong{Best practices:} +#' \itemize{ +#' \item Use methods that are well-validated for your specific tissue type and experimental design +#' \item Consider the biological context when interpreting aggregated results +#' \item Validate results against independent measurements when possible +#' \item Be cautious when aggregating methods with very different cell-type definitions +#' \item Consider using the individual method results to assess consistency across methods +#' } #' #' @param methyl_set A minfi MethylSet #' @param array type of methylation array that was used. possible options are '450k' and 'EPIC' @@ -85,7 +134,7 @@ deconvolute <- function(methyl_set, method=deconvolution_methods, scale_results #' Defaults to FALSE. #' @param ... Additional parameters, passed to the algorithm used. See individual method documentations for details. #' -#' @return dataframe with results of all selected methods as well as the combined estimates +#' @return A data frame with columns: sample, method, celltype, value. Contains results from all individual methods plus an 'aggregated' method that averages the estimates across methods. #' @export #' @examples #' diff --git a/_pkgdown.yml b/_pkgdown.yml index 5aca2c7..29208e2 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -8,6 +8,7 @@ articles: - getting_started - visualization - signatures + - combined_methods - title: "Contributing" contents: - contribute @@ -29,6 +30,8 @@ navbar: href: articles/visualization.html - text: "Signature Matrices & Custom CpGs" href: articles/signatures.html + - text: "Combined Methods Approach" + href: articles/combined_methods.html - text: "Contribute" href: articles/contribute.html diff --git a/deconvMe.Rproj b/deconvMe.Rproj index 0519ecb..21a4da0 100644 --- a/deconvMe.Rproj +++ b/deconvMe.Rproj @@ -1 +1,17 @@ - \ No newline at end of file +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source diff --git a/man/deconvolute_combined.Rd b/man/deconvolute_combined.Rd index 4d79c84..90a7db6 100644 --- a/man/deconvolute_combined.Rd +++ b/man/deconvolute_combined.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/main.R \name{deconvolute_combined} \alias{deconvolute_combined} -\title{Run selected set of methods and average results} +\title{Run multiple deconvolution methods and create aggregated results} \usage{ deconvolute_combined( methyl_set, @@ -26,10 +26,58 @@ Defaults to FALSE.} \item{...}{Additional parameters, passed to the algorithm used. See individual method documentations for details.} } \value{ -dataframe with results of all selected methods as well as the combined estimates +A data frame with columns: sample, method, celltype, value. Contains results from all individual methods plus an 'aggregated' method that averages the estimates across methods. } \description{ -Run selected set of methods and average results +This function runs multiple cell-type deconvolution methods on the same methylation data and creates both individual method results and an aggregated (averaged) estimate. The aggregation approach can help reduce method-specific biases and provide more robust cell-type proportion estimates. +} +\details{ +\strong{How it works:} +\itemize{ +\item Runs each specified method independently on the methylation data +\item Standardizes cell-type names across methods using \code{rename_cell_types()} +\item For MethylResolver specifically, combines Tnaive and Tmem into "T cell CD4+" to match other methods +\item Calculates the mean estimate for each cell type across all methods (aggregated results) +\item Returns both individual method results and aggregated results in a long-format data frame +} + +\strong{Cell-type standardization:} +The function uses \code{rename_cell_types()} to standardize cell-type names across different methods. This mapping includes: +\itemize{ +\item CD8T/CD8/CD8T-cells_EPIC → "T cell CD8+" +\item CD4T/CD4T-cells_EPIC → "T cell CD4+" +\item B/Bcell/B-cells_EPIC → "B cell" +\item NK/NK-cells_EPIC → "NK cell" +\item Mono/Mon/Monocytes_EPIC → "Monocyte" +\item Neu/Neutro/Neutrophils/Neutrophils_EPIC → "Neutrophil" +\item Any unrecognized cell types → "other" +} + +\strong{Meaning of 'other' cell types:} +The "other" category includes: +\itemize{ +\item Cell types that are not in the standardized mapping above +\item Method-specific cell types that don't have direct equivalents in other methods +\item Rare or specialized cell populations that are only detected by certain methods +} + +\strong{Limitations of the aggregation approach:} +\itemize{ +\item \strong{Method heterogeneity:} Different methods use different algorithms, reference datasets, and cell-type definitions, which may not be directly comparable +\item \strong{Missing data handling:} If a method fails to estimate a particular cell type, it may be excluded from the aggregation, potentially biasing results +\item \strong{Equal weighting:} The current implementation gives equal weight to all methods, regardless of their individual performance or reliability +\item \strong{Cell-type coverage:} Methods may detect different sets of cell types, leading to incomplete coverage in aggregated results +\item \strong{No confidence intervals:} The aggregation provides point estimates without uncertainty quantification +} + +\strong{Best practices:} +\itemize{ +\item Use methods that are well-validated for your specific tissue type and experimental design +\item Consider the biological context when interpreting aggregated results +\item Validate results against independent measurements when possible +\item Be cautious when aggregating methods with very different cell-type definitions +\item Consider using the individual method results to assess consistency across methods +} } \examples{ diff --git a/vignettes/combined_methods.Rmd b/vignettes/combined_methods.Rmd new file mode 100644 index 0000000..db429e0 --- /dev/null +++ b/vignettes/combined_methods.Rmd @@ -0,0 +1,131 @@ +--- +title: "Combined Methods Approach in deconvMe" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Combined Methods Approach in deconvMe} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +# Combined Methods Approach in deconvMe + +The `deconvolute_combined()` function in deconvMe allows you to run multiple cell-type deconvolution methods simultaneously and create aggregated results. This approach can help reduce method-specific biases and provide more robust estimates of cell-type proportions. + +## Basic Usage + +```{r, message=FALSE, warning=FALSE} +library(deconvMe) +library(minfiData) +options(matrixStats.useNames.NA = "deprecated") + +# Example data +methyl_set <- minfiData::MsetEx + +# Run multiple methods +result_combined <- deconvolute_combined( + methyl_set = methyl_set, + methods = c('epidish', 'houseman', 'methylcc'), + array = '450k' +) +``` + +## Understanding the Output + +The combined results include both individual method results and aggregated estimates: + +```{r} +# View the structure +head(result_combined) + +# Check available methods +unique(result_combined$method) + +# Check available cell types +unique(result_combined$celltype) +``` + +## Cell-Type Standardization + +The function automatically standardizes cell-type names across methods: + +```{r} +# Example of cell-type mapping +library(dplyr) + +# Show how cell types are mapped +cell_type_mapping <- data.frame( + Original = c("CD8T", "CD4T", "B", "NK", "Mono", "Neu", "Unknown"), + Standardized = c("T cell CD8+", "T cell CD4+", "B cell", "NK cell", "Monocyte", "Neutrophil", "other") +) +knitr::kable(cell_type_mapping, caption = "Cell-type standardization mapping") +``` + +## The "Other" Category + +The "other" category includes: +- Cell types not in the standardized mapping +- Method-specific cell types without equivalents +- Rare or specialized cell populations + +This category should be interpreted carefully, as it may represent: +- True rare cell types +- Method-specific artifacts +- Incomplete cell-type coverage + +## Visualizing Combined Results + +```{r, fig.height=6, fig.width=10, message=FALSE, warning=FALSE} +# Create visualization of individual vs aggregated results +library(ggplot2) + +# Filter for one sample to show the comparison +sample_data <- result_combined[result_combined$sample == result_combined$sample[1], ] + +ggplot(sample_data, aes(x = celltype, y = value, fill = method)) + + geom_bar(stat = "identity", position = "dodge") + + labs(title = "Individual Methods vs Aggregated Results", + subtitle = paste("Sample:", sample_data$sample[1]), + y = "Estimated Fraction", + x = "Cell Type") + + theme_minimal() + + theme(axis.text.x = element_text(angle = 45, hjust = 1)) +``` + +## Limitations and Considerations + +### 1. Method Heterogeneity +Different methods use different algorithms and reference datasets, which may not be directly comparable. Consider: +- Whether methods are validated for your tissue type +- The quality and relevance of reference datasets +- Algorithm-specific assumptions + +### 2. Equal Weighting +The current implementation gives equal weight to all methods. This may not be optimal if: +- Some methods are more reliable for your specific use case +- Methods have different levels of validation +- You have prior knowledge about method performance + +### 3. Missing Data +If a method fails to estimate a particular cell type, it may be excluded from aggregation, potentially biasing results. + +### 4. Cell-Type Coverage +Methods may detect different sets of cell types, leading to incomplete coverage in aggregated results. + +## Quality Control +```{r} +# Check for consistency across methods +consistency_check <- result_combined %>% + group_by(sample, celltype) %>% + summarise( + mean_value = mean(value), + sd_value = sd(value), + cv = sd_value / mean_value, # coefficient of variation + .groups = 'drop' + ) %>% + filter(!is.na(mean_value)) + +# Identify cell types with high variability across methods +high_variability <- consistency_check %>% + filter(cv > 0.5) # arbitrary threshold +``` + diff --git a/vignettes/signatures.Rmd b/vignettes/signatures.Rmd index 00ad5d0..4b6c9e3 100644 --- a/vignettes/signatures.Rmd +++ b/vignettes/signatures.Rmd @@ -27,6 +27,7 @@ deconvMe provides functions to access the signature matrices used by each deconv ```{r, message=FALSE, warning=FALSE} library(deconvMe) +options(matrixStats.useNames.NA = "deprecated") ``` ## EpiDISH From 58101c636a7b0ee32ca1c9d334d1c63befcee628 Mon Sep 17 00:00:00 2001 From: alex-d13 Date: Wed, 30 Jul 2025 08:58:03 +0200 Subject: [PATCH 2/5] more documentation on reference-based vs. reference-free --- R/main.R | 8 -------- man/deconvolute_combined.Rd | 9 --------- vignettes/signatures.Rmd | 23 ++++++++++++++++++++--- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/R/main.R b/R/main.R index 08f3727..c1255bd 100755 --- a/R/main.R +++ b/R/main.R @@ -117,14 +117,6 @@ deconvolute <- function(methyl_set, method=deconvolution_methods, scale_results #' \item \strong{No confidence intervals:} The aggregation provides point estimates without uncertainty quantification #' } #' -#' \strong{Best practices:} -#' \itemize{ -#' \item Use methods that are well-validated for your specific tissue type and experimental design -#' \item Consider the biological context when interpreting aggregated results -#' \item Validate results against independent measurements when possible -#' \item Be cautious when aggregating methods with very different cell-type definitions -#' \item Consider using the individual method results to assess consistency across methods -#' } #' #' @param methyl_set A minfi MethylSet #' @param array type of methylation array that was used. possible options are '450k' and 'EPIC' diff --git a/man/deconvolute_combined.Rd b/man/deconvolute_combined.Rd index 90a7db6..819b92f 100644 --- a/man/deconvolute_combined.Rd +++ b/man/deconvolute_combined.Rd @@ -69,15 +69,6 @@ The "other" category includes: \item \strong{Cell-type coverage:} Methods may detect different sets of cell types, leading to incomplete coverage in aggregated results \item \strong{No confidence intervals:} The aggregation provides point estimates without uncertainty quantification } - -\strong{Best practices:} -\itemize{ -\item Use methods that are well-validated for your specific tissue type and experimental design -\item Consider the biological context when interpreting aggregated results -\item Validate results against independent measurements when possible -\item Be cautious when aggregating methods with very different cell-type definitions -\item Consider using the individual method results to assess consistency across methods -} } \examples{ diff --git a/vignettes/signatures.Rmd b/vignettes/signatures.Rmd index 4b6c9e3..d32b614 100644 --- a/vignettes/signatures.Rmd +++ b/vignettes/signatures.Rmd @@ -7,11 +7,28 @@ vignette: > %\VignetteEncoding{UTF-8} --- -# Background: What Are Signature Matrices? +# Background: Reference-Based vs Reference-Free Deconvolution -Cell-type deconvolution methods rely on *signature matrices* (also called reference matrices or basis matrices) to estimate the proportions of different cell types in a heterogeneous DNA methylation sample. A signature matrix is a table where each row corresponds to a CpG site (or region), and each column corresponds to a cell type. The entries represent the expected methylation value (often as beta values) for each CpG in each pure cell type. +Cell-type deconvolution methods can be broadly categorized into two main approaches: -Signature matrices are typically constructed from reference datasets where DNA methylation has been measured in sorted or purified cell populations. The choice of CpGs and the quality of the reference data are critical for accurate deconvolution. Different methods use different strategies for selecting CpGs and constructing their signature matrices: +## Reference-Based Methods +Reference-based methods rely on *signature matrices* (also called reference matrices or basis matrices) to estimate the proportions of different cell types in a heterogeneous DNA methylation sample. A signature matrix is a table where each row corresponds to a CpG site (or region), and each column corresponds to a cell type. The entries represent the expected methylation value (often as beta values) for each CpG in each pure cell type. + +Signature matrices are typically constructed from reference datasets where DNA methylation has been measured in sorted or purified cell populations. The choice of CpGs and the quality of the reference data are critical for accurate deconvolution. + +## Reference-Free Methods +Reference-free methods attempt to deconvolve cell-type proportions without requiring prior knowledge of cell-type-specific methylation signatures. These methods use computational approaches such as non-negative matrix factorization (NMF) or independent component analysis (ICA) to identify latent cell-type components directly from the mixed methylation data. + +## Why deconvMe Focuses on Reference-Based Methods + +deconvMe exclusively implements reference-based deconvolution methods because they generally provide **better performance and more reliable results** compared to reference-free approaches. Reference-based methods offer several advantages: + +- **Higher accuracy**: Pre-defined signature matrices based on purified cell populations provide more reliable cell-type identification +- **Better interpretability**: Results can be directly mapped to known cell types with biological meaning +- **Consistent results**: The same signature matrix applied to different datasets produces comparable results +- **Validation capability**: Results can be validated against known cell-type proportions when available + +Different reference-based methods use different strategies for selecting CpGs and constructing their signature matrices: - **EpiDISH** uses reference matrices for blood, breast, or epithelial cell types, based on published datasets. - **Houseman** uses optimized sets of CpGs (e.g., IDOL-optimized) for blood and other tissues. From 97a48314ec9aff8edc06d1a229d30858bece6b19 Mon Sep 17 00:00:00 2001 From: alex-d13 Date: Wed, 30 Jul 2025 09:09:24 +0200 Subject: [PATCH 3/5] dont use paramter for methatlas signature --- R/methatlas.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/R/methatlas.R b/R/methatlas.R index 3018174..b47b329 100644 --- a/R/methatlas.R +++ b/R/methatlas.R @@ -70,10 +70,11 @@ run_methatlas <- function(beta_matrix, reference_atlas = system.file("reference_ #' Get MethAtlas Signature Matrix #' #' Returns the reference matrix used by MethAtlas from a CSV file. -#' @param reference_atlas Path to a csv file (default: package reference_atlas.csv) +#' #' @return Signature matrix as tibble with CpGs in rows (column 'CpGs') and cell types in columns #' @export -get_methatlas_signature_matrix <- function(reference_atlas = system.file("reference_atlas.csv", package = "deconvMe")) { +get_methatlas_signature_matrix <- function() { + reference_atlas = system.file("reference_atlas.csv", package = "deconvMe") read.csv(reference_atlas, check.names = FALSE) } \ No newline at end of file From a5adf53c2d463ef631d4aed039012ec83c4e5497 Mon Sep 17 00:00:00 2001 From: alex-d13 Date: Wed, 30 Jul 2025 10:17:02 +0200 Subject: [PATCH 4/5] overview table of methods --- R/houseman.R | 2 +- vignettes/getting_started.Rmd | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/R/houseman.R b/R/houseman.R index 1376b69..bbc5f63 100644 --- a/R/houseman.R +++ b/R/houseman.R @@ -2,7 +2,7 @@ #' #' @param methyl_set A minfi MethylSet #' @param array type of methylation array that was used. possible options are '450k' and 'EPIC' -#' @param compositeCellType Which composite cell type is being deconvoluted. Should be one of "Blood", "CordBloodCombined", "CordBlood", "CordBloodNorway", "CordTissueAndBlood", or "DLPFC". See details for preferred approaches. +#' @param compositeCellType Which composite cell type is being deconvoluted. Should be one of "Blood", "CordBloodCombined", "CordBlood", "CordBloodNorway", "CordTissueAndBlood", or "DLPFC". #' @param processMethod Joint normalization/background correction for user and reference data. For MethylSet objects only "preprocessQuantile" is available. Set it to any minfi preprocessing function as a character if you want to override it, like "preprocessFunnorm" #' @param probeSelect How should probes be selected to distinguish cell types? Options include: 1) "IDOL", (default) for using a customized set of probes obtained from IDOL optimization, available for Blood and Umbilical Cord Blood 2) "both", which selects an equal number (50) of probes (with F-stat p-value < 1E-8) with the greatest magnitude of effect from the hyper- and hypo-methylated sides, and 3) "any", which selects the 100 probes (with F-stat p-value < 1E-8) with the greatest magnitude of difference regardless of direction of effect. This according to minfi algorithm. Default input "auto" in minfi will use "any" for cord blood and "both" otherwise. Please see references for more details. #' @param cellTypes A vector of length K that contains the cell type names. Default: c("CD8T", "CD4T", "NK", "Bcell", "Mono", "Neu"). Please notice that this library use Neutrophils instead of Granulocytes. See details for your library. diff --git a/vignettes/getting_started.Rmd b/vignettes/getting_started.Rmd index 2686b51..26d6737 100644 --- a/vignettes/getting_started.Rmd +++ b/vignettes/getting_started.Rmd @@ -50,4 +50,18 @@ The result of the deconvolution is a table with the estimated cell-type fraction 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 +For more details, see the package documentation and other vignettes! + +# Overview of Included Methods + +Below is a template table summarizing the deconvolution methods included in deconvMe. This table lists each method, the type of algorithm it uses, the intended tissue types, and the type of data used to build the internal deconvolution reference. + +| Name | Algorithm Type(s) | Intended Tissue Type(s) | Reference Source Data | +|:--------------|:-------------------------|:----------------------------|:------------------------------------------------------| +| EpiDISH | Robust Partial Correlations (RPC), Constrained Projection (CP), Support Vector Regression (SVR) | Blood, Epithelial, Breast | purified blood, epithelial, and non-epithelial data, extended with DNAse Hypersensitivity Sites from Roadmap and ENCODE | +| Houseman | Constrained projection/Quadratic Programming (CP/QP) | Blood| Purified blood cell methylation profiles (IDOL-optimized) | +| MethylCC | Constrained Linear model based on DMRs | Blood (in deconvMe, can be extended to other tissues) | purified blood | +| MethylResolver | Least Trimmed Squares (LTS) regression | Blood, cancer | Purified blood methylation profiles (IDOL-optimized), extended with additional leukocytes | +| MethAtlas | non-negative least squares (NNLS) | Blood, immune, tissue-wide | Comprehensive atlas of purified tissue and immune cell methylomes | + +*This table can be expanded as new methods are added to the package.* \ No newline at end of file From 04f2ae4e63469907ac311b7b208fbc0d548525a0 Mon Sep 17 00:00:00 2001 From: alex-d13 Date: Wed, 30 Jul 2025 11:36:21 +0200 Subject: [PATCH 5/5] update tests --- tests/testthat/test_others.R | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/testthat/test_others.R b/tests/testthat/test_others.R index 14269ea..7f090bb 100644 --- a/tests/testthat/test_others.R +++ b/tests/testthat/test_others.R @@ -6,6 +6,7 @@ # result <- deconvMe::deconvolute(methyl_set = methyl_set, method = 'epidish') suppressMessages(library(deconvMe)) +options(matrixStats.useNames.NA = "deprecated") # ---------------------- # EpiDISH tests @@ -104,8 +105,7 @@ test_that("run_houseman warns and proceeds if some CpGs are missing, errors if a # ---------------------- test_that("get_methatlas_signature_matrix returns a data frame with expected structure", { - ref_path <- system.file("reference_atlas.csv", package = "deconvMe") - sig <- deconvMe::get_methatlas_signature_matrix(ref_path) + sig <- deconvMe::get_methatlas_signature_matrix() expect_s3_class(sig, "data.frame") expect_true(nrow(sig) > 0) expect_true(ncol(sig) > 0) @@ -113,14 +113,13 @@ test_that("get_methatlas_signature_matrix returns a data frame with expected str }) test_that("run_methatlas supports cpg_subset argument", { - ref_path <- system.file("reference_atlas.csv", package = "deconvMe") - sig <- deconvMe::get_methatlas_signature_matrix(ref_path) + sig <- deconvMe::get_methatlas_signature_matrix() subset_cpgs <- sig$CpGs[1:10] beta <- matrix(runif(10 * 3), nrow = 10, ncol = 3) rownames(beta) <- subset_cpgs colnames(beta) <- paste0("Sample", 1:3) expect_error( - deconvMe::run_methatlas(beta, reference_atlas = ref_path, cpg_subset = subset_cpgs), + deconvMe::run_methatlas(beta, cpg_subset = subset_cpgs), NA ) }) @@ -130,19 +129,18 @@ test_that("run_methatlas supports cpg_subset argument", { # ---------------------- test_that("run_methatlas warns and proceeds if some CpGs are missing, errors if all are missing", { - ref_path <- system.file("reference_atlas.csv", package = "deconvMe") - sig <- deconvMe::get_methatlas_signature_matrix(ref_path) + sig <- deconvMe::get_methatlas_signature_matrix() subset_cpgs <- sig$CpGs[1:5] missing_cpgs <- paste0("cg_missing_", 1:5) beta <- matrix(runif(10 * 3), nrow = 10, ncol = 3) rownames(beta) <- c(subset_cpgs, missing_cpgs) colnames(beta) <- paste0("Sample", 1:3) expect_warning( - deconvMe::run_methatlas(beta, reference_atlas = ref_path, cpg_subset = c(subset_cpgs, missing_cpgs)), + deconvMe::run_methatlas(beta, cpg_subset = c(subset_cpgs, missing_cpgs)), "not present in the reference atlas" ) expect_error( - deconvMe::run_methatlas(beta, reference_atlas = ref_path, cpg_subset = missing_cpgs), + deconvMe::run_methatlas(beta, cpg_subset = missing_cpgs), "None of the specified cpg_subset CpGs are present" ) })