methread location error

5 views
Skip to first unread message

Arpit Gaur

unread,
Jan 15, 2026, 9:32:41 AMJan 15
to methylkit_discussion
Hi, 

when trying to load files read using file.path() I repeatedly get an error message- 

Received single location.
Error in if (!file.exists(location)) { : the condition has length > 1

I am using this function as mentioned in the user's manual.

My codes are- 

myCHG=list("BF1.CHG.txt.gz","BGH2.CHG.txt.gz")
paths = file.path(getwd(), myCHG)

myobj = methRead(location = paths,
             sample.id = c("BF1", "BGH2"),
             pipeline = "bismarkCytosineReport",
             context= "CHG",
             assembly = "IWGSC RefSeq 2.1",
             treatment = c(0,1), header = FALSE)


Can someone please help me to understand where I am making mistake(s)?

Thank you for your help in advance.

Regards
Arpit

alex....@gmail.com

unread,
Jan 18, 2026, 11:56:56 AMJan 18
to methylkit_discussion
Hi Arpit,

Thanks for sharing this error and the associated code.  I was able to reproduce your error on my machine. 

The error you showed occurs when multiple locations are given as character strings. For multiple input files, both location and sample id have to be of type list (see code example in basics section of methylKit manual).
For now, please use this code to proceed with your analysis. 

```r

myCHG=list("BF1.CHG.txt.gz","BGH2.CHG.txt.gz")
# for multiple input files both location and sample id have to be of type list
paths = file.path(getwd(), myCHG) |> as.list()
sample_ids = c("BF1", "BGH2") |> as.list()


myobj = methRead(location = paths,
                 sample.id = sample_ids,

                 pipeline = "bismarkCytosineReport",
                 context= "CHG",
                 assembly = "IWGSC RefSeq 2.1",
                 treatment = c(0,1), header = FALSE)

```

Best,
Alex


Reply all
Reply to author
Forward
0 new messages