MethylKit read issue
1
0
Entering edit mode
CHEN • 0
@b99ae545
Last seen 13 days ago
China

Hi!

I am trying to read the following files into a raw MethylKit. However I am getting an error. enter image description here

The error is: Error in if (is.na(treatment)) stop("Treatment vector is missing.") : the condition has length > 1

Has anyone else had this issue?

These are my codes

setwd("/Volumes/One Touch/3.1.Cout")
library(methylKit)
library(xlsx)

sampleinfo <- read.xlsx("/Volumes/One Touch/3.1.Cout/sampleinfo.xlsx",sheetName = "1")
head(sampleinfo)
 #  grade        id treatment1 treatment2
 #1 Normal 02-T17325          0          0
#2  CIN1 02-T17380          0          0
#3  CIN1 02-T17397          0          0
#4  Normal 02-T17407          0          0
#5  Normal 02-T17411          0          0
#6 Normal 02-T17451          0          0

file_list2 <- list(paste0(sampleinfo$id,".met.txt.gz"))
myobj <-  methRead(file_list2,
                    sample.id=sampleinfo$id,
                    context = "CpG",
                    assembly="hg19",
                    treatment=sampleinfo$treatment1
  )


# Received list of locations.
Error in if (is.na(treatment)) stop("Treatment vector is missing.") : 
  the condition has length > 1


sessionInfo( )

#R version 4.3.1 (2023-06-16)
#Platform: x86_64-apple-darwin20 (64-bit)
#Running under: macOS Big Sur 11.7.10

#Matrix products: default
#BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
#LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

attached base packages:
[1] stats4    stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
 [1] xlsx_0.6.5                        BSgenome.Hsapiens.UCSC.hg19_1.4.3
 [3] BSgenome_1.70.2                   rtracklayer_1.62.0               
 [5] BiocIO_1.12.0                     Biostrings_2.70.3                
 [7] XVector_0.42.0                    methylKit_1.28.0                 
 [9] GenomicRanges_1.54.1              GenomeInfoDb_1.38.8              
[11] IRanges_2.36.0                    S4Vectors_0.40.2                 
[13] BiocGenerics_0.48.1              

loaded via a namespace (and not attached):
 [1] tidyselect_1.2.1            dplyr_1.1.4                
 [3] R.utils_2.12.3              bitops_1.0-7               
 [5] RCurl_1.98-1.14             GenomicAlignments_1.38.2   
 [7] XML_3.99-0.16.1             lifecycle_1.0.4            
 [9] survival_3.5-8              statmod_1.5.0              
[11] magrittr_2.0.3              compiler_4.3.1             
[13] rlang_1.1.3                 tools_4.3.1                
[15] utf8_1.2.4                  yaml_2.3.8                 
[17] data.table_1.15.4           S4Arrays_1.2.1             
[19] mclust_6.1                  DelayedArray_0.28.0        
[21] plyr_1.8.9                  abind_1.4-5                
[23] BiocParallel_1.36.0         HDF5Array_1.30.1           
[25] numDeriv_2016.8-1.1         R.oo_1.26.0                
[27] grid_4.3.1                  fansi_1.0.6                
[29] colorspace_2.1-0            Rhdf5lib_1.24.2            
[31] ggplot2_3.5.0               scales_1.3.0               
[33] gtools_3.9.5                iterators_1.0.14           
[35] MASS_7.3-60.0.1             SummarizedExperiment_1.32.0
[37] bbmle_1.0.25.1              cli_3.6.2                  
[39] mvtnorm_1.2-4               crayon_1.5.2               
[41] generics_0.1.3              rstudioapi_0.16.0          
[43] reshape2_1.4.4              rjson_0.2.21               
[45] DelayedMatrixStats_1.24.0   bdsmatrix_1.3-7            
[47] rhdf5_2.46.1                qvalue_2.34.0              
[49] stringr_1.5.1               zlibbioc_1.48.2            
[51] splines_4.3.1               parallel_4.3.1             
[53] BiocManager_1.30.22         restfulr_0.0.15            
[55] matrixStats_1.2.0           vctrs_0.6.5                
[57] methrix_1.16.0              glmnet_4.1-8               
[59] Matrix_1.6-5                fastseg_1.48.0             
[61] foreach_1.5.2               limma_3.58.1               
[63] glue_1.7.0                  emdbook_1.3.13             
[65] codetools_0.2-19            rJava_1.0-11               
[67] stringi_1.8.3               shape_1.4.6.1              
[69] gtable_0.3.4                munsell_0.5.0              
[71] tibble_3.2.1                pillar_1.9.0               
[73] xlsxjars_0.6.1              rhdf5filters_1.14.1        
[75] GenomeInfoDbData_1.2.11     R6_2.5.1                   
[77] sparseMatrixStats_1.14.0    lattice_0.22-6             
[79] Biobase_2.62.0              R.methodsS3_1.8.2          
[81] Rsamtools_2.18.0            Rcpp_1.0.12                
[83] fastJT_1.0.6                coda_0.19-4.1              
[85] SparseArray_1.2.4           MatrixGenerics_1.14.0      
[87] pkgconfig_2.0.3

Best wishes,

Shimin

methylKit • 192 views
ADD COMMENT
0
Entering edit mode

I am experiencing precisely the same issue and encounter the same error: "Received list of locations. Error in if (is.na(treatment)) stop("Treatment vector is missing.") : the condition has length > 1"

I have confirmed that inputted filepaths (list of named filepaths), ids (vector of character ids), and treatment assignments (vector of 0/1 treatment assignment) are correctly formatted as specified, and that the input files are correctly formatted. Import of a single file runs successfully, but providing a list of files returns the error that OP posted.

Has anyone else encountered this or found a workaround?

ADD REPLY
1
Entering edit mode
@james-w-macdonald-5106
Last seen 16 hours ago
United States

The argument for sample.id, if you pass a list of samples, must also be a list.

## from the examples
> file.list=list(
              system.file("extdata", "test1.myCpG.txt", package = "methylKit"),
              system.file("extdata", "test2.myCpG.txt", package = "methylKit"),
              system.file("extdata", "control1.myCpG.txt", package = "methylKit"),
              system.file("extdata", "control2.myCpG.txt", package = "methylKit") 
              )
> d.f <- data.frame(id = c("test1","test2","ctl1","ctl2"), treatment = c(1,1,0,0))

> myobj <- methRead(file.list, d.f$id, "hg18", treatment = d.f$treatment)
Received list of locations.
Error in if (is.na(treatment)) stop("Treatment vector is missing.") : 
  the condition has length > 1

> myobj <- methRead(file.list, as.list(d.f$id), "hg18", treatment = d.f$treatment)
Received list of locations.
Reading file.
Reading file.
Reading file.
Reading file.

Login before adding your answer.

Traffic: 460 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6