CompEpigen / methrix

An R :package: for fast and flexible DNA methylation analysis
https://www.bioconductor.org/packages/release/bioc/html/methrix.html
Other
28 stars 11 forks source link

Subsetting samples will not allow report generation when recal_stats=T #17

Closed ClarissaFeuersteinAkgoz closed 4 years ago

ClarissaFeuersteinAkgoz commented 4 years ago

Here the code and the error message:

install_github( CompEpigen/methrix ,  ref = "devel_update")
library("methrix")

report.dir <- "/C010-projects/Pathway_27/SGBS_hydroxymethylation/WGoxBS/QC_all"

setwd(report.dir)
m <-readRDS("methrix_object_hs37d5.RDS")

#subset samples 
m_subset <-m[,m@ metadata$descriptive_stats$genome_stat$mean_cov>10]

#filter CpGs 
data_mask <- mask_methrix(m_subset , low_count = 2, high_quantile = 0.99)
m10masked <-coverage_filter(data_mask, cov_thr = 10, min_samples = 16)

#generate report and recalculate statistics
methrix_report(m10masked, output_dir=file.path(report.dir,"cov10" ), recal_stats = T)

**Error message:**
> _Step 1 of 5: Methylation/Coverage per chromosome  Error in merge.data.table(meth_stat, cov_stat, by = c("chr", "Sample_Name")) :    Elements listed in `by` must be valid column names in x and y In addition: Warning message: In merge.data.table(meth_stat, cov_stat, by = c("chr", "Sample_Name")) :   You are trying to join data.tables where 'x' and 'y' arguments are 0 columns data.table.
> --_
PoisonAlien commented 4 years ago

I can reproduce this. I will fix it soon.

PoisonAlien commented 4 years ago

Hi @ClarissaFeuersteinAkgoz , Sorry for the delay in addressing this issue :| I have fixed it now, could you try it out and let me know. Well I did try on your data and it worked but it would be nice if you can confirm if results are okay.

It was indeed a good bug. We used to count NAs to estimate number of uncovered/covered CpGs. However in your filtered data there were no NAs which led get_stats function to collapse. It should be fixed now. Thanks.

edit: Install from master branch.