Chip-seq data analysis in R with bioconductor - change of character from "*" to "+"
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?
• 1,868 views
•
link
2 answers
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...
• 0 views
•
link
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
• 0 views
•
link
Log in to answer this question.
What have you tried exactly ? And what do you mean by 'the whole data frame changes' ?