Chip-seq data analysis in R with bioconductor - change of character from "*" to "+"
2
0
Entering edit mode
7.5 years ago

I have a chip-seq data file, where the QC and trimming has already been done, as well as the mapping to the reference genome. Now I have data as follow:

 GRanges object with 2288 ranges and 0 metadata columns:
          seqnames                 ranges strand
             <Rle>              <IRanges>  <Rle>
      [1]     chr1   [16174360, 16175609]      *
      [2]     chr1   [20811067, 20812439]      *
      [3]     chr1   [22783676, 22784321]      *
      [4]     chr1   [26735004, 26735693]      *
      [5]     chr1   [27023038, 27023988]      *

How do I go about changing the "*" character to "+" seeing that the fraglen <- estimate.mean.fraglen(reads, method = "correlation") gives the following error:

Error in .local(x, ...) : x must have named elements '+' and '-'

I have tried using gsub, sub and chartr, and specifying the column, but then the whole data frame changes. Any recommendations?

R ChIP-Seq Bioconductor character change • 1.3k views
ADD COMMENT
0
Entering edit mode

What have you tried exactly ? And what do you mean by 'the whole data frame changes' ?

ADD REPLY
2
Entering edit mode
7.5 years ago

reads = reads[which(strand(reads) != "*")] or something along those lines. Of course this leads to the question of how you got unstranded alignment information to begin with...

ADD COMMENT
0
Entering edit mode
7.5 years ago
ejm32 ▴ 450

This should do the trick:

gr0 <- GRanges(Rle(c("chr2", "chr2", "chr1", "chr3"), c(1, 3, 2, 4)), IRanges(1:10, width=10:1))
gr0
strand(gr0)<-Rle("+", length(gr0))
gr0
ADD COMMENT

Login before adding your answer.

Traffic: 1574 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