[Bioc-devel] Modification of seqnames in GRanges
Liu,Bin
BLiu1 at mdanderson.org
Fri Oct 28 18:56:21 CEST 2011
Hi,
I have a question about how to modify the seqnames in below. I would like to remove chr in the seqnames.
For example: "chr2L" -> "2L". I tried the following code and got an error:
> seqnames(gr1) <- sub("chr", "", seqnames(gr1))
Error in `seqnames<-`(`*tmp*`, value = <S4 object of class "Rle">) :
levels of supplied 'seqnames' must be identical to 'seqlevels(x)'
With the following checking, it seems chrM is not in seqnames but is in the levels.
> levels(seqnames(gr1))
[1] "chr2L" "chr2LHet" "chr2R" "chr2RHet" "chr3L" "chr3LHet"
[7] "chr3R" "chr3RHet" "chr4" "chrU" "chrUextra" "chrX"
[13] "chrXHet" "chrYHet" "chrM"
> unique(seqnames(gr1))
[1] chr2L chr2LHet chr2R chr2RHet chr3L chr3LHet chr3R
[8] chr3RHet chr4 chrU chrUextra chrX chrXHet chrYHet
15 Levels: chr2L chr2LHet chr2R chr2RHet chr3L chr3LHet chr3R chr3RHet ... chrM
Any way to solve the problem? Thanks for the help.
Bin Liu
> gr1
GRanges with 48498 ranges and 0 elementMetadata values:
seqnames ranges strand
<Rle> <IRanges> <Rle>
[1] chr2L [ 8117, 8192] +
[2] chr2L [11345, 11409] +
[3] chr2L [11519, 11778] +
[4] chr2L [12222, 12285] +
[5] chr2L [12929, 13519] +
[6] chr2L [13626, 13682] +
[7] chr2L [14875, 14932] +
[8] chr2L [15712, 17052] +
[9] chr2L [17213, 18025] +
... ... ... ...
[48490] chrYHet [191815, 191893] +
[48491] chrYHet [192066, 206119] +
[48492] chrYHet [229343, 232315] +
[48493] chrYHet [232496, 232758] +
[48494] chrYHet [233403, 233455] +
[48495] chrYHet [233595, 271120] +
[48496] chrYHet [280371, 291285] +
[48497] chrYHet [305380, 305531] +
[48498] chrYHet [306016, 306486] +
---
seqlengths:
chr2L chr2LHet chr2R chr2RHet ... chrXHet chrYHet chrM
23011544 368872 21146708 3288761 ... 204112 347038 19517
More information about the Bioc-devel
mailing list