When running DMRichR::processBismark(), I encountered an error related to sample name matching between the metadata file and Bismark cytosine report files. The function expects sample names in the metadata to match the names of the cytosine report files, but the pattern matching logic only works if the sample name is followed by an underscore in the filename. This causes issues with default Bismark cytosine report filenames (e.g., generated by Nextflow's methylseq pipeline with the --cytosine_report option), which don’t include an underscore before the file extension.
Steps to Reproduce:
- Prepare a metadata file (sample_info.xlsx) with a Name column containing sample names like
SRR24725548.
- Generate Bismark cytosine report files using Nextflow’s methylseq with
--cytosine_report, resulting in filenames like SRR24725548.CpG_report.txt.gz.
- Run the following code in R:
library(DMRichR) DMRichR::DM.R(genome="hg38", testCovariate="Diagnosis", cutoff=0.05)
The function throws the following error:
Assigning sample metadata with Diagnosis as factor of interest...
Error in DMRichR::processBismark(files = list.files(path = getwd(), pattern = "*.CpG_report.txt.gz"), :
sampleNames(bs) == as.character(meta$Name) are not all TRUE
> sampleNames(bs)
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'object' in selecting a method for function 'sampleNames': object 'bs' not found
Actual Behavior
The issue arises because the bs object isn’t created. The sample names in meta$Name (e.g., SRR24725548) don’t match the filenames (e.g., SRR24725548.CpG_report.txt.gz) due to DMRichR’s pattern matching, which seems to expect an underscore after the sample name. Since the default Bismark filenames lack an underscore before .CpG_report.txt.gz, the matching fails.
Expected Behavior
I resolved this by manually renaming all cytosine report files to include an underscore after the sample name. For example:
cmd: mv SRR24725548.CpG_report.txt.gz SRR24725548_.CpG_report.txt.gz
This allowed the sample names to match and the function to proceed. However, this is inconvenient, especially when dealing with large datasets.
Suggested Fix
It would be great if DMRichR’s pattern matching could be updated to handle filenames without requiring an underscore after the sample name. Perhaps the function could use a more flexible regex pattern or allow users to specify a custom pattern for matching sample names to filenames.
Additional Information
-
DMRichR Version:
> packageVersion("DMRichR")
[1] ‘1.7.8’
-
R Version:
> R.version.string
[1] "R version 4.3.3 (2024-02-29)"
Operating System:
PRETTY_NAME="Ubuntu 24.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
When running
DMRichR::processBismark(), I encountered an error related to sample name matching between the metadata file and Bismark cytosine report files. The function expects sample names in the metadata to match the names of the cytosine report files, but the pattern matching logic only works if the sample name is followed by an underscore in the filename. This causes issues with default Bismark cytosine report filenames (e.g., generated by Nextflow's methylseq pipeline with the --cytosine_report option), which don’t include an underscore before the file extension.Steps to Reproduce:
SRR24725548.--cytosine_report, resulting in filenames like SRR24725548.CpG_report.txt.gz.library(DMRichR) DMRichR::DM.R(genome="hg38", testCovariate="Diagnosis", cutoff=0.05)The function throws the following error:
Actual Behavior
The issue arises because the
bsobject isn’t created. The sample names inmeta$Name(e.g., SRR24725548) don’t match the filenames (e.g., SRR24725548.CpG_report.txt.gz) due to DMRichR’s pattern matching, which seems to expect an underscore after the sample name. Since the default Bismark filenames lack an underscore before .CpG_report.txt.gz, the matching fails.Expected Behavior
I resolved this by manually renaming all cytosine report files to include an underscore after the sample name. For example:
cmd:
mv SRR24725548.CpG_report.txt.gz SRR24725548_.CpG_report.txt.gzThis allowed the sample names to match and the function to proceed. However, this is inconvenient, especially when dealing with large datasets.
Suggested Fix
It would be great if DMRichR’s pattern matching could be updated to handle filenames without requiring an underscore after the sample name. Perhaps the function could use a more flexible regex pattern or allow users to specify a custom pattern for matching sample names to filenames.
Additional Information
DMRichR Version:
R Version:
Operating System: