This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Bsseq problem error at least two dimensions

hello,everyone. i am a new learner on bioinformatics. recently, i have use the bsseq software to deal with the data. but i have meet some error message. which i can not solve. here is my code:

library(bsseq)
setwd("/home/dnamethylation/testbsseq")
data <- list.files(path="/home/dnamethylation/testbsseq", pattern = "*.cov")
bismarkbsseq <- read.bismark(files = data, sampleNames = gsub(".cov", "", data), rmZeroCov = TRUE, strandCollapse = FALSE)
bsseq_bsmooth <- BSmooth(bismarkbsseq, verbose = TRUE, mc.cores = 24)
BS.cov <- getCoverage(bsseq_bsmooth)
keepLoci.ex <- which(rowSums(BS.cov[, bismarkbsseq$Type == "SSA", drop=F] >= 2) >= 2 & rowSums(BS.cov[, bismarkbsseq$Type == "normal", drop=F] >= 2) >= 2) # (here i do not understand why bismarkbsseq$Type == "SSA" , the "SSA" represent what meaning? can i name it "cancer" or other name?)

after that, i got an error message

Error in rowSums(BS.cov[, bismarkbsseq$Type == "SSA"] >= 2) : 
  'x' must be an array of at least two dimensions

I really do not know how to deal with it? would you please give me some advice? thanks in advance! best wishes xia

software error

You should add some colData if you're going to try and use it to filter by.

thank you so much for your reply.do you mean i should change the command like this? bismarkbsseq <- read.bismark(files = data, sampleNames = gsub(".cov", "", data), colData=c("a1","a2","b1","b2"), rmZeroCov = TRUE, strandCollapse = FALSE)

but when i change the command, it gives me such error message:(colData = c("a1", "b1", "a1", "b2")) is useless

in this step, i store the 4 samples in a directory,should i sepreate them into two directory?how can i add some colData?would you please give me some guidence? thanks in advance xia

You might have to give it to the BSmooth() command, it's been a while since I've used bsseq.

thanks for your reply, now i have change my command to : bismarkbsseq5 <- read.bismark(files = data, sampleNames = gsub(".cov", "", c("A1","B1","A2","B2")), rmZeroCov = TRUE, strandCollapse = FALSE), and i hope this may works, but i still do not know "SSA" "normal" represent what meaning, if it represents the colname of the data? can i change my command into this? keepLoci.ex <- which(rowSums(BS.cov[, bismarkbsseq$Type == "A", drop=F] >= 2) >= 2 & rowSums(BS.cov[, bismarkbsseq$Type == "B", drop=F] >= 2) >= 2) i am appreciate for your help, would you please give me some advice? thanks in advance xia

i have try to change the name in BSmooth(), but i can not put them into the command. here is the user_guidence instruction: BSmooth(BSseq, ns = 70, h = 1000, maxGap = 10^8, keep.se = FALSE, BPPARAM = bpparam(), chunkdim = NULL, level = NULL, verbose = getOption("verbose")) ,it seems i can not put the name into it. but i am not sure. thanks for you help!

According to the manual you need to give a dataframe to read.bismark(). SSA and such in that code are meant to be your groups, so you'll need to change it to match what you're using.

thanks for your help! after i change my command into: bismarkbsseq5 <- read.bismark(files = data, sampleNames = gsub(".cov", "", c("A1","B1","A2","B2")), rmZeroCov = TRUE, strandCollapse = FALSE) bsseq_bsmooth5 <- BSmooth(bismarkbsseq5, verbose = TRUE, mc.cores = 24) BS.cov <- getCoverage(bsseq_bsmooth5) when i put the command: head(BS.cov, n=5), it gives me such message A1 B1 A2 B2 [1,] 1 5 2 4 [2,] 1 0 0 0 [3,] 2 5 1 3 [4,] 1 2 0 1 [5,] 0 3 1 1 and when i use the command:colnames(bsseq_bsmooth5),here is the result "A1" "B1" "A2" "B2", it seems that i add the colname to the data, but when i use the command:keepLoci.ex <- which(rowSums(BS.cov[, bismarkbsseq$Type == "A", drop=F] >= 2) >= 2 & rowSums(BS.cov[, bismarkbsseq$Type == "B", drop=F] >= 2) >= 2) ,it still gives me error message like previously: Error in rowSums(BS.cov[, bismarkbsseq$Type == "A", drop = F] >= 2) : 'x' must be an array of at least two dimensions...i am sorry to bother you, but would you please point out which mistake do i made? thanks in advance xia

sorry, i put the wrong command:keepLoci.ex <- which(rowSums(BS.cov[, bismarkbsseq5$Type == "A", drop=F] >= 2) >= 2 & rowSums(BS.cov[, bismarkbsseq5$Type == "B", drop=F] >= 2) >= 2) Error in rowSums(BS.cov[, bismarkbsseq5$Type == "A", drop = F] >= 2) : 'x' must be an array of at least two dimensions, it still give me error message as previously.

1 answer

hello, again,thanks for your persistent help! it seems it works with me after i name the data,here is all my command,i hope this may help:

library(bsseq)
setwd("/home/dnamethylation/testbsseq")
data <- list.files(path="/home/dnamethylation/testbsseq", pattern = "*.cov")
bismarkbsseq5 <- read.bismark(files = data, sampleNames = gsub(".cov", "", c("A1","B1","A2","B2")), rmZeroCov = TRUE, strandCollapse = FALSE)  #(please remember name the data!!!!!name the data!!!!!)
bsseq_bsmooth <- BSmooth(bismarkbsseq5, verbose = TRUE, mc.cores = 24)
bsseq_data_tstats <- BSmooth.tstat(bsseq_bsmooth5, group1= c("A1","A2"), group2= c("B1", "B2"),estimate.var = "group2")
dmr_list <- dmrFinder(bsseq_data_tstats, verbose = TRUE)
write.csv(dmr_list,"no_cutoff_dmr.csv")

this command may not perfect, but it works on my system, and this problem troubles me for a long time, i hope this may help others.

Devon, thanks for your persistent help!!!thank you so much!! best wishes xia

Log in to answer this question.