Search
Question: Subsetting GRanges objext
0
gravatar for lalchungnungabt17
12 weeks ago by
lalchungnungabt170 wrote:

Hi,

I have a GRanges object "MB_granges" which has data from Chr1 - Chr22, also ChrX and ChrY. I had removed ChrX and ChrY using the following command. 

> seqnames(MB_granges)
factor-Rle of length 485512 with 24 runs
  Lengths: 46857 34810 25159 20464 24327 36611 30017 20950  9861 24388 ... 21969 27879  5922 25521 10379  4243  8552 11232   416
  Values :  chr1  chr2  chr3  chr4  chr5  chr6  chr7  chr8  chr9 chr10 ... chr16 chr17 chr18 chr19 chr20 chr21 chr22  chrX  chrY
Levels(24): chr1 chr2 chr3 chr4 chr5 chr6 chr7 chr8 chr9 chr10 ... chr15 chr16 chr17 chr18 chr19 chr20 chr21 chr22 chrX chrY

>Desired_seqnames=c("chr1","chr2","chr3","chr4","chr5","chr6","chr7","chr8","ch9","chr10","chr11","chr12","chr13","chr14","chr15","chr16","chr17","chr18","chr19","chr20","chr21","chr22")

>New_MB_granges=subset(MB_granges, seqnames %in% Desired_seqnames)

But, when i check the sequence name of the new GRanges object, ChrX and ChrY still appears at the Levels, even though i was able to remove ChrX and ChrY. Can i get help how to get rid of this? I guess it might create problems later on. OR is this the correct way of subsetting a GRanges object?

seqnames(New_MB_granges)

factor-Rle of length 464003 with 21 runs
  Lengths: 46857 34810 25159 20464 24327 36611 30017 20950 24388 28794 ... 15078 15259 21969 27879  5922 25521 10379  4243  8552
  Values :  chr1  chr2  chr3  chr4  chr5  chr6  chr7  chr8 chr10 chr11 ... chr14 chr15 chr16 chr17 chr18 chr19 chr20 chr21 chr22
Levels(24): chr1 chr2 chr3 chr4 chr5 chr6 chr7 chr8 chr9 chr10 ... chr15 chr16 chr17 chr18 chr19 chr20 chr21 chr22 chrX chrY

 

Thank you in advance!

ADD COMMENTlink modified 12 weeks ago by James W. MacDonald48k • written 12 weeks ago by lalchungnungabt170
1
gravatar for Michael Lawrence
12 weeks ago by
United States
Michael Lawrence10k wrote:

This is the way factors work, and the behavior can be useful. To adjust the seqlevels, use a convenience function like keepSeqlevels(), or the seqlevels<-() setter.

ADD COMMENTlink written 12 weeks ago by Michael Lawrence10k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 157 users visited in the last hour