Hi Lei,
Yes this is possible. If you have your genes as a GRanges object (this is how I did it, you might have another approach):
ann_granges = read_gff3("../../path/annotation.gff3")
genes_granges = ann_granges %>% filter(type == "gene") #using dplyr functions
you can then use the "regionCounts" function to summarise the methylated and unmethylated Cs for each gene:
#Assume "db" is you methyl database object
counts_gene = regionCounts(db, genes_granges)
You can then use the functions like normal:
lapply(counts_gene, getMethylationStats, plot=F)
lapply(counts_gene, getCoverageStats, plot=F)
counts_gene_f = filterByCoverage(counts_gene, hi.count = 100000) #need to check the plots/info to work out what this should be
counts_gene_fu = methylKit::unite(counts_gene_f, destrand=FALSE, min.per.group = 3L, suffix = "genes_fu3") #some of these options are specifc to what I was doing.
... etc
Hope that helps.
David