SKILL.md
Version Compatibility
Reference examples tested with: Bismark 0.24+, methylKit 1.28+
Before using code patterns, verify installed versions match. If versions differ:
- R:
packageVersion('<pkg>')then?function_nameto verify parameters
If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
methylKit Analysis
"Analyze methylation patterns across my samples" → Import per-cytosine methylation data, filter by coverage, normalize across samples, and test for differential methylation at individual CpG sites.
- R:
methylKit::methRead()→filterByCoverage()→normalizeCoverage()→calculateDiffMeth()
Read Bismark Coverage Files
library(methylKit)
file_list <- list('sample1.bismark.cov.gz', 'sample2.bismark.cov.gz',
'sample3.bismark.cov.gz', 'sample4.bismark.cov.gz')
sample_ids <- c('ctrl_1', 'ctrl_2', 'treat_1', 'treat_2')
treatment <- c(0, 0, 1, 1) # 0 = control, 1 = treatment
meth_obj <- methRead(
location = as.list(file_list),
sample.id = as.list(sample_ids),
treatment = treatment,
assembly = 'hg38',
context = 'CpG',
pipeline = 'bismarkCoverage'
)
Read Bismark cytosine Report
meth_obj <- methRead(
location = as.list(file_list),
sample.id = as.list(sample_ids),
treatment = treatment,
assembly = 'hg38',
context = 'CpG',
pipeline = 'bismarkCytosineReport'
)
Basic Statistics
# Coverage statistics
getMethylationStats(meth_obj[[1]], plot = TRUE, both.strands = FALSE)
# Coverage per sample
getCoverageStats(meth_obj[[1]], plot = TRUE, both.strands = FALSE)
Filter by Coverage
# Remove CpGs with very low or very high coverage
meth_filtered <- filterByCoverage(
meth_obj,
lo.count = 10, # Minimum 10 reads
lo.perc = NULL,
hi.count = NULL,
hi.perc = 99.9 # Remove top 0.1% (likely PCR artifacts)
)
