compare_CherryFreqs: Compare Methylation Frequencies Between Two Tips

View source: R/summaryStatistics.R

compare_CherryFreqsR Documentation

Compare Methylation Frequencies Between Two Tips

Description

Performs a chi-squared test to compare the distribution of methylation states (unmethylated 0, partially-methylated 0.5, and methylated 1) between two cherry tips. A cherry is a pair of leaf nodes (also called tips or terminal nodes) in a phylogenetic tree that share a direct common ancestor.

Usage

compare_CherryFreqs(tip1, tip2, testing = FALSE)

Arguments

tip1

A numeric vector representing methylation states (0, 0.5, 1) at tip 1.

tip2

A numeric vector representing methylation states (0, 0.5, 1) at tip 2.

testing

Logical; if TRUE, returns additional intermediate data including the contingency table and test result.

Details

The function uses simulate.p.value = TRUE in chisq.test to compute the p-value via Monte Carlo simulation to improve reliability regardless of whether the expected frequencies meet the assumptions of the chi-squared test (i.e., expected counts of at least 5 in each category).

Value

If testing = TRUE, returns a list with the contingency table and chi-squared test results. Otherwise, returns the p-value of the test.

Examples

tip1 <- c(0, 0, 1, 0.5, 1, 0.5)
tip2 <- c(0, 1, 1, 0, 0.5, 0.5)
compare_CherryFreqs(tip1, tip2)


MethEvolSIM documentation built on April 12, 2025, 1:30 a.m.